Skip to content

Commit b41aadf

Browse files
authored
Feature/paid-compute in cli (#115)
* Create initializeCompute command and refator computeStart command. * Fix config and imports from ocean.js in the commands. * Added checks for escrow and porvider fees in compute start command. * Make exports work. * Fix await. * Fix asset and ddo types. * Update publish script. * Update workflow to not use old c2d. * Added tests for compute environments and fix ci. * Fix branch for node. * Correct ci. * Print ocean node logs. * Fix import. * Added test for initialize and get compute envs. * Rename tests suit. * Add test for start compute. * Changed publish approach command. * Print ocean node logs in ci. * Update examples with indexedMetadata. * Replace with runCommand. * Increased timeout. * Debug logs for compute dataset. * Fix retrieval for did. * Remove eval. * Debug getDDO command. * Updated test. * Updated test. * debug. * Trim response from get compute envs response. * Added validation for fields in initialize command and start compute. Fixed tests parsing. * Update setup and cli. * Fix condition. * Fix resources. * Modified config and updated test. * Add logs in initialize. * Refactor condition. * Fix stringified resources. * Update import. * Fix envs. * Debug command initialize. * Modified test. * stringify in program command. * Refactor parsing of initialize response. * Added missing parameter from startCompute. * Added one dash. * Fix envs reponse + missing parameters from command. * modified commands. * Cleanup. * debug start compute command. * Fix name for amountToDeposit. * Fix import between the test. * Created util for tests. * remove duplicate argument. * debug parsing initialize response. * Fix all tests, refactor code for startCompute. Added tests for compute status and get job results. * Fix import. * Cleanup + fix ci. * Make agreement ID optional back. * Update ocean.js * Make amount to deposit optional. * Incorporate initializeCommand in startCompute. * Updated logic for startCompute command. * Fix condition. Updated test. * Fix amount. * Fix print and lint. * Fix option. * Fix test. * Fix test. * Fix setup test. * Fix README.
1 parent 43d9068 commit b41aadf

19 files changed

Lines changed: 1226 additions & 505 deletions

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ jobs:
121121
sleep 10
122122
attempt=$((attempt + 1))
123123
done
124+
124125
- name: docker logs
125-
run: docker logs ocean-ocean-contracts-1 && docker logs ocean-ganache-1 && docker logs ocean-typesense-1
126+
run: docker logs ocean_ocean-contracts_1 && docker logs ocean_typesense_1
126127
if: ${{ failure() }}
127128

128129
- name: Run system tests
@@ -131,4 +132,9 @@ jobs:
131132
INDEXING_RETRY_INTERVAL: 4000
132133
INDEXING_MAX_RETRIES: 120
133134
NODE_URL: 'http://127.0.0.1:8001'
134-
AVOID_LOOP_RUN: true
135+
AVOID_LOOP_RUN: true
136+
- name: Print Ocean Node Logs if tests fail
137+
if: ${{ failure() }}
138+
run: |
139+
echo "========== Ocean Node Logs =========="
140+
tac ${{ github.workspace }}/ocean-node/ocean-node.log || echo "Log file not found"

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,19 @@ npm run cli <command> [options] <arguments>
194194
**Start Compute:**
195195

196196
- **Positional:**
197-
`npm run cli startCompute did1,did2 algoDid env1`
197+
`npm run cli startCompute -- did1,did2 algoDid env1 maxJobDuration paymentToken resources --accept true`
198198

199199
- **Named Options:**
200-
`npm run cli startCompute --datasets did1,did2 --algo algoDid --env env1`
200+
`npm run cli startCompute --datasets did1,did2 --algo algoDid --env env1 --maxJobDuration maxJobDuration --token paymentToken --resources resources --accept true`
201201
(Options can be provided in any order.)
202202

203+
204+
- `maxJobDuration` is a required parameter an represents the time measured in seconds for job maximum execution, the payment is based on this maxJobDuration value, user needs to provide this.
205+
- `paymentToken` is required and represents the address of the token that is supported by the environment for processing the compute job payment. It can be retrieved from `getComputeEnvironments` command output.
206+
- `resources` is required and represents a stringified JSON object obtained from `getComputeEnvironments` command output. `getComputeEnvironments` command shows the available resources and the selected resources by the user need to be within the available limits.
207+
e.g.: `'[{"id":"cpu","amount":3},{"id":"ram","amount":16772672536},{"id":"disk","amount":0}]'`
208+
- `--accept` option can be set to `true` or `false`. If it is set to `false` a prompt will be displayed to the user for manual accepting the payment before starting a compute job. If it is set to `true`, the compute job starts automatically, without user input.
209+
203210
---
204211

205212
**Start Free Compute:**
@@ -291,6 +298,11 @@ npm run cli <command> [options] <arguments>
291298
`-d, --datasets <datasetDids>`
292299
`-a, --algo <algoDid>`
293300
`-e, --env <computeEnvId>`
301+
`--init <initializeResponse>`
302+
`--maxJobDuration <maxJobDuration>`
303+
`-t, --token <paymentToken>`
304+
`--resources <resources>`
305+
`--amountToDeposit <amountToDeposit>` (Id `''`, it will fallback to initialize compute payment amount.)
294306

295307
- **startFreeCompute:**
296308
`-d, --datasets <datasetDids>`

metadata/downloadAssetPaymentUSDC.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,32 +41,32 @@
4141
"timeout": 86400
4242
}
4343
],
44-
"event": {
45-
},
46-
"nft": {
47-
"address": "",
48-
"name": "Ocean Data NFT",
49-
"symbol": "OCEAN-NFT",
50-
"state": 5,
51-
"tokenURI": "",
52-
"owner": "",
53-
"created": ""
54-
},
55-
"purgatory": {
56-
"state": false
44+
"indexedMetadata": {
45+
"event": {},
46+
"nft": {
47+
"address": "",
48+
"name": "Ocean Data NFT",
49+
"symbol": "OCEAN-NFT",
50+
"state": 5,
51+
"tokenURI": "",
52+
"owner": "",
53+
"created": ""
54+
},
55+
"purgatory": {
56+
"state": false
57+
},
58+
"stats": [{
59+
"orders": 0,
60+
"token": "0xf08A50178dfcDe18524640EA6618a1f965821715",
61+
"prices": [
62+
{
63+
"price": "2"
64+
}
65+
]
66+
}]
5767
},
5868
"datatokens": [
5969
],
60-
"stats": {
61-
"allocated": 0,
62-
"orders": 0,
63-
"price": {
64-
"value": "2",
65-
"tokenAddress": "0xf08A50178dfcDe18524640EA6618a1f965821715",
66-
"tokenSymbol": "USDC"
67-
}
68-
},
69-
7070
"accessDetails": {
7171
"baseToken": {
7272
"address": "0xf08A50178dfcDe18524640EA6618a1f965821715",

metadata/jsAlgo.json

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,30 @@
5454
}
5555
}
5656
],
57-
"stats": {
58-
"allocated": 0,
59-
"orders": 0,
60-
"price": {
61-
"value": "0"
62-
}
63-
},
64-
"nft": {
65-
"address": "",
66-
"name": "Ocean Data NFT",
67-
"symbol": "OCEAN-NFT",
68-
"state": 5,
69-
"tokenURI": "",
70-
"owner": "",
71-
"created": ""
57+
"indexedMetadata": {
58+
"event": {},
59+
"nft": {
60+
"address": "",
61+
"name": "Ocean Data NFT",
62+
"symbol": "OCEAN-NFT",
63+
"state": 5,
64+
"tokenURI": "",
65+
"owner": "",
66+
"created": ""
67+
},
68+
"purgatory": {
69+
"state": false
70+
},
71+
"stats": [
72+
{
73+
"orders": 0,
74+
"prices": [
75+
{
76+
"price": "0"
77+
}
78+
]
79+
}
80+
],
81+
"datatokens": []
7282
}
7383
}

