mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
Merge pull request #387 from oceanprotocol/fix/compute-algo-meta
Fix compute when not using published algo
This commit is contained in:
commit
5d978feddd
@ -1,4 +1,4 @@
|
||||
import { File, MetaData } from '../ddo/MetaData'
|
||||
import { File, MetaDataAlgorithm } from '../ddo/MetaData'
|
||||
import Account from '../ocean/Account'
|
||||
import { noZeroX } from '../utils'
|
||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||
@ -115,7 +115,7 @@ export class Brizo extends Instantiable {
|
||||
serviceAgreementId: string,
|
||||
consumerAccount: Account,
|
||||
algorithmDid?: string,
|
||||
algorithmMeta?: MetaData,
|
||||
algorithmMeta?: MetaDataAlgorithm,
|
||||
jobId?: string,
|
||||
output?: Output
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
@ -138,7 +138,7 @@ export class Brizo extends Instantiable {
|
||||
url += `&consumerAddress=${address}`
|
||||
url += `&serviceAgreementId=${noZeroX(serviceAgreementId)}`
|
||||
url += (algorithmDid && `&algorithmDid=${algorithmDid}`) || ''
|
||||
url += (algorithmMeta && `&algorithmMeta=${algorithmMeta}`) || ''
|
||||
url += (algorithmMeta && `&algorithmMeta=${JSON.stringify(algorithmMeta)}`) || ''
|
||||
url += (output && `&output=${JSON.stringify(output)}`) || ''
|
||||
url += (jobId && `&jobId=${jobId}`) || ''
|
||||
|
||||
|
@ -64,6 +64,8 @@ export interface File {
|
||||
}
|
||||
|
||||
export interface MetaDataAlgorithm {
|
||||
url?: string
|
||||
rawcode?: string
|
||||
language?: string
|
||||
format?: string
|
||||
version?: string
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Instantiable, InstantiableConfig } from '../Instantiable.abstract'
|
||||
import { MetaData } from '../ddo/MetaData'
|
||||
import { MetaData, MetaDataAlgorithm } from '../ddo/MetaData'
|
||||
import Account from './Account'
|
||||
import { DDO } from '../ddo/DDO'
|
||||
import { SubscribablePromise } from '../utils'
|
||||
@ -132,7 +132,7 @@ export class OceanCompute extends Instantiable {
|
||||
consumerAccount: Account,
|
||||
agreementId: string,
|
||||
algorithmDid?: string,
|
||||
algorithmMeta?: MetaData,
|
||||
algorithmMeta?: MetaDataAlgorithm,
|
||||
output?: Output
|
||||
): Promise<ComputeJob> {
|
||||
output = this.checkOutput(consumerAccount, output)
|
||||
|
@ -1,7 +1,15 @@
|
||||
import { assert } from 'chai'
|
||||
|
||||
import { config } from '../config'
|
||||
import { Ocean, Account, DDO, MetaData, ComputeJobStatus, Config } from '../../../src'
|
||||
import {
|
||||
Ocean,
|
||||
Account,
|
||||
DDO,
|
||||
MetaData,
|
||||
ComputeJobStatus,
|
||||
Config,
|
||||
MetaDataAlgorithm
|
||||
} from '../../../src'
|
||||
import { getMetadata, createComputeService } from '../utils'
|
||||
import { ServiceCompute } from '../../../src/ddo/Service'
|
||||
|
||||
@ -88,9 +96,28 @@ describe('Compute', () => {
|
||||
} catch {}
|
||||
})
|
||||
|
||||
it('should start a compute job', async () => {
|
||||
it('should start a compute job with a published algo', async () => {
|
||||
const response = await ocean.compute.start(account, agreementId, algorithm.id)
|
||||
|
||||
assert.equal(response.status, ComputeJobStatus.Started)
|
||||
})
|
||||
|
||||
it('should start a compute job with a rawcode algo', async () => {
|
||||
const algoMeta: MetaDataAlgorithm = {
|
||||
rawcode: `console.log('Hello world!')`,
|
||||
container: {
|
||||
entrypoint: 'node $ALGO',
|
||||
image: 'node',
|
||||
tag: '10'
|
||||
}
|
||||
}
|
||||
const response = await ocean.compute.start(
|
||||
account,
|
||||
agreementId,
|
||||
undefined,
|
||||
algoMeta
|
||||
)
|
||||
|
||||
assert.equal(response.status, ComputeJobStatus.Started)
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user