From 83ea6723e0f74ac65d46086d137024a2eb9fbd8b Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 24 Jan 2020 15:23:50 +0100 Subject: [PATCH] algorithm metadata --- integration/ocean/Compute.test.ts | 16 +++++++++++++++- integration/utils/ddo-metadata-generator.ts | 14 +++++++++++++- src/ddo/MetaData.ts | 14 ++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/integration/ocean/Compute.test.ts b/integration/ocean/Compute.test.ts index 51c7070..8958dd8 100644 --- a/integration/ocean/Compute.test.ts +++ b/integration/ocean/Compute.test.ts @@ -3,6 +3,7 @@ import { assert } from 'chai' import { config } from '../config' import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid import { getMetadata } from '../utils' +import { ServiceType } from '../../src/ddo/Service' describe('Compute', () => { let ocean: Ocean @@ -12,11 +13,24 @@ describe('Compute', () => { const metadataAsset = getMetadata() const metadataAlgorithm = getMetadata(0, 'algorithm') + const assetComputeService = { + type: 'compute' as ServiceType, + index: 2, + attributes: { + main: { + serviceAgreementTemplate: { + contractName: '' + } + } + } + } before(async () => { ocean = await Ocean.getInstance(config) ;[account] = await ocean.accounts.list() - ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account) + ddoAsset = await ocean.assets.create(metadataAsset as MetaData, account, [ + assetComputeService + ]) ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account) }) diff --git a/integration/utils/ddo-metadata-generator.ts b/integration/utils/ddo-metadata-generator.ts index 94078ae..6ebc29b 100644 --- a/integration/utils/ddo-metadata-generator.ts +++ b/integration/utils/ddo-metadata-generator.ts @@ -46,6 +46,17 @@ const metadata: Partial = { } } +const algorithmMeta = { + language: 'scala', + format: 'docker-image', + version: '0.1', + container: { + entrypoint: 'ocean-entrypoint.sh', + image: '', + tag: '' + } +} + export const generateMetadata = ( name: string, type?: 'dataset' | 'algorithm', @@ -56,7 +67,8 @@ export const generateMetadata = ( ...metadata.main, name, type: type || 'dataset', - price: (price || 21) + '0'.repeat(18) + price: (price || 21) + '0'.repeat(18), + algorithm: type === 'algorithm' && algorithmMeta }, additionalInformation: { ...metadata.additionalInformation diff --git a/src/ddo/MetaData.ts b/src/ddo/MetaData.ts index 3a9858c..dacaec2 100644 --- a/src/ddo/MetaData.ts +++ b/src/ddo/MetaData.ts @@ -84,6 +84,18 @@ export interface File { compression?: string } +export interface Algorithm { + container: { + entrypoint: string + image: string + tag: string + } + language?: string + format?: string + version?: string + files?: File[] +} + /** * Main attributes of assets metadata. * @see https://github.com/oceanprotocol/OEPs/tree/master/8 @@ -151,6 +163,8 @@ export interface MetaDataMain { encryptedService?: any service?: Service + + algorithm?: Algorithm } /**