1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00

algorithm metadata

This commit is contained in:
Matthias Kretschmann 2020-01-24 15:23:50 +01:00
parent c8ea5f77c2
commit 83ea6723e0
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 42 additions and 2 deletions

View File

@ -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)
})

View File

@ -46,6 +46,17 @@ const metadata: Partial<MetaData> = {
}
}
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

View File

@ -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
}
/**