1
0
mirror of https://github.com/oceanprotocol/ocean.js.git synced 2024-11-26 20:39:05 +01:00

Merge 0abb44852f3724a9a93d9cf90f92a05f518c7bf7 into a00211e8d8dbeeacc3b44b934f48e8d25bf36245

This commit is contained in:
paulo@oceanprotocol 2024-06-25 11:42:51 +03:00 committed by GitHub
commit 713780d46e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 21 additions and 12 deletions

View File

@ -274,6 +274,7 @@ let resolvedDatasetDdo: DDO
let resolvedAlgorithmDdo: DDO let resolvedAlgorithmDdo: DDO
let computeJobId: string let computeJobId: string
let agreementId: string
``` ```
### 4.3 Helper methods ### 4.3 Helper methods
@ -654,13 +655,18 @@ Let's have 5 minute of compute access
algo algo
) )
console.log('COMPUTE JOBS', computeJobs)
``` ```
<!-- <!--
assert(computeJobs, 'Cannot start compute job') assert(computeJobs, 'Cannot start compute job')
--> -->
Let's save the compute job it, we re going to use later Let's save the compute job id, we re going to use later
We can also save the agreementId. Its another optional field that we can later use to retrieve the job status
```Typescript ```Typescript
computeJobId = computeJobs[0].jobId computeJobId = computeJobs[0].jobId
// eslint-disable-next-line prefer-destructuring
agreementId = computeJobs[0].agreementId
``` ```
@ -672,7 +678,7 @@ You can also add various delays so you see the various states of the compute job
providerUrl, providerUrl,
await consumerAccount.getAddress(), await consumerAccount.getAddress(),
computeJobId, computeJobId,
DATASET_DDO.id agreementId
) )
``` ```
<!-- <!--

View File

@ -128,9 +128,9 @@ ___
### computeStatus ### computeStatus
**computeStatus**(`providerUri`, `consumerAddress`, `jobId?`, `did?`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\> **computeStatus**(`providerUri`, `consumerAddress`, `jobId?`, `agreementId?`, `signal?`): `Promise`<[`ComputeJob`](../interfaces/ComputeJob.md) \| [`ComputeJob`](../interfaces/ComputeJob.md)[]\>
Get compute status for a specific jobId/documentId/owner. Get compute status for a specific jobId/agreementId/owner.
#### Parameters #### Parameters
@ -139,7 +139,7 @@ Get compute status for a specific jobId/documentId/owner.
| `providerUri` | `string` | The URI of the provider we want to query | | `providerUri` | `string` | The URI of the provider we want to query |
| `consumerAddress` | `string` | The consumer ethereum address | | `consumerAddress` | `string` | The consumer ethereum address |
| `jobId?` | `string` | The ID of a compute job. | | `jobId?` | `string` | The ID of a compute job. |
| `did?` | `string` | The ID of the asset | | `agreementId?` | `string` | The ID of service agreement |
| `signal?` | `AbortSignal` | abort signal | | `signal?` | `AbortSignal` | abort signal |
#### Returns #### Returns

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "@oceanprotocol/lib", "name": "@oceanprotocol/lib",
"version": "3.3.1", "version": "3.3.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@oceanprotocol/lib", "name": "@oceanprotocol/lib",
"version": "3.3.1", "version": "3.3.2",
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@oceanprotocol/contracts": "^2.0.3", "@oceanprotocol/contracts": "^2.0.3",

View File

@ -1,7 +1,7 @@
{ {
"name": "@oceanprotocol/lib", "name": "@oceanprotocol/lib",
"source": "./src/index.ts", "source": "./src/index.ts",
"version": "3.3.1", "version": "3.3.2",
"description": "JavaScript client library for Ocean Protocol", "description": "JavaScript client library for Ocean Protocol",
"main": "./dist/lib.js", "main": "./dist/lib.js",
"umd:main": "dist/lib.umd.js", "umd:main": "dist/lib.umd.js",

View File

@ -688,7 +688,7 @@ export class Provider {
* @param {string} providerUri The URI of the provider we want to query * @param {string} providerUri The URI of the provider we want to query
* @param {string} consumerAddress The consumer ethereum address * @param {string} consumerAddress The consumer ethereum address
* @param {string} jobId The ID of a compute job. * @param {string} jobId The ID of a compute job.
* @param {string} did The ID of the asset * @param {string} agreementId The ID of the service agreement (tx id)
* @param {AbortSignal} signal abort signal * @param {AbortSignal} signal abort signal
* @return {Promise<ComputeJob | ComputeJob[]>} * @return {Promise<ComputeJob | ComputeJob[]>}
*/ */
@ -696,7 +696,7 @@ export class Provider {
providerUri: string, providerUri: string,
consumerAddress: string, consumerAddress: string,
jobId?: string, jobId?: string,
did?: string, agreementId?: string,
signal?: AbortSignal signal?: AbortSignal
): Promise<ComputeJob | ComputeJob[]> { ): Promise<ComputeJob | ComputeJob[]> {
const providerEndpoints = await this.getEndpoints(providerUri) const providerEndpoints = await this.getEndpoints(providerUri)
@ -709,7 +709,7 @@ export class Provider {
: null : null
let url = `?consumerAddress=${consumerAddress}` let url = `?consumerAddress=${consumerAddress}`
url += (did && `&documentId=${this.noZeroX(did)}`) || '' url += (agreementId && `&agreementId=${this.noZeroX(agreementId)}`) || ''
url += (jobId && `&jobId=${jobId}`) || '' url += (jobId && `&jobId=${jobId}`) || ''
if (!computeStatusUrl) return null if (!computeStatusUrl) return null

View File

@ -274,6 +274,7 @@ let resolvedDatasetDdo: DDO
let resolvedAlgorithmDdo: DDO let resolvedAlgorithmDdo: DDO
let computeJobId: string let computeJobId: string
let agreementId: string
/// ``` /// ```
/// ### 4.3 Helper methods /// ### 4.3 Helper methods
@ -661,6 +662,8 @@ describe('Compute-to-data example tests', async () => {
/// Let's save the compute job it, we re going to use later /// Let's save the compute job it, we re going to use later
/// ```Typescript /// ```Typescript
computeJobId = computeJobs[0].jobId computeJobId = computeJobs[0].jobId
// eslint-disable-next-line prefer-destructuring
agreementId = computeJobs[0].agreementId
}) /// }) ///
/// ``` /// ```
@ -672,7 +675,7 @@ describe('Compute-to-data example tests', async () => {
providerUrl, providerUrl,
await consumerAccount.getAddress(), await consumerAccount.getAddress(),
computeJobId, computeJobId,
DATASET_DDO.id agreementId
) )
/// ``` /// ```
/// <!-- /// <!--