metadata/jsIPFSAlgo.json

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,30 @@
5151
}
5252
}
5353
],
54-
"stats": {
55-
"allocated": 0,
56-
"orders": 0,
57-
"price": {
58-
"value": "0"
54+
"indexedMetadata": {
55+
"event": {},
56+
"nft": {
57+
"address": "",
58+
"name": "Ocean Data NFT",
59+
"symbol": "OCEAN-NFT",
60+
"state": 5,
61+
"tokenURI": "",
62+
"owner": "",
63+
"created": ""
64+
},
65+
"purgatory": {
66+
"state": false
67+
},
68+
"stats": [
69+
{
70+
"orders": 0,
71+
"prices": [
72+
{
73+
"price": "0"
74+
}
75+
]
5976
}
60-
},
61-
"nft": {
62-
"address": "",
63-
"name": "Ocean Data NFT",
64-
"symbol": "OCEAN-NFT",
65-
"state": 5,
66-
"tokenURI": "",
67-
"owner": "",
68-
"created": ""
69-
}
77+
],
78+
"datatokens": []
79+
}
7080
}

metadata/pythonAlgo.json

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,30 @@
4848
"serviceEndpoint": "http://10.84.128.6:8001"
4949
}
5050
],
51-
"stats": {
52-
"allocated": 0,
53-
"orders": 0,
54-
"price": {
55-
"value": "0"
56-
}
57-
},
58-
"nft": {
59-
"address": "",
60-
"name": "Ocean Data NFT",
61-
"symbol": "OCEAN-NFT",
62-
"state": 5,
63-
"tokenURI": "",
64-
"owner": "",
65-
"created": ""
51+
"indexedMetadata": {
52+
"event": {},
53+
"nft": {
54+
"address": "",
55+
"name": "Ocean Data NFT",
56+
"symbol": "OCEAN-NFT",
57+
"state": 5,
58+
"tokenURI": "",
59+
"owner": "",
60+
"created": ""
61+
},
62+
"purgatory": {
63+
"state": false
64+
},
65+
"stats": [
66+
{
67+
"orders": 0,
68+
"prices": [
69+
{
70+
"price": "0"
71+
}
72+
]
73+
}
74+
],
75+
"datatokens": []
6676
}
6777
}

