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,
|
||||
algorithmDid?: string,
|
||||
algorithmMeta?: MetaData,
|
||||
jobId?: string
|
||||
jobId?: string,
|
||||
output?: Object
|
||||
): Promise<ComputeJob | ComputeJob[]> {
|
||||
const signature = await this.createSignature(consumerAccount, serviceAgreementId)
|
||||
const address = consumerAccount.getId()
|
||||
@ -138,6 +139,7 @@ export class Brizo extends Instantiable {
|
||||
url += `&serviceAgreementId=${noZeroX(serviceAgreementId)}`
|
||||
url += algorithmDid && `&algorithmDid=${algorithmDid}`
|
||||
url += algorithmMeta && `&algorithmMeta=${algorithmMeta}`
|
||||
url += output && `&output=${output}`
|
||||
url += jobId && `&jobId=${jobId}`
|
||||
|
||||
// switch fetch method
|
||||
|
@ -16,18 +16,6 @@ export enum ComputeJobStatus {
|
||||
Stopped,
|
||||
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 {
|
||||
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.
|
||||
* @param {Account} consumerAccount The account of the consumer ordering the service.
|
||||
* @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 {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
|
||||
*/
|
||||
public async start(
|
||||
consumerAccount: Account,
|
||||
agreementId: string,
|
||||
algorithmDid?: string,
|
||||
algorithmMeta?: MetaData
|
||||
algorithmMeta?: MetaData,
|
||||
output?:Object
|
||||
): Promise<ComputeJob> {
|
||||
output=await this.check_output_dict(consumerAccount,output)
|
||||
const status = await this.ocean.brizo.compute(
|
||||
'post',
|
||||
agreementId,
|
||||
consumerAccount,
|
||||
algorithmDid,
|
||||
algorithmMeta
|
||||
algorithmMeta,
|
||||
null,
|
||||
output
|
||||
)
|
||||
|
||||
return status as ComputeJob
|
||||
|
Loading…
Reference in New Issue
Block a user