mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
requested changes
This commit is contained in:
parent
7eb3f2f479
commit
92aae397e6
@ -54,9 +54,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dockerImageCustom",
|
"name": "dockerImageCustom",
|
||||||
"label": "Docker Image URL",
|
"label": "Custom Docker Image",
|
||||||
"placeholder": "e.g. oceanprotocol/algo_dockers:node-vibrant or https://example.com/image_path:image_tag",
|
"placeholder": "e.g. oceanprotocol/algo_dockers:node-vibrant or quay.io/startx/mariadb",
|
||||||
"help": "Provide the name and the tag of a public Docker hub image or the full URL if you have it hosted in a 3rd party repository",
|
"help": "Provide the name and the tag of a public Docker hub image or the custom image if you have it hosted in a 3rd party repository",
|
||||||
"type": "container",
|
"type": "container",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
@ -69,7 +69,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "dockerImageCustomEntrypoint",
|
"name": "dockerImageCustomEntrypoint",
|
||||||
"label": "Docker Entrypoint",
|
"label": "Docker Image Entrypoint",
|
||||||
"placeholder": "e.g. python $ALGO",
|
"placeholder": "e.g. python $ALGO",
|
||||||
"help": "Provide the entrypoint for your algorithm.",
|
"help": "Provide the entrypoint for your algorithm.",
|
||||||
"required": true
|
"required": true
|
||||||
|
@ -268,7 +268,7 @@ export async function getAlgorithmDatasetsForCompute(
|
|||||||
const query = generateBaseQuery(baseQueryParams)
|
const query = generateBaseQuery(baseQueryParams)
|
||||||
const computeDatasets = await queryMetadata(query, cancelToken)
|
const computeDatasets = await queryMetadata(query, cancelToken)
|
||||||
|
|
||||||
if (computeDatasets.totalResults === 0) return []
|
if (computeDatasets?.totalResults === 0) return []
|
||||||
|
|
||||||
const datasets = await transformAssetToAssetSelection(
|
const datasets = await transformAssetToAssetSelection(
|
||||||
datasetProviderUri,
|
datasetProviderUri,
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { LoggerInstance } from '@oceanprotocol/lib'
|
import { LoggerInstance } from '@oceanprotocol/lib'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import isUrl from 'is-url-superb'
|
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
export interface dockerContainerInfo {
|
export interface dockerContainerInfo {
|
||||||
@ -8,7 +7,7 @@ export interface dockerContainerInfo {
|
|||||||
checksum: string
|
checksum: string
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getDockerHubImageChecksum(
|
export async function getContainerChecksum(
|
||||||
image: string,
|
image: string,
|
||||||
tag: string
|
tag: string
|
||||||
): Promise<dockerContainerInfo> {
|
): Promise<dockerContainerInfo> {
|
||||||
@ -30,7 +29,7 @@ async function getDockerHubImageChecksum(
|
|||||||
response.data.status !== 'success'
|
response.data.status !== 'success'
|
||||||
) {
|
) {
|
||||||
toast.error(
|
toast.error(
|
||||||
'Could not fetch docker hub image info. Please check container image and tag and try again'
|
'Could not fetch docker hub image informations. If you have it hosted in a 3rd party repository please fill in the container checksum manually.'
|
||||||
)
|
)
|
||||||
return containerInfo
|
return containerInfo
|
||||||
}
|
}
|
||||||
@ -40,44 +39,8 @@ async function getDockerHubImageChecksum(
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
LoggerInstance.error(error.message)
|
LoggerInstance.error(error.message)
|
||||||
toast.error(
|
toast.error(
|
||||||
'Could not fetch docker hub image info. Please check container image and tag and try again'
|
'Could not fetch docker hub image informations. If you have it hosted in a 3rd party repository please fill in the container checksum manually.'
|
||||||
)
|
)
|
||||||
return containerInfo
|
return containerInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validateContainerImageUrl(
|
|
||||||
imageURL: string
|
|
||||||
): Promise<dockerContainerInfo> {
|
|
||||||
const containerInfo: dockerContainerInfo = {
|
|
||||||
exists: false,
|
|
||||||
checksum: null
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
const response = await axios.head(imageURL)
|
|
||||||
if (!response || response.status !== 200) {
|
|
||||||
toast.error(
|
|
||||||
'Could not fetch docker image info. Please check URL and try again'
|
|
||||||
)
|
|
||||||
return containerInfo
|
|
||||||
}
|
|
||||||
containerInfo.exists = true
|
|
||||||
return containerInfo
|
|
||||||
} catch (error) {
|
|
||||||
LoggerInstance.error(error.message)
|
|
||||||
toast.error(
|
|
||||||
'Could not fetch docker image info. Please check URL and try again'
|
|
||||||
)
|
|
||||||
return containerInfo
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getContainerChecksum(
|
|
||||||
dockerImage: string,
|
|
||||||
tag: string
|
|
||||||
): Promise<dockerContainerInfo> {
|
|
||||||
const isValid = isUrl(dockerImage)
|
|
||||||
? await validateContainerImageUrl(dockerImage)
|
|
||||||
: await getDockerHubImageChecksum(dockerImage, tag)
|
|
||||||
return isValid
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import { filesize } from 'filesize'
|
import filesize from 'filesize'
|
||||||
import cleanupContentType from '@utils/cleanupContentType'
|
import cleanupContentType from '@utils/cleanupContentType'
|
||||||
import styles from './index.module.css'
|
import styles from './index.module.css'
|
||||||
import Loader from '@shared/atoms/Loader'
|
import Loader from '@shared/atoms/Loader'
|
||||||
|
@ -24,22 +24,23 @@ export default function ContainerInput(props: InputProps): ReactElement {
|
|||||||
try {
|
try {
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
const parsedContainerValue = container?.split(':')
|
const parsedContainerValue = container?.split(':')
|
||||||
const imageNname = parsedContainerValue?.slice(0, -1).join(':')
|
const imageName =
|
||||||
|
parsedContainerValue?.length > 1
|
||||||
|
? parsedContainerValue?.slice(0, -1).join(':')
|
||||||
|
: parsedContainerValue[0]
|
||||||
const tag =
|
const tag =
|
||||||
parsedContainerValue?.length > 1 ? parsedContainerValue?.at(-1) : ''
|
parsedContainerValue?.length > 1 ? parsedContainerValue?.at(-1) : ''
|
||||||
const containerInfo = await getContainerChecksum(imageNname, tag)
|
const containerInfo = await getContainerChecksum(imageName, tag)
|
||||||
if (containerInfo.exists) {
|
setFieldValue('metadata.dockerImageCustom', imageName)
|
||||||
setFieldValue('metadata.dockerImageCustom', imageNname)
|
setFieldValue('metadata.dockerImageCustomTag', tag)
|
||||||
setFieldValue('metadata.dockerImageCustomTag', tag)
|
setChecked(true)
|
||||||
setChecked(true)
|
if (containerInfo.checksum) {
|
||||||
if (containerInfo.checksum) {
|
setFieldValue(
|
||||||
setFieldValue(
|
'metadata.dockerImageCustomChecksum',
|
||||||
'metadata.dockerImageCustomChecksum',
|
containerInfo.checksum
|
||||||
containerInfo.checksum
|
)
|
||||||
)
|
helpersChecksum.setTouched(false)
|
||||||
helpersChecksum.setTouched(false)
|
setIsValid(true)
|
||||||
setIsValid(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setFieldError(`${field.name}[0].url`, error.message)
|
setFieldError(`${field.name}[0].url`, error.message)
|
||||||
|
Loading…
Reference in New Issue
Block a user