mirror of
https://github.com/oceanprotocol-archive/squid-js.git
synced 2024-02-02 15:31:51 +01:00
add Output Object passed to brizo
This commit is contained in:
parent
fa09f6f2c7
commit
a60e415925
@ -116,7 +116,8 @@ export class Brizo extends Instantiable {
|
|||||||
consumerAccount: Account,
|
consumerAccount: Account,
|
||||||
algorithmDid?: string,
|
algorithmDid?: string,
|
||||||
algorithmMeta?: MetaData,
|
algorithmMeta?: MetaData,
|
||||||
jobId?: string
|
jobId?: string,
|
||||||
|
output?: Object
|
||||||
): Promise<ComputeJob | ComputeJob[]> {
|
): Promise<ComputeJob | ComputeJob[]> {
|
||||||
const signature = await this.createSignature(consumerAccount, serviceAgreementId)
|
const signature = await this.createSignature(consumerAccount, serviceAgreementId)
|
||||||
const address = consumerAccount.getId()
|
const address = consumerAccount.getId()
|
||||||
@ -138,6 +139,7 @@ export class Brizo extends Instantiable {
|
|||||||
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 += jobId && `&jobId=${jobId}`
|
url += jobId && `&jobId=${jobId}`
|
||||||
|
|
||||||
// switch fetch method
|
// switch fetch method
|
||||||
|
@ -16,18 +16,6 @@ export enum ComputeJobStatus {
|
|||||||
Stopped,
|
Stopped,
|
||||||
Deleted
|
Deleted
|
||||||
}
|
}
|
||||||
export interface Output {
|
|
||||||
publishAlgorithmLog?: boolean
|
|
||||||
publishOutput?: boolean
|
|
||||||
brizoAddress?: string
|
|
||||||
brizoUrl?: string
|
|
||||||
metadata?: Object
|
|
||||||
metadataUrl?: string
|
|
||||||
nodeUri?: string
|
|
||||||
owner?: string
|
|
||||||
secretStoreUrl?: string
|
|
||||||
whitelist?: Array
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ComputeJob {
|
export interface ComputeJob {
|
||||||
owner: string
|
owner: string
|
||||||
@ -86,26 +74,72 @@ export class OceanCompute extends Instantiable {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return minimal output object
|
||||||
|
* @return {Promise<Object>} Returns output object
|
||||||
|
*/
|
||||||
|
public async minimal_output_object():Promise<Object> {
|
||||||
|
var minimal_output=Object()
|
||||||
|
minimal_output["publishAlgorithmLog"]=false
|
||||||
|
minimal_output["publishOutput"]=false
|
||||||
|
return(minimal_output)
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check the output object and add default properties if needed
|
||||||
|
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||||
|
* @param {Object} output Output section used for publishing the result.
|
||||||
|
* @return {Promise<Object>} Returns output object
|
||||||
|
*/
|
||||||
|
public async check_output_dict(
|
||||||
|
consumerAccount:Account,
|
||||||
|
output?:Object
|
||||||
|
): Promise<Object> {
|
||||||
|
if (!output){
|
||||||
|
//build a minimal object and return it
|
||||||
|
return (await this.minimal_output_object())
|
||||||
|
}
|
||||||
|
if((!output["publishAlgorithmLog"] || output["publishAlgorithmLog"]==false) && (!output["publishOutput"] || output["publishOutput"]==false)){
|
||||||
|
return (await this.minimal_output_object())
|
||||||
|
}
|
||||||
|
if(!output["brizoAddress"])
|
||||||
|
output["brizoAddress"]=this.config.brizoAddress
|
||||||
|
if(!output["brizoUrl"])
|
||||||
|
output["brizoUrl"]=this.config.brizoUri
|
||||||
|
if(!output["metadataUrl"])
|
||||||
|
output["metadataUrl"]=this.config.aquariusUri
|
||||||
|
if(!output["nodeUri"])
|
||||||
|
output["nodeUri"]=this.config.nodeUri
|
||||||
|
if(!output["owner"])
|
||||||
|
output["owner"]=consumerAccount.getId()
|
||||||
|
if(!output["secretStoreUrl"])
|
||||||
|
output["secretStoreUrl"]=this.config.secretStoreUri
|
||||||
|
return output
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Start the execution of a compute job.
|
* Start the execution of a compute job.
|
||||||
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||||
* @param {string} agreementId The service agreement ID.
|
* @param {string} agreementId The service agreement ID.
|
||||||
* @param {string} algorithmDid The DID of the algorithm asset (of type `algorithm`) to run on the asset.
|
* @param {string} algorithmDid The DID of the algorithm asset (of type `algorithm`) to run on the asset.
|
||||||
* @param {MetaData} algorithmMeta Metadata about the algorithm being run if `algorithm` is being used. This is ignored when `algorithmDid` is specified.
|
* @param {MetaData} algorithmMeta Metadata about the algorithm being run if `algorithm` is being used. This is ignored when `algorithmDid` is specified.
|
||||||
|
* @param {Object} output Output section used for publishing the result.
|
||||||
* @return {Promise<ComputeJob>} Returns compute job ID under status.jobId
|
* @return {Promise<ComputeJob>} Returns compute job ID under status.jobId
|
||||||
*/
|
*/
|
||||||
public async start(
|
public async start(
|
||||||
consumerAccount: Account,
|
consumerAccount: Account,
|
||||||
agreementId: string,
|
agreementId: string,
|
||||||
algorithmDid?: string,
|
algorithmDid?: string,
|
||||||
algorithmMeta?: MetaData
|
algorithmMeta?: MetaData,
|
||||||
|
output?:Object
|
||||||
): Promise<ComputeJob> {
|
): Promise<ComputeJob> {
|
||||||
|
output=await this.check_output_dict(consumerAccount,output)
|
||||||
const status = await this.ocean.brizo.compute(
|
const status = await this.ocean.brizo.compute(
|
||||||
'post',
|
'post',
|
||||||
agreementId,
|
agreementId,
|
||||||
consumerAccount,
|
consumerAccount,
|
||||||
algorithmDid,
|
algorithmDid,
|
||||||
algorithmMeta
|
algorithmMeta,
|
||||||
|
null,
|
||||||
|
output
|
||||||
)
|
)
|
||||||
|
|
||||||
return status as ComputeJob
|
return status as ComputeJob
|
||||||
|
Loading…
Reference in New Issue
Block a user