1
0
mirror of https://github.com/oceanprotocol-archive/squid-js.git synced 2024-02-02 15:31:51 +01:00
This commit is contained in:
alexcos20 2020-02-01 15:42:02 +02:00
parent eb73d6604c
commit 6e2289b27d
2 changed files with 28 additions and 29 deletions

View File

@ -117,7 +117,7 @@ export class Brizo extends Instantiable {
algorithmDid?: string, algorithmDid?: string,
algorithmMeta?: MetaData, algorithmMeta?: MetaData,
jobId?: string, jobId?: string,
output?: Object output?: Record<string, any>
): 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()

View File

@ -78,43 +78,42 @@ export class OceanCompute extends Instantiable {
* return minimal output object * return minimal output object
* @return {Promise<Object>} Returns output object * @return {Promise<Object>} Returns output object
*/ */
public async minimal_output_object():Promise<Object> { public async getminimaloutput(): Promise<Record<string, any>> {
var minimal_output=Object() const minimaloutput = Object()
minimal_output["publishAlgorithmLog"]=false minimaloutput.publishAlgorithmLog = false
minimal_output["publishOutput"]=false minimaloutput.publishOutput = false
return minimal_output return minimaloutput
} }
/** /**
* Check the output object and add default properties if needed * Check the output object and add default properties if needed
* @param {Account} consumerAccount The account of the consumer ordering the service. * @param {Account} consumerAccount The account of the consumer ordering the service.
* @param {Object} output Output section used for publishing the result. * @param {Object} output Output section used for publishing the result.
* @return {Promise<Object>} Returns output object * @return {Promise<Object>} Returns output object
*/ */
public async check_output_dict( public async checkoutput(
consumerAccount: Account, consumerAccount: Account,
output?:Object output?: Record<string, any>
): Promise<Object> { ): Promise<Record<string, any>> {
if (!output) { if (!output) {
// build a minimal object and return it // build a minimal object and return it
return (await this.minimal_output_object()) return this.getminimaloutput()
} }
if((!output["publishAlgorithmLog"] || output["publishAlgorithmLog"]==false) && (!output["publishOutput"] || output["publishOutput"]==false)){ if (
return (await this.minimal_output_object()) (!output.publishAlgorithmLog || output.publishAlgorithmLog === false) &&
(!output.publishOutput || output.publishOutput === false)
) {
return this.getminimaloutput()
} }
if(!output["brizoAddress"]) if (!output.brizoAddress) output.brizoAddress = this.config.brizoAddress
output["brizoAddress"]=this.config.brizoAddress if (!output.brizoUrl) output.brizoUrl = this.config.brizoUri
if(!output["brizoUrl"]) if (!output.metadataUrl) output.metadataUrl = this.config.aquariusUri
output["brizoUrl"]=this.config.brizoUri if (!output.nodeUri) output.nodeUri = this.config.nodeUri
if(!output["metadataUrl"]) if (!output.owner) output.owner = consumerAccount.getId()
output["metadataUrl"]=this.config.aquariusUri if (!output.secretStoreUrl) output.secretStoreUrl = this.config.secretStoreUri
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 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.
@ -129,9 +128,9 @@ export class OceanCompute extends Instantiable {
agreementId: string, agreementId: string,
algorithmDid?: string, algorithmDid?: string,
algorithmMeta?: MetaData, algorithmMeta?: MetaData,
output?:Object output?: Record<string, any>
): Promise<ComputeJob> { ): Promise<ComputeJob> {
output=await this.check_output_dict(consumerAccount,output) output = await this.checkoutput(consumerAccount, output)
const status = await this.ocean.brizo.compute( const status = await this.ocean.brizo.compute(
'post', 'post',
agreementId, agreementId,