Skip to content

Commit

Permalink
Merge pull request #622 from golemfactory/test/JST-520/add-missing-co…
Browse files Browse the repository at this point in the history
…mposable-task

test(examples): add missing composing task example
  • Loading branch information
cryptobench authored Oct 19, 2023
2 parents b0b8b8b + 47cc5fa commit 012c95e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
23 changes: 23 additions & 0 deletions examples/docs-examples/examples/composing-tasks/alert-code.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { TaskExecutor } from "@golem-sdk/golem-js";
(async () => {
const executor = await TaskExecutor.create({
package: "529f7fdaf1cf46ce3126eb6bbcd3b213c314fe8fe884914f5d1106d4",
yagnaOptions: { apiKey: "try_golem" },
});

const result = await executor.run(async (ctx) => {
const res = await ctx
.beginBatch()
.uploadFile("./worker.mjs", "/golem/input/worker.mjs")
.run("node /golem/input/worker.mjs > /golem/input/output.txt")
.run("cat /golem/input/output.txt")
.downloadFile("/golem/input/output.txt", "./output.txt")
.endStream();

for await (const chunk of res) {
chunk.index == 2 ? console.log(chunk.stdout) : "";
}
});

await executor.end();
})();
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"@typescript-eslint/parser": "^6.0.0",
"buffer": "^6.0.3",
"cypress": "13.3.1",
"eslint": "~8.50.0",
"eslint": "~8.51.0",
"eslint-config-prettier": "^9.0.0",
"express": "^4.18.2",
"husky": "^8.0.3",
Expand All @@ -101,7 +101,7 @@
"typedoc": "^0.25.1",
"typedoc-plugin-markdown": "^3.14.0",
"typedoc-plugin-merge-modules": "^5.0.1",
"typedoc-theme-hierarchy": "4.1.1",
"typedoc-theme-hierarchy": "4.1.2",
"typescript": "^5.1.6",
"webpack": "^5.75.0"
}
Expand Down
1 change: 1 addition & 0 deletions tests/examples/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/single-command.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/composing-tasks/single-command.cjs" },
{ "cmd": "ts-node", "path": "examples/docs-examples/examples/composing-tasks/single-command.ts" },
{ "cmd": "ts-node", "path": "examples/docs-examples/examples/composing-tasks/alert-code.mjs" },

{ "cmd": "node", "path": "examples/docs-examples/examples/executing-tasks/before-each.mjs" },
{ "cmd": "node", "path": "examples/docs-examples/examples/executing-tasks/foreach.mjs" },
Expand Down

0 comments on commit 012c95e

Please sign in to comment.