1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

integrate compute options into form data, expose default option

This commit is contained in:
Matthias Kretschmann 2021-11-29 16:49:38 +00:00
parent 8a60aaf3f5
commit 9bd9156553
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 39 additions and 15 deletions

View File

@ -141,6 +141,15 @@
"options": ["Forever", "1 day", "1 week", "1 month", "1 year"], "options": ["Forever", "1 day", "1 week", "1 month", "1 year"],
"sortOptions": false, "sortOptions": false,
"required": true "required": true
},
{
"name": "computeOptions",
"label": "Compute Environment",
"type": "radio",
"options": [
"populated from computeEnvironmentDefaults in Publish/_constants & computeEnvironmentOptions in Publish/Services/"
],
"required": true
} }
] ]
}, },

View File

@ -6,8 +6,8 @@ import IconCompute from '@images/compute.svg'
import content from '../../../../content/publish/form.json' import content from '../../../../content/publish/form.json'
import { getFieldContent } from '../_utils' import { getFieldContent } from '../_utils'
import { FormPublishData } from '../_types' import { FormPublishData } from '../_types'
import { useWeb3 } from '@context/Web3'
import { getOceanConfig } from '@utils/ocean' import { getOceanConfig } from '@utils/ocean'
import { computeEnvironmentDefaults } from '../_constants'
const accessTypeOptionsTitles = getFieldContent( const accessTypeOptionsTitles = getFieldContent(
'access', 'access',
@ -38,6 +38,10 @@ export default function ServicesFields(): ReactElement {
} }
] ]
const computeEnvironmentOptions = [
`Default: ${computeEnvironmentDefaults.cpu} CPU, ${computeEnvironmentDefaults.memory} memory, ${computeEnvironmentDefaults.volumeSize} disk`
]
// Auto-change access type based on algo privacy boolean. // Auto-change access type based on algo privacy boolean.
// Could be also done later in transformPublishFormToDdo(). // Could be also done later in transformPublishFormToDdo().
useEffect(() => { useEffect(() => {
@ -84,6 +88,15 @@ export default function ServicesFields(): ReactElement {
component={Input} component={Input}
name="services[0].providerUrl" name="services[0].providerUrl"
/> />
{values.services[0].access === 'compute' && (
<Field
{...getFieldContent('computeOptions', content.services.fields)}
component={Input}
name="services[0].computeOptions"
options={computeEnvironmentOptions}
disabled
/>
)}
<Field <Field
{...getFieldContent('files', content.services.fields)} {...getFieldContent('files', content.services.fields)}
component={Input} component={Input}

View File

@ -36,6 +36,19 @@ export const wizardSteps: StepContent[] = [
} }
] ]
export const computeEnvironmentDefaults: ServiceComputeOptions = {
namespace: 'ocean-compute',
cpu: 1,
gpu: 0,
gpuType: '',
memory: '1Gb',
volumeSize: '1Gb',
allowRawAlgorithm: false,
allowNetworkAccess: true,
publisherTrustedAlgorithmPublishers: null,
publisherTrustedAlgorithms: null
}
export const initialValues: FormPublishData = { export const initialValues: FormPublishData = {
user: { user: {
stepCurrent: 1, stepCurrent: 1,
@ -65,7 +78,8 @@ export const initialValues: FormPublishData = {
providerUrl: { providerUrl: {
url: 'https://provider.mainnet.oceanprotocol.com', url: 'https://provider.mainnet.oceanprotocol.com',
valid: true valid: true
} },
computeOptions: computeEnvironmentDefaults
} }
], ],
pricing: { pricing: {
@ -98,16 +112,3 @@ export const algorithmContainerPresets: MetadataAlgorithmContainer[] = [
checksum: '' checksum: ''
} }
] ]
export const computeEnvironmentDefaults: ServiceComputeOptions = {
namespace: 'ocean-compute',
cpu: 1,
gpu: 0,
gpuType: '',
memory: '1Gb',
volumeSize: '1Gb',
allowRawAlgorithm: false,
allowNetworkAccess: true,
publisherTrustedAlgorithmPublishers: null,
publisherTrustedAlgorithms: null
}

View File

@ -17,6 +17,7 @@ export interface FormPublishService {
access: 'Download' | 'Compute' | string access: 'Download' | 'Compute' | string
providerUrl?: { url: string; valid: boolean } providerUrl?: { url: string; valid: boolean }
algorithmPrivacy?: boolean algorithmPrivacy?: boolean
computeOptions?: ServiceComputeOptions
} }
export interface FormPublishData { export interface FormPublishData {