metadata/simpleComputeDataset.json

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,30 @@
4747
}
4848
}
4949
],
50-
"event": {
51-
},
52-
"nft": {
53-
"address": "",
54-
"name": "Ocean Data NFT",
55-
"symbol": "OCEAN-NFT",
56-
"state": 5,
57-
"tokenURI": "",
58-
"owner": "",
59-
"created": ""
60-
},
61-
"purgatory": {
62-
"state": false
63-
},
64-
"datatokens": [
65-
],
66-
"stats": {
67-
"allocated": 0,
68-
"orders": 0,
69-
"price": {
70-
"value": "0"
71-
}
50+
"indexedMetadata": {
51+
"event": {},
52+
"nft": {
53+
"address": "",
54+
"name": "Ocean Data NFT",
55+
"symbol": "OCEAN-NFT",
56+
"state": 5,
57+
"tokenURI": "",
58+
"owner": "",
59+
"created": ""
60+
},
61+
"purgatory": {
62+
"state": false
63+
},
64+
"stats": [
65+
{
66+
"orders": 0,
67+
"prices": [
68+
{
69+
"price": "0"
70+
}
71+
]
72+
}
73+
],
74+
"datatokens": []
7275
}
7376
}

metadata/simpleDownloadDataset.json

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,30 @@
4141
"timeout": 86400
4242
}
4343
],
44-
"event": {
45-
},
46-
"nft": {
47-
"address": "",
48-
"name": "Ocean Data NFT",
49-
"symbol": "OCEAN-NFT",
50-
"state": 5,
51-
"tokenURI": "",
52-
"owner": "",
53-
"created": ""
54-
},
55-
"purgatory": {
56-
"state": false
57-
},
58-
"datatokens": [
59-
],
60-
"stats": {
61-
"allocated": 0,
62-
"orders": 0,
63-
"price": {
64-
"value": "2"
65-
}
44+
"indexedMetadata": {
45+
"event": {},
46+
"nft": {
47+
"address": "",
48+
"name": "Ocean Data NFT",
49+
"symbol": "OCEAN-NFT",
50+
"state": 5,
51+
"tokenURI": "",
52+
"owner": "",
53+
"created": ""
54+
},
55+
"purgatory": {
56+
"state": false
57+
},
58+
"stats": [
59+
{
60+
"orders": 0,
61+
"prices": [
62+
{
63+
"price": "0"
64+
}
65+
]
66+
}
67+
],
68+
"datatokens": []
6669
}
6770
}

0 commit comments

Comments
 (0)