diff --git a/src/brizo/Brizo.ts b/src/brizo/Brizo.ts index 77aa4cb..083cfd8 100644 --- a/src/brizo/Brizo.ts +++ b/src/brizo/Brizo.ts @@ -134,13 +134,13 @@ export class Brizo extends Instantiable { // construct Brizo URL let url = serviceEndpoint - url += `&signature=${signature}` + url += `?signature=${signature}` url += `&consumerAddress=${address}` url += `&serviceAgreementId=${noZeroX(serviceAgreementId)}` - url += algorithmDid && `&algorithmDid=${algorithmDid}` - url += algorithmMeta && `&algorithmMeta=${algorithmMeta}` - url += output && `&output=${output}` - url += jobId && `&jobId=${jobId}` + url += algorithmDid && `&algorithmDid=${algorithmDid}` || '' + url += algorithmMeta && `&algorithmMeta=${algorithmMeta}` || '' + url += output && `&output=${JSON.stringify(output)}` || '' + url += jobId && `&jobId=${jobId}` || '' // switch fetch method let fetch diff --git a/src/ocean/OceanCompute.ts b/src/ocean/OceanCompute.ts index 8782dbd..921fb77 100644 --- a/src/ocean/OceanCompute.ts +++ b/src/ocean/OceanCompute.ts @@ -6,16 +6,20 @@ import { SubscribablePromise } from '../utils' import { OrderProgressStep } from './utils/ServiceUtils' import { DID } from '../squid' -export enum ComputeJobStatus { - Started, - ConfiguringVolumes, - RunningAlgorithm, - FilteringResults, - PublishingResult, - Completed, - Stopped, - Deleted -} + +export const ComputeJobStatus = Object.freeze({ + Started: 10, + ConfiguringVolumes: 20, + ProvisioningSuccess: 30, + DataProvisioningFailed: 31, + AlgorithmProvisioningFailed: 32, + RunningAlgorithm: 40, + FilteringResults: 50, + PublishingResult: 60, + Completed: 70, + Stopped: 80, + Deleted: 90 +}) export interface Output { publishAlgorithmLog?: boolean @@ -36,7 +40,7 @@ export interface ComputeJob { jobId: string dateCreated: string dateFinished: string - status: ComputeJobStatus + status: number statusText: string algorithmLogUrl: string resultsUrls: string[] @@ -133,7 +137,7 @@ export class OceanCompute extends Instantiable { output?: Output ): Promise { output = this.checkOutput(consumerAccount, output) - const status = await this.ocean.brizo.compute( + const computeJobsList = await this.ocean.brizo.compute( 'post', agreementId, consumerAccount, @@ -143,7 +147,7 @@ export class OceanCompute extends Instantiable { output ) - return status as ComputeJob + return computeJobsList[0] as ComputeJob } /** @@ -158,7 +162,7 @@ export class OceanCompute extends Instantiable { agreementId: string, jobId: string ): Promise { - const status = await this.ocean.brizo.compute( + const computeJobsList = await this.ocean.brizo.compute( 'put', agreementId, consumerAccount, @@ -167,7 +171,7 @@ export class OceanCompute extends Instantiable { jobId ) - return status as ComputeJob + return computeJobsList[0] as ComputeJob } /** @@ -182,7 +186,7 @@ export class OceanCompute extends Instantiable { agreementId: string, jobId: string ): Promise { - const status = await this.ocean.brizo.compute( + const computeJobsList = await this.ocean.brizo.compute( 'delete', agreementId, consumerAccount, @@ -191,7 +195,7 @@ export class OceanCompute extends Instantiable { jobId ) - return status as ComputeJob + return computeJobsList[0] as ComputeJob } /** @@ -223,7 +227,7 @@ export class OceanCompute extends Instantiable { agreementId?: string, jobId?: string ): Promise { - const status = await this.ocean.brizo.compute( + const computeJobsList = await this.ocean.brizo.compute( 'get', agreementId, consumerAccount, @@ -232,7 +236,7 @@ export class OceanCompute extends Instantiable { jobId ) - return status as ComputeJob[] + return computeJobsList as ComputeJob[] } /** @@ -247,7 +251,7 @@ export class OceanCompute extends Instantiable { agreementId: string, jobId: string ): Promise { - const status = await this.ocean.brizo.compute( + const computeJobsList = await this.ocean.brizo.compute( 'get', agreementId, consumerAccount, @@ -256,6 +260,6 @@ export class OceanCompute extends Instantiable { jobId ) - return status as ComputeJob + return computeJobsList[0] as ComputeJob } }