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:
parent
c8ea5f77c2
commit
83ea6723e0
@ -3,6 +3,7 @@ import { assert } from 'chai'
|
|||||||
import { config } from '../config'
|
import { config } from '../config'
|
||||||
import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid
|
import { Ocean, Account, DDO, MetaData } from '../../src' // @oceanprotocol/squid
|
||||||
import { getMetadata } from '../utils'
|
import { getMetadata } from '../utils'
|
||||||
|
import { ServiceType } from '../../src/ddo/Service'
|
||||||
|
|
||||||
describe('Compute', () => {
|
describe('Compute', () => {
|
||||||
let ocean: Ocean
|
let ocean: Ocean
|
||||||
@ -12,11 +13,24 @@ describe('Compute', () => {
|
|||||||
|
|
||||||
const metadataAsset = getMetadata()
|
const metadataAsset = getMetadata()
|
||||||
const metadataAlgorithm = getMetadata(0, 'algorithm')
|
const metadataAlgorithm = getMetadata(0, 'algorithm')
|
||||||
|
const assetComputeService = {
|
||||||
|
type: 'compute' as ServiceType,
|
||||||
|
index: 2,
|
||||||
|
attributes: {
|
||||||
|
main: {
|
||||||
|
serviceAgreementTemplate: {
|
||||||
|
contractName: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ocean = await Ocean.getInstance(config)
|
ocean = await Ocean.getInstance(config)
|
||||||
;[account] = await ocean.accounts.list()
|
;[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)
|
ddoAlgorithm = await ocean.assets.create(metadataAlgorithm as MetaData, account)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -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 = (
|
export const generateMetadata = (
|
||||||
name: string,
|
name: string,
|
||||||
type?: 'dataset' | 'algorithm',
|
type?: 'dataset' | 'algorithm',
|
||||||
@ -56,7 +67,8 @@ export const generateMetadata = (
|
|||||||
...metadata.main,
|
...metadata.main,
|
||||||
name,
|
name,
|
||||||
type: type || 'dataset',
|
type: type || 'dataset',
|
||||||
price: (price || 21) + '0'.repeat(18)
|
price: (price || 21) + '0'.repeat(18),
|
||||||
|
algorithm: type === 'algorithm' && algorithmMeta
|
||||||
},
|
},
|
||||||
additionalInformation: {
|
additionalInformation: {
|
||||||
...metadata.additionalInformation
|
...metadata.additionalInformation
|
||||||
|
@ -84,6 +84,18 @@ export interface File {
|
|||||||
compression?: string
|
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.
|
* Main attributes of assets metadata.
|
||||||
* @see https://github.com/oceanprotocol/OEPs/tree/master/8
|
* @see https://github.com/oceanprotocol/OEPs/tree/master/8
|
||||||
@ -151,6 +163,8 @@ export interface MetaDataMain {
|
|||||||
encryptedService?: any
|
encryptedService?: any
|
||||||
|
|
||||||
service?: Service
|
service?: Service
|
||||||
|
|
||||||
|
algorithm?: Algorithm
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user