-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #622 from golemfactory/test/JST-520/add-missing-co…
…mposable-task test(examples): add missing composing task example
- Loading branch information
Showing
3 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
examples/docs-examples/examples/composing-tasks/alert-code.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters