diff --git a/bin/runnbs.ts b/bin/runnbs.ts index 41a8524..1870c4f 100644 --- a/bin/runnbs.ts +++ b/bin/runnbs.ts @@ -1,5 +1,5 @@ import "@std/dotenv/load"; - +import { retry } from "jsr:@std/async"; import { getConfig } from "jurassic/config.ts"; import path from "node:path"; @@ -8,18 +8,21 @@ if (import.meta.main) { const results = await Promise.all( config.notebooks.map((nb: string) => { console.log(`Running ${nb}`); - const command = new Deno.Command("jupyter", { - args: [ - "execute", - "--kernel_name=deno", - path.resolve(config.nbsPath, nb), - ], - stdin: "piped", - stdout: "piped", - }); - const child = command.spawn(); - child.stdin.close(); - return child.status; + const fn = () => { + const command = new Deno.Command("jupyter", { + args: [ + "execute", + "--kernel_name=deno", + path.resolve(config.nbsPath, nb), + ], + stdin: "piped", + stdout: "piped", + }); + const child = command.spawn(); + child.stdin.close(); + return child.status; + }; + return retry(fn, { maxAttempts: 3, minTimeout: 100 }); }), ); diff --git a/deno.json b/deno.json index 7a4f52a..e3633f9 100644 --- a/deno.json +++ b/deno.json @@ -22,6 +22,7 @@ }, "imports": { "@anthropic-ai/sdk": "npm:@anthropic-ai/sdk@^0.33.1", + "@std/async": "jsr:@std/async@^1.0.9", "@std/dotenv": "jsr:@std/dotenv@^0.225.3", "@std/fs": "jsr:@std/fs@^1.0.6", "typescript": "npm:typescript@^5.7.2", diff --git a/deno.lock b/deno.lock index 0844ed6..8b4eeae 100644 --- a/deno.lock +++ b/deno.lock @@ -2,6 +2,8 @@ "version": "4", "specifiers": { "jsr:@std/assert@*": "1.0.9", + "jsr:@std/async@*": "1.0.9", + "jsr:@std/async@^1.0.9": "1.0.9", "jsr:@std/dotenv@~0.225.3": "0.225.3", "jsr:@std/fs@^1.0.6": "1.0.6", "jsr:@std/internal@^1.0.5": "1.0.5", @@ -20,6 +22,9 @@ "jsr:@std/internal" ] }, + "@std/async@1.0.9": { + "integrity": "c6472fd0623b3f3daae023cdf7ca5535e1b721dfbf376562c0c12b3fb4867f91" + }, "@std/dotenv@0.225.3": { "integrity": "a95e5b812c27b0854c52acbae215856d9cce9d4bbf774d938c51d212711e8d4a" }, @@ -251,6 +256,7 @@ }, "workspace": { "dependencies": [ + "jsr:@std/async@^1.0.9", "jsr:@std/dotenv@~0.225.3", "jsr:@std/fs@^1.0.6", "npm:@anthropic-ai/sdk@~0.33.1",