From e78c981a3bfab9d00d28968eff73886dba2db252 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Thu, 20 Mar 2025 15:24:36 +0200 Subject: [PATCH 01/18] add compute test file --- test/compute.test.ts | 105 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 test/compute.test.ts diff --git a/test/compute.test.ts b/test/compute.test.ts new file mode 100644 index 0000000..1a32a5c --- /dev/null +++ b/test/compute.test.ts @@ -0,0 +1,105 @@ +import { expect } from "chai"; +import { exec } from "child_process"; +import path from "path"; +import fs from "fs"; +import util from "util"; + +const execPromise = util.promisify(exec); + +describe("Ocean CLI Compute Flow", function () { + this.timeout(300000); // 5 min timeout + + const projectRoot = path.resolve(__dirname, ".."); + + let computeDatasetDid: string; + let algoDid: string; + const computeEnvId: string = "1"; + let jobId: string; + + const runCommand = async (command: string): Promise => { + console.log(`\n[CMD]: ${command}`); + try { + const { stdout } = await execPromise(command, { cwd: projectRoot }); + console.log(`[OUTPUT]:\n${stdout}`); + return stdout; + } catch (error: any) { + console.error(`[ERROR]:\n${error.stderr || error.message}`); + throw error; + } + }; + + before(async () => { + process.env.PRIVATE_KEY = "0xYOUR_PRIVATE_KEY"; + process.env.RPC = "http://127.0.0.1:8545"; + process.env.AQUARIUS_URL = "http://127.0.0.1:5000"; + process.env.PROVIDER_URL = "http://127.0.0.1:8030"; + }); + + it("should publish a compute dataset", async () => { + const metadataFile = path.resolve( + projectRoot, + "metadata/simpleComputeDataset.json" + ); + + if (!fs.existsSync(metadataFile)) { + throw new Error(`Metadata file not found: ${metadataFile}`); + } + + const output = await runCommand(`npm run cli publish ${metadataFile}`); + + const didMatch = output.match(/did:op:[a-f0-9]{64}/); + expect(didMatch, "No DID found in output").to.not.be.null; + + computeDatasetDid = didMatch![0]; + console.log(`Published Compute Dataset DID: ${computeDatasetDid}`); + }); + + it("should publish an algorithm", async () => { + const algoFile = path.resolve(projectRoot, "metadata/jsAlgo.json"); + + if (!fs.existsSync(algoFile)) { + throw new Error(`Algorithm metadata file not found: ${algoFile}`); + } + + const output = await runCommand(`npm run cli publishAlgo ${algoFile}`); + + const didMatch = output.match(/did:op:[a-f0-9]{64}/); + expect(didMatch, "No DID found in output").to.not.be.null; + + algoDid = didMatch![0]; + console.log(`Published Algorithm DID: ${algoDid}`); + }); + + it("should start a compute job", async () => { + const output = await runCommand( + `npm run cli startCompute -- --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` + ); + + const jobIdMatch = output.match( + /Job started successfully with ID: ([a-f0-9-]+)/i + ); + expect(jobIdMatch, "No Job ID found in output").to.not.be.null; + + jobId = jobIdMatch![1]; + console.log(`Started Compute Job ID: ${jobId}`); + }); + + it("should get the job status", async () => { + const output = await runCommand( + `npm run cli getJobStatus -- --dataset ${computeDatasetDid} --job ${jobId}` + ); + + expect(output).to.contain(jobId); + expect(output).to.match(/status/i); + console.log(`Job status output received for jobId: ${jobId}`); + }); + + it("should stop the compute job", async () => { + const output = await runCommand( + `npm run cli stopCompute -- --dataset ${computeDatasetDid} --job ${jobId}` + ); + + expect(output).to.contain("Compute job stopped successfully"); + console.log(`Stopped Compute Job ID: ${jobId}`); + }); +}); From edfcc35a76d5b4981e84563790d88717bee94d15 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Thu, 20 Mar 2025 15:28:31 +0200 Subject: [PATCH 02/18] update compute commands --- test/compute.test.ts | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/test/compute.test.ts b/test/compute.test.ts index 1a32a5c..6e51a69 100644 --- a/test/compute.test.ts +++ b/test/compute.test.ts @@ -6,14 +6,14 @@ import util from "util"; const execPromise = util.promisify(exec); -describe("Ocean CLI Compute Flow", function () { - this.timeout(300000); // 5 min timeout +describe("Ocean CLI Free Compute Flow", function () { + this.timeout(300000); const projectRoot = path.resolve(__dirname, ".."); let computeDatasetDid: string; let algoDid: string; - const computeEnvId: string = "1"; + let computeEnvId: string; let jobId: string; const runCommand = async (command: string): Promise => { @@ -70,9 +70,22 @@ describe("Ocean CLI Compute Flow", function () { console.log(`Published Algorithm DID: ${algoDid}`); }); - it("should start a compute job", async () => { + it("should get compute environments", async () => { + const output = await runCommand(`npm run cli getComputeEnvironments`); + + expect(output).to.contain("id"); + + const envMatch = output.match(/id: (0x[a-fA-F0-9]+)/); + if (!envMatch) + throw new Error("No environment ID found in environments output"); + + computeEnvId = envMatch[1]; + console.log(`Fetched Compute Env ID: ${computeEnvId}`); + }); + + it("should start a free compute job", async () => { const output = await runCommand( - `npm run cli startCompute -- --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` + `npm run cli startFreeCompute -- --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` ); const jobIdMatch = output.match( @@ -81,17 +94,26 @@ describe("Ocean CLI Compute Flow", function () { expect(jobIdMatch, "No Job ID found in output").to.not.be.null; jobId = jobIdMatch![1]; - console.log(`Started Compute Job ID: ${jobId}`); + console.log(`Started Free Compute Job ID: ${jobId}`); }); - it("should get the job status", async () => { + it("should get job status", async () => { const output = await runCommand( `npm run cli getJobStatus -- --dataset ${computeDatasetDid} --job ${jobId}` ); expect(output).to.contain(jobId); - expect(output).to.match(/status/i); - console.log(`Job status output received for jobId: ${jobId}`); + expect(output.toLowerCase()).to.match(/status/); + console.log(`Job status retrieved for jobId: ${jobId}`); + }); + + it("should fetch streamable logs", async () => { + const output = await runCommand( + `npm run cli computeStreamableLogs -- --job ${jobId}` + ); + + expect(output).to.contain(jobId); + console.log(`Streamable logs retrieved for jobId: ${jobId}`); }); it("should stop the compute job", async () => { @@ -100,6 +122,6 @@ describe("Ocean CLI Compute Flow", function () { ); expect(output).to.contain("Compute job stopped successfully"); - console.log(`Stopped Compute Job ID: ${jobId}`); + console.log(`Stopped compute job with ID: ${jobId}`); }); }); From d96c84112bb6a2f098bd69b71a7885e9653acba2 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Thu, 20 Mar 2025 15:31:07 +0200 Subject: [PATCH 03/18] update key --- test/compute.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/compute.test.ts b/test/compute.test.ts index 6e51a69..063acd2 100644 --- a/test/compute.test.ts +++ b/test/compute.test.ts @@ -29,7 +29,8 @@ describe("Ocean CLI Free Compute Flow", function () { }; before(async () => { - process.env.PRIVATE_KEY = "0xYOUR_PRIVATE_KEY"; + process.env.PRIVATE_KEY = + "0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699b1150a5befc"; process.env.RPC = "http://127.0.0.1:8545"; process.env.AQUARIUS_URL = "http://127.0.0.1:5000"; process.env.PROVIDER_URL = "http://127.0.0.1:8030"; From 238216cabba16a64ff400dd544c169271182be43 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 21 Mar 2025 13:21:44 +0200 Subject: [PATCH 04/18] small fixes --- test/compute.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/compute.test.ts b/test/compute.test.ts index 063acd2..8b7b186 100644 --- a/test/compute.test.ts +++ b/test/compute.test.ts @@ -4,8 +4,14 @@ import path from "path"; import fs from "fs"; import util from "util"; +import { dirname } from "path"; +import { fileURLToPath } from "url"; + const execPromise = util.promisify(exec); +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + describe("Ocean CLI Free Compute Flow", function () { this.timeout(300000); @@ -32,8 +38,12 @@ describe("Ocean CLI Free Compute Flow", function () { process.env.PRIVATE_KEY = "0x1d751ded5a32226054cd2e71261039b65afb9ee1c746d055dd699b1150a5befc"; process.env.RPC = "http://127.0.0.1:8545"; - process.env.AQUARIUS_URL = "http://127.0.0.1:5000"; - process.env.PROVIDER_URL = "http://127.0.0.1:8030"; + // process.env.AQUARIUS_URL = "http://127.0.0.1:5000"; + // process.env.PROVIDER_URL = "http://127.0.0.1:8030"; + process.env.ADDRESS_FILE = path.join( + process.env.HOME || "", + ".ocean/ocean-contracts/artifacts/address.json" + ); }); it("should publish a compute dataset", async () => { From 261b4896dba4ccc5c1270d24d87a97bfcb2214b7 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 21 Mar 2025 15:32:49 +0200 Subject: [PATCH 05/18] add log --- test/compute.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/compute.test.ts b/test/compute.test.ts index 8b7b186..3520759 100644 --- a/test/compute.test.ts +++ b/test/compute.test.ts @@ -44,6 +44,7 @@ describe("Ocean CLI Free Compute Flow", function () { process.env.HOME || "", ".ocean/ocean-contracts/artifacts/address.json" ); + console.log("Starting compute tests ... "); }); it("should publish a compute dataset", async () => { From 8035089cfc099fa7136d4b0612c253b64f814bc2 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 21 Mar 2025 15:57:50 +0200 Subject: [PATCH 06/18] check ocean node issue --- .github/workflows/ci.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbdc587..688a679 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '18' + node-version: "18" - name: Install dependencies run: npm install @@ -34,7 +34,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '18' + node-version: "18" - name: Install dependencies run: npm install @@ -52,7 +52,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: '18.19.0' + node-version: "18.19.0" - name: Cache node_modules uses: actions/cache@v3 @@ -69,8 +69,8 @@ jobs: - name: Checkout Barge uses: actions/checkout@v3 with: - repository: 'oceanprotocol/barge' - path: 'barge' + repository: "oceanprotocol/barge" + path: "barge" - name: Login to Docker Hub if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }} @@ -116,14 +116,14 @@ jobs: - name: Checkout Ocean Node uses: actions/checkout@v3 with: - repository: 'oceanprotocol/ocean-node' - path: 'ocean-node' - ref: 'main' + repository: "oceanprotocol/ocean-node" + path: "ocean-node" + ref: "main" - name: Start Ocean Node working-directory: ${{ github.workspace }}/ocean-node run: | - npm ci + npm i npm run build npm run start & env: @@ -133,8 +133,8 @@ jobs: P2P_ipV4BindTcpPort: 8000 HTTP_API_PORT: 8001 RPCS: '{ "8996": {"rpc": "http://127.0.0.1:8545", "chainId": 8996, "network": "development", "chunkSize": 100} }' - DB_URL: 'http://localhost:9200' - DB_TYPE: 'elasticsearch' + DB_URL: "http://localhost:9200" + DB_TYPE: "elasticsearch" FEE_TOKENS: '{ "1": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48", "137": "0x282d8efCe846A88B159800bd4130ad77443Fa1A1", "80001": "0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8", "56": "0xDCe07662CA8EbC241316a15B611c89711414Dd1a" }' FEE_AMOUNT: '{ "amount": 1, "unit": "MB" }' AUTHORIZED_DECRYPTERS: '["0xe2DD09d719Da89e5a3D0F2549c7E24566e947260","0x529043886F21D9bc1AE0feDb751e34265a246e47"]' @@ -153,10 +153,9 @@ jobs: done echo "Ocean Node did not start in time" exit 1 - - name: Run system tests + - name: Run system tests run: npm run test:system env: INDEXING_RETRY_INTERVAL: 4000 INDEXING_MAX_RETRIES: 120 - NODE_URL: 'http://127.0.0.1:8001' - + NODE_URL: "http://127.0.0.1:8001" From 73424dcee2a90c8047469dcb569fe16753cafc38 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 21 Mar 2025 16:15:58 +0200 Subject: [PATCH 07/18] try legacy peers --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 688a679..cc8d56a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,7 +123,9 @@ jobs: - name: Start Ocean Node working-directory: ${{ github.workspace }}/ocean-node run: | - npm i + npm cache clean --force + rm -rf node_modules package-lock.json + npm install --legacy-peer-deps npm run build npm run start & env: From 8bdc7127dcba55ccb022ee8439851b2c980d5d15 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 21 Mar 2025 16:43:32 +0200 Subject: [PATCH 08/18] update node version --- .github/workflows/ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc8d56a..3975ad6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,7 +52,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "18.19.0" + node-version: "20.16.0" - name: Cache node_modules uses: actions/cache@v3 @@ -123,9 +123,7 @@ jobs: - name: Start Ocean Node working-directory: ${{ github.workspace }}/ocean-node run: | - npm cache clean --force - rm -rf node_modules package-lock.json - npm install --legacy-peer-deps + npm ci npm run build npm run start & env: From 1c11caf25d4101762bac47a2fbc17c4b9a1be10a Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Fri, 21 Mar 2025 16:49:47 +0200 Subject: [PATCH 09/18] update get env test --- .github/workflows/ci.yml | 4 ++-- test/compute.test.ts | 25 ++++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3975ad6..89adc66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "18" + node-version: "20" - name: Install dependencies run: npm install @@ -34,7 +34,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "18" + node-version: "20" - name: Install dependencies run: npm install diff --git a/test/compute.test.ts b/test/compute.test.ts index 3520759..168f321 100644 --- a/test/compute.test.ts +++ b/test/compute.test.ts @@ -85,19 +85,26 @@ describe("Ocean CLI Free Compute Flow", function () { it("should get compute environments", async () => { const output = await runCommand(`npm run cli getComputeEnvironments`); - expect(output).to.contain("id"); + let environments; + try { + environments = JSON.parse(output); + } catch (error) { + throw new Error("Output is not valid JSON:\n" + output); + } + + expect(environments).to.be.an("array").that.is.not.empty; + + const firstEnv = environments[0]; - const envMatch = output.match(/id: (0x[a-fA-F0-9]+)/); - if (!envMatch) - throw new Error("No environment ID found in environments output"); + expect(firstEnv).to.have.property("id").that.is.a("string"); - computeEnvId = envMatch[1]; + computeEnvId = firstEnv.id; console.log(`Fetched Compute Env ID: ${computeEnvId}`); }); it("should start a free compute job", async () => { const output = await runCommand( - `npm run cli startFreeCompute -- --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` + `npm run cli startFreeCompute --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` ); const jobIdMatch = output.match( @@ -111,7 +118,7 @@ describe("Ocean CLI Free Compute Flow", function () { it("should get job status", async () => { const output = await runCommand( - `npm run cli getJobStatus -- --dataset ${computeDatasetDid} --job ${jobId}` + `npm run cli getJobStatus --dataset ${computeDatasetDid} --job ${jobId}` ); expect(output).to.contain(jobId); @@ -121,7 +128,7 @@ describe("Ocean CLI Free Compute Flow", function () { it("should fetch streamable logs", async () => { const output = await runCommand( - `npm run cli computeStreamableLogs -- --job ${jobId}` + `npm run cli computeStreamableLogs --job ${jobId}` ); expect(output).to.contain(jobId); @@ -130,7 +137,7 @@ describe("Ocean CLI Free Compute Flow", function () { it("should stop the compute job", async () => { const output = await runCommand( - `npm run cli stopCompute -- --dataset ${computeDatasetDid} --job ${jobId}` + `npm run cli stopCompute --dataset ${computeDatasetDid} --job ${jobId}` ); expect(output).to.contain("Compute job stopped successfully"); From 334bb48644946cc6407b55d3683ef39dd99edd4a Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 18:54:30 +0000 Subject: [PATCH 10/18] wip, fix test --- .github/workflows/ci.yml | 18 ++++++------ src/commands.ts | 6 ++-- test/compute.test.ts | 61 ++++++++++++++++++++++++++++++---------- 3 files changed, 58 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89adc66..d2d1557 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "20" + node-version: '18' - name: Install dependencies run: npm install @@ -34,7 +34,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "20" + node-version: '18' - name: Install dependencies run: npm install @@ -52,7 +52,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v2 with: - node-version: "20.16.0" + node-version: '18.19.0' - name: Cache node_modules uses: actions/cache@v3 @@ -69,8 +69,8 @@ jobs: - name: Checkout Barge uses: actions/checkout@v3 with: - repository: "oceanprotocol/barge" - path: "barge" + repository: 'oceanprotocol/barge' + path: 'barge' - name: Login to Docker Hub if: ${{ env.DOCKERHUB_PASSWORD && env.DOCKERHUB_USERNAME }} @@ -117,8 +117,8 @@ jobs: uses: actions/checkout@v3 with: repository: "oceanprotocol/ocean-node" - path: "ocean-node" - ref: "main" + path: 'ocean-node' + ref: 'main' - name: Start Ocean Node working-directory: ${{ github.workspace }}/ocean-node @@ -133,8 +133,8 @@ jobs: P2P_ipV4BindTcpPort: 8000 HTTP_API_PORT: 8001 RPCS: '{ "8996": {"rpc": "http://127.0.0.1:8545", "chainId": 8996, "network": "development", "chunkSize": 100} }' - DB_URL: "http://localhost:9200" - DB_TYPE: "elasticsearch" + DB_URL: 'http://localhost:9200' + DB_TYPE: 'elasticsearch' FEE_TOKENS: '{ "1": "0x967da4048cD07aB37855c090aAF366e4ce1b9F48", "137": "0x282d8efCe846A88B159800bd4130ad77443Fa1A1", "80001": "0xd8992Ed72C445c35Cb4A2be468568Ed1079357c8", "56": "0xDCe07662CA8EbC241316a15B611c89711414Dd1a" }' FEE_AMOUNT: '{ "amount": 1, "unit": "MB" }' AUTHORIZED_DECRYPTERS: '["0xe2DD09d719Da89e5a3D0F2549c7E24566e947260","0x529043886F21D9bc1AE0feDb751e34265a246e47"]' diff --git a/src/commands.ts b/src/commands.ts index b00ad9b..5ef5331 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -473,7 +473,7 @@ export class Commands { if (computeJobs && computeJobs[0]) { const { jobId, agreementId } = computeJobs[0]; - console.log("Compute started. JobID: " + jobId); + console.log("Compute started. JobID: " + jobId); console.log("Agreement ID: " + agreementId); } else { console.log("Error while starting the compute job: ", computeJobs); @@ -635,7 +635,7 @@ export class Commands { if (computeJobs && computeJobs[0]) { const { jobId } = computeJobs[0]; - console.log("Compute started. JobID: " + jobId); + console.log("Compute started. JobID: " + jobId); } else { console.log("Error while starting the compute job: ", computeJobs); } @@ -684,7 +684,7 @@ export class Commands { ); return; } - console.log('Exiting compute environments: ', computeEnvs) + console.log('Existing compute environments:', computeEnvs) } public async computeStreamableLogs(args: string[]) { diff --git a/test/compute.test.ts b/test/compute.test.ts index 168f321..1471324 100644 --- a/test/compute.test.ts +++ b/test/compute.test.ts @@ -12,6 +12,11 @@ const execPromise = util.promisify(exec); const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); +export async function sleep(ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms); + }); +} describe("Ocean CLI Free Compute Flow", function () { this.timeout(300000); @@ -85,34 +90,60 @@ describe("Ocean CLI Free Compute Flow", function () { it("should get compute environments", async () => { const output = await runCommand(`npm run cli getComputeEnvironments`); - let environments; + expect(output).to.contain("id"); + + const indexOfArray = output.indexOf('[') + console.log('output ', output) + const cleaned = `${output.substring(indexOfArray).trim()}` + + const validJsonString = cleaned + .replace(/'/g, '"') + .replace(/\[Object\]/g, '{}') + .replace(/\[Array\]/g, '[]') + .replace(/[\r\n]+/g, '') + .replace(/\+/g, '') + .replace(/\s+/g, '') + .replace(/([{,])\s*(\w+)(?=\s*:)/g, '$1"$2"'); // Add quotes around unquoted keys + try { - environments = JSON.parse(output); - } catch (error) { - throw new Error("Output is not valid JSON:\n" + output); - } - - expect(environments).to.be.an("array").that.is.not.empty; - - const firstEnv = environments[0]; - expect(firstEnv).to.have.property("id").that.is.a("string"); - - computeEnvId = firstEnv.id; - console.log(`Fetched Compute Env ID: ${computeEnvId}`); + const environments = JSON.parse(validJsonString) + console.log('environments ', environments) + if(environments.length > 0) { + for(let i = 0; i< environments.length; i++) { + const env = environments[i] + console.log('environment: ', env) + if(env.free) { + computeEnvId = env.id + console.log(`Fetched Compute Env ID: ${computeEnvId}`); + break + } + } + } + expect(environments.length > 0, 'No compute environments were found') + expect(computeEnvId, 'No free C2D environment found').to.not.be.null; + } catch(err) { + console.error('Unable to get compute environments') + } + }); it("should start a free compute job", async () => { + + await sleep(9000) // wait a bit, ideally wait to index + const output = await runCommand( `npm run cli startFreeCompute --datasets ${computeDatasetDid} --algo ${algoDid} --env ${computeEnvId}` ); const jobIdMatch = output.match( - /Job started successfully with ID: ([a-f0-9-]+)/i + /Compute started. JobID: ([a-f0-9-]+)/i ); expect(jobIdMatch, "No Job ID found in output").to.not.be.null; - jobId = jobIdMatch![1]; + const jobText = output.indexOf('Compute started. JobID:') + const important = output.substring(jobText) + jobId = important.replace('Compute started. JobID: ','') console.log(`Started Free Compute Job ID: ${jobId}`); }); From 22a1fd4f1b69f4ca4be11acacad95fda9c32c020 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 19:32:10 +0000 Subject: [PATCH 11/18] put ci as was --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2d1557..44bdb1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: - name: Checkout Ocean Node uses: actions/checkout@v3 with: - repository: "oceanprotocol/ocean-node" + repository: 'oceanprotocol/ocean-node' path: 'ocean-node' ref: 'main' @@ -158,4 +158,4 @@ jobs: env: INDEXING_RETRY_INTERVAL: 4000 INDEXING_MAX_RETRIES: 120 - NODE_URL: "http://127.0.0.1:8001" + NODE_URL: 'http://127.0.0.1:8001' From 06bfa8acad22bd244104163b3c0236d9d3e211f3 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 23:13:59 +0000 Subject: [PATCH 12/18] esbuild --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44bdb1c..58686b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,7 +123,10 @@ jobs: - name: Start Ocean Node working-directory: ${{ github.workspace }}/ocean-node run: | + npm run clean + rm -rf ./node_modules npm ci + npm ci esbuild npm run build npm run start & env: From efa58aeacb3e76aa1a88908b6693c84b8b45aaea Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 23:20:29 +0000 Subject: [PATCH 13/18] esbuild --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58686b4..190411f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,8 +125,8 @@ jobs: run: | npm run clean rm -rf ./node_modules + npm ci esbuild@0.18.20 npm ci - npm ci esbuild npm run build npm run start & env: From f926b5ab1dd4b5f01fe1ad5efc8d721eb7830297 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 23:28:14 +0000 Subject: [PATCH 14/18] esbuild --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 190411f..2781044 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,7 +124,6 @@ jobs: working-directory: ${{ github.workspace }}/ocean-node run: | npm run clean - rm -rf ./node_modules npm ci esbuild@0.18.20 npm ci npm run build From c9b3b2cc53eadd54fc869caba607fd63231a60c9 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 23:33:59 +0000 Subject: [PATCH 15/18] esbuild --- .github/workflows/ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2781044..f4185bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -118,13 +118,11 @@ jobs: with: repository: 'oceanprotocol/ocean-node' path: 'ocean-node' - ref: 'main' + ref: 'test-esbuild' - name: Start Ocean Node working-directory: ${{ github.workspace }}/ocean-node run: | - npm run clean - npm ci esbuild@0.18.20 npm ci npm run build npm run start & From 01f53f141d8e68f67907c062745d8bef6ddc2285 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 23:44:40 +0000 Subject: [PATCH 16/18] update endpoint on sample --- metadata/simpleComputeDataset.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata/simpleComputeDataset.json b/metadata/simpleComputeDataset.json index 0e8ba71..9a5c8c5 100644 --- a/metadata/simpleComputeDataset.json +++ b/metadata/simpleComputeDataset.json @@ -37,7 +37,7 @@ ] }, "datatokenAddress": "", - "serviceEndpoint": "http://10.84.128.6:8001", + "serviceEndpoint": "http://127.0.0.1:8001", "timeout": 86400, "compute": { "allowRawAlgorithm": false, From bb1504add23f3682b76e215f39b2a7b8259f3196 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Fri, 21 Mar 2025 23:56:48 +0000 Subject: [PATCH 17/18] another fix --- src/cli.ts | 2 +- src/commands.ts | 33 ++++++++++++++++++++------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index f7380b0..2788ce3 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -271,7 +271,7 @@ export async function createCLI() { const dsDid = options.dataset || datasetDid; const jId = options.job || jobId; const agrId = options.agreement || agreementId; - if (!dsDid || !jId) { + if (!jId) { console.error(chalk.red('Dataset DID and Job ID are required')); process.exit(1); } diff --git a/src/commands.ts b/src/commands.ts index 5ef5331..ee56dec 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -850,23 +850,30 @@ export class Commands { // args[2] - jobId // args[3] - agreementId const hasAgreementId = args.length === 4; - - const dataDdo = await this.aquarius.waitForIndexer(args[1],null,null, this.indexingParams.retryInterval, this.indexingParams.maxRetries); - if (!dataDdo) { - console.error( - "Error fetching DDO " + args[1] + ". Does this asset exists?" - ); - return; + const hasDid = args.length >=3 + let dataDdo = null + if(hasDid) { + dataDdo = await this.aquarius.waitForIndexer(args[1],null,null, this.indexingParams.retryInterval, this.indexingParams.maxRetries); + if (!dataDdo) { + console.error( + "Error fetching DDO " + args[1] + ". Does this asset exists?" + ); + return; + } } - const jobId = args[2] + + const jobId = hasDid ? args[2] : args[1] let agreementId = null; if(hasAgreementId) { - agreementId = args[3]; + agreementId = hasDid ? args[3] : args[2]; } - const providerURI = - this.macOsProviderUrl && dataDdo.chainId === 8996 - ? this.macOsProviderUrl - : dataDdo.services[0].serviceEndpoint; + let providerURI = this.macOsProviderUrl || this.providerUrl + if(dataDdo) { + providerURI = this.macOsProviderUrl && dataDdo.chainId === 8996 + ? this.macOsProviderUrl + : dataDdo.services[0].serviceEndpoint; + } + const jobStatus = (await ProviderInstance.computeStatus( providerURI, From 3b0cfbba692356c0e05496573a953d44ed1bad81 Mon Sep 17 00:00:00 2001 From: paulo-ocean Date: Sat, 22 Mar 2025 00:12:40 +0000 Subject: [PATCH 18/18] missing env vars --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f4185bf..7d99cf0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -159,3 +159,5 @@ jobs: INDEXING_RETRY_INTERVAL: 4000 INDEXING_MAX_RETRIES: 120 NODE_URL: 'http://127.0.0.1:8001' + RPC: 'http://127.0.0.1:8545' + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}