Spaces:
Running
Running
Download action_driver.mjs from WideChaos/local-label-queue: direct link, hf CLI and curl.
- Browser
- Download file 899 Bytes
-
https://huggingface.co/spaces/WideChaos/local-label-queue/resolve/main/action_driver.mjs
- Command line
-
hf download hf://spaces/WideChaos/local-label-queue/action_driver.mjs
-
curl -L -o action_driver.mjs https://huggingface.co/spaces/WideChaos/local-label-queue/resolve/main/action_driver.mjs
899 Bytes
| import fs from "node:fs"; | |
| import { | |
| createSession, | |
| exportCheckpoint, | |
| readCheckpoint, | |
| sessionFromCheckpoint, | |
| } from "./queue.mjs"; | |
| const cases = JSON.parse(fs.readFileSync(0, "utf8")), | |
| results = []; | |
| for (const c of cases) { | |
| const s = await createSession(c.inventory), | |
| trace = []; | |
| for (const action of c.actions) { | |
| if (action.type === "undo") s.undo(); | |
| else s.decide(action.status, action.label, action.id); | |
| trace.push({ | |
| summary: s.summary(), | |
| revision: s.revision, | |
| undo_count: s.undoCount, | |
| }); | |
| } | |
| const checkpoint = await exportCheckpoint(s); | |
| const restored = sessionFromCheckpoint( | |
| await readCheckpoint(new TextEncoder().encode(JSON.stringify(checkpoint))), | |
| ); | |
| results.push({ | |
| trace, | |
| checkpoint, | |
| restored_payload: restored.payload(), | |
| restored_undo_count: restored.undoCount, | |
| }); | |
| } | |
| console.log(JSON.stringify(results)); | |