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

Return proper value from the compute endpoints.

This commit is contained in:
ssallam 2020-03-05 15:28:55 +01:00
parent 75a0ef05d9
commit e2ed974af2
2 changed files with 30 additions and 26 deletions

View File

@ -134,13 +134,13 @@ export class Brizo extends Instantiable {
// construct Brizo URL // construct Brizo URL
let url = serviceEndpoint let url = serviceEndpoint
url += `&signature=${signature}` url += `?signature=${signature}`
url += `&consumerAddress=${address}` url += `&consumerAddress=${address}`
url += `&serviceAgreementId=${noZeroX(serviceAgreementId)}` url += `&serviceAgreementId=${noZeroX(serviceAgreementId)}`
url += algorithmDid && `&algorithmDid=${algorithmDid}` url += algorithmDid && `&algorithmDid=${algorithmDid}` || ''
url += algorithmMeta && `&algorithmMeta=${algorithmMeta}` url += algorithmMeta && `&algorithmMeta=${algorithmMeta}` || ''
url += output && `&output=${output}` url += output && `&output=${JSON.stringify(output)}` || ''
url += jobId && `&jobId=${jobId}` url += jobId && `&jobId=${jobId}` || ''
// switch fetch method // switch fetch method
let fetch let fetch

View File

@ -6,16 +6,20 @@ import { SubscribablePromise } from '../utils'
import { OrderProgressStep } from './utils/ServiceUtils' import { OrderProgressStep } from './utils/ServiceUtils'
import { DID } from '../squid' import { DID } from '../squid'
export enum ComputeJobStatus {
Started, export const ComputeJobStatus = Object.freeze({
ConfiguringVolumes, Started: 10,
RunningAlgorithm, ConfiguringVolumes: 20,
FilteringResults, ProvisioningSuccess: 30,
PublishingResult, DataProvisioningFailed: 31,
Completed, AlgorithmProvisioningFailed: 32,
Stopped, RunningAlgorithm: 40,
Deleted FilteringResults: 50,
} PublishingResult: 60,
Completed: 70,
Stopped: 80,
Deleted: 90
})
export interface Output { export interface Output {
publishAlgorithmLog?: boolean publishAlgorithmLog?: boolean
@ -36,7 +40,7 @@ export interface ComputeJob {
jobId: string jobId: string
dateCreated: string dateCreated: string
dateFinished: string dateFinished: string
status: ComputeJobStatus status: number
statusText: string statusText: string
algorithmLogUrl: string algorithmLogUrl: string
resultsUrls: string[] resultsUrls: string[]
@ -133,7 +137,7 @@ export class OceanCompute extends Instantiable {
output?: Output output?: Output
): Promise<ComputeJob> { ): Promise<ComputeJob> {
output = this.checkOutput(consumerAccount, output) output = this.checkOutput(consumerAccount, output)
const status = await this.ocean.brizo.compute( const computeJobsList = await this.ocean.brizo.compute(
'post', 'post',
agreementId, agreementId,
consumerAccount, consumerAccount,
@ -143,7 +147,7 @@ export class OceanCompute extends Instantiable {
output output
) )
return status as ComputeJob return computeJobsList[0] as ComputeJob
} }
/** /**
@ -158,7 +162,7 @@ export class OceanCompute extends Instantiable {
agreementId: string, agreementId: string,
jobId: string jobId: string
): Promise<ComputeJob> { ): Promise<ComputeJob> {
const status = await this.ocean.brizo.compute( const computeJobsList = await this.ocean.brizo.compute(
'put', 'put',
agreementId, agreementId,
consumerAccount, consumerAccount,
@ -167,7 +171,7 @@ export class OceanCompute extends Instantiable {
jobId jobId
) )
return status as ComputeJob return computeJobsList[0] as ComputeJob
} }
/** /**
@ -182,7 +186,7 @@ export class OceanCompute extends Instantiable {
agreementId: string, agreementId: string,
jobId: string jobId: string
): Promise<ComputeJob> { ): Promise<ComputeJob> {
const status = await this.ocean.brizo.compute( const computeJobsList = await this.ocean.brizo.compute(
'delete', 'delete',
agreementId, agreementId,
consumerAccount, consumerAccount,
@ -191,7 +195,7 @@ export class OceanCompute extends Instantiable {
jobId jobId
) )
return status as ComputeJob return computeJobsList[0] as ComputeJob
} }
/** /**
@ -223,7 +227,7 @@ export class OceanCompute extends Instantiable {
agreementId?: string, agreementId?: string,
jobId?: string jobId?: string
): Promise<ComputeJob[]> { ): Promise<ComputeJob[]> {
const status = await this.ocean.brizo.compute( const computeJobsList = await this.ocean.brizo.compute(
'get', 'get',
agreementId, agreementId,
consumerAccount, consumerAccount,
@ -232,7 +236,7 @@ export class OceanCompute extends Instantiable {
jobId jobId
) )
return status as ComputeJob[] return computeJobsList as ComputeJob[]
} }
/** /**
@ -247,7 +251,7 @@ export class OceanCompute extends Instantiable {
agreementId: string, agreementId: string,
jobId: string jobId: string
): Promise<ComputeJob> { ): Promise<ComputeJob> {
const status = await this.ocean.brizo.compute( const computeJobsList = await this.ocean.brizo.compute(
'get', 'get',
agreementId, agreementId,
consumerAccount, consumerAccount,
@ -256,6 +260,6 @@ export class OceanCompute extends Instantiable {
jobId jobId
) )
return status as ComputeJob return computeJobsList[0] as ComputeJob
} }
} }