mirror of
https://github.com/oceanprotocol/ocean.js.git
synced 2024-11-26 20:39:05 +01:00
Merge branch 'feature/compute-interface' into feature/compute-test
This commit is contained in:
commit
27168cc64d
@ -9,6 +9,7 @@ import {
|
|||||||
ServiceCommon,
|
ServiceCommon,
|
||||||
ServiceCompute
|
ServiceCompute
|
||||||
} from '../ddo/interfaces/Service'
|
} from '../ddo/interfaces/Service'
|
||||||
|
|
||||||
import { EditableMetadata } from '../ddo/interfaces/EditableMetadata'
|
import { EditableMetadata } from '../ddo/interfaces/EditableMetadata'
|
||||||
import Account from './Account'
|
import Account from './Account'
|
||||||
import DID from './DID'
|
import DID from './DID'
|
||||||
|
@ -117,6 +117,47 @@ export class Compute extends Instantiable {
|
|||||||
return computeJobsList[0] as ComputeJob
|
return computeJobsList[0] as ComputeJob
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a compute job and all resources associated with the job. If job is running it will be stopped first.
|
||||||
|
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||||
|
* @param {string} did Decentralized identifier.
|
||||||
|
* @param {string} jobId The ID of the compute job to be stopped
|
||||||
|
* @return {Promise<ComputeJob>} Returns the new status of a job
|
||||||
|
*/
|
||||||
|
public async delete(
|
||||||
|
consumerAccount: Account,
|
||||||
|
did: string,
|
||||||
|
jobId: string
|
||||||
|
): Promise<ComputeJob> {
|
||||||
|
const computeJobsList = await this.ocean.provider.compute(
|
||||||
|
'delete',
|
||||||
|
did,
|
||||||
|
consumerAccount,
|
||||||
|
undefined,
|
||||||
|
undefined,
|
||||||
|
jobId
|
||||||
|
)
|
||||||
|
|
||||||
|
return computeJobsList[0] as ComputeJob
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ends a running compute job and starts it again.
|
||||||
|
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||||
|
* @param {string} did Decentralized identifier.
|
||||||
|
* @param {string} jobId The ID of the compute job to be stopped
|
||||||
|
* @return {Promise<ComputeJob>} Returns the new status of a job
|
||||||
|
*/
|
||||||
|
public async restart(
|
||||||
|
consumerAccount: Account,
|
||||||
|
did: string,
|
||||||
|
jobId: string
|
||||||
|
): Promise<ComputeJob> {
|
||||||
|
await this.stop(consumerAccount, did, jobId)
|
||||||
|
const result = await this.start(consumerAccount, did, jobId)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about the status of all compute jobs, or a single compute job.
|
* Returns information about the status of all compute jobs, or a single compute job.
|
||||||
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||||
@ -227,7 +268,6 @@ export class Compute extends Instantiable {
|
|||||||
): ServiceCompute {
|
): ServiceCompute {
|
||||||
const name = 'dataAssetComputingService'
|
const name = 'dataAssetComputingService'
|
||||||
if (!timeout) timeout = 3600
|
if (!timeout) timeout = 3600
|
||||||
|
|
||||||
const service = {
|
const service = {
|
||||||
type: 'compute',
|
type: 'compute',
|
||||||
index: 3,
|
index: 3,
|
||||||
@ -246,7 +286,6 @@ export class Compute extends Instantiable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (computePrivacy) service.attributes.main.privacy = computePrivacy
|
if (computePrivacy) service.attributes.main.privacy = computePrivacy
|
||||||
|
|
||||||
return service as ServiceCompute
|
return service as ServiceCompute
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user