@genroc/eval-node 0.20.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/worker.js +10 -4
- package/package.json +1 -1
- package/worker.ts +10 -5
package/README.md
CHANGED
|
@@ -78,9 +78,9 @@ export default function (input: Input): Output {
|
|
|
78
78
|
## Running the worker
|
|
79
79
|
|
|
80
80
|
```sh
|
|
81
|
-
docker run -e GENROC_SERVER=http://host:8448
|
|
81
|
+
docker run -e GENROC_SERVER=http://host:8448 ghcr.io/genroc/eval-node:latest
|
|
82
82
|
# or
|
|
83
|
-
GENROC_SERVER=http://localhost:8448
|
|
83
|
+
GENROC_SERVER=http://localhost:8448 npx genroc-eval-node
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
The worker connects to genroc, not the other way round, so it only needs outbound access.
|
|
@@ -89,7 +89,7 @@ The worker connects to genroc, not the other way round, so it only needs outboun
|
|
|
89
89
|
|---|---|---|
|
|
90
90
|
| `GENROC_SERVER` | `http://localhost:8448` | the genroc server |
|
|
91
91
|
| `GENROC_TOKEN` / `GENROC_TOKEN_FILE` | *(none)* | token, or a file holding it, when the server uses `--auth token` |
|
|
92
|
-
| `
|
|
92
|
+
| `PROCESS` / `TASK` | `script-node` / `eval_node` | the process and task id this worker claims; the defaults are script-node's. Set `PROCESS` for a renamed copy. Neither may be empty. |
|
|
93
93
|
| `CONCURRENCY` | `4` | scripts run at once |
|
|
94
94
|
| `LEASE_MS` | `30000` | claim lease, renewed every third of it |
|
|
95
95
|
| `POLL_MS` | `250` | idle poll interval |
|
package/dist/worker.js
CHANGED
|
@@ -22,8 +22,14 @@ const RENEW_MS = Math.max(1_000, Math.floor(LEASE_MS / 3));
|
|
|
22
22
|
// The answer has to land before the task's deadline fires, or a script that overran surfaces as
|
|
23
23
|
// external.timeout ("nobody answered") rather than as its own `timeout`.
|
|
24
24
|
const ANSWER_MARGIN_MS = 250;
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
// script-node's names; a renamed copy sets PROCESS. The claim requires both: this worker answers
|
|
26
|
+
// one task's contract, so it must never be handed another's.
|
|
27
|
+
const PROCESS_FILTER = process.env.PROCESS ?? "script-node";
|
|
28
|
+
const TASK_FILTER = process.env.TASK ?? "eval_node";
|
|
29
|
+
if (!PROCESS_FILTER || !TASK_FILTER) {
|
|
30
|
+
console.error("PROCESS and TASK must both name the queue this worker serves; neither may be empty.");
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
27
33
|
// Large values arrive as refs; a bundle is one object per definition version, fetched once.
|
|
28
34
|
// Refs are content hashes, so the cache never invalidates.
|
|
29
35
|
const objectCache = new Map();
|
|
@@ -115,8 +121,8 @@ async function claim(n) {
|
|
|
115
121
|
worker_id: WORKER_ID,
|
|
116
122
|
limit: n,
|
|
117
123
|
lease_ms: LEASE_MS,
|
|
118
|
-
|
|
119
|
-
|
|
124
|
+
process: PROCESS_FILTER,
|
|
125
|
+
task: TASK_FILTER,
|
|
120
126
|
});
|
|
121
127
|
if (!ok) {
|
|
122
128
|
// A credential problem is not transient, and polling through it looks like a healthy idle
|
package/package.json
CHANGED
package/worker.ts
CHANGED
|
@@ -25,8 +25,14 @@ const RENEW_MS = Math.max(1_000, Math.floor(LEASE_MS / 3));
|
|
|
25
25
|
// The answer has to land before the task's deadline fires, or a script that overran surfaces as
|
|
26
26
|
// external.timeout ("nobody answered") rather than as its own `timeout`.
|
|
27
27
|
const ANSWER_MARGIN_MS = 250;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
// script-node's names; a renamed copy sets PROCESS. The claim requires both: this worker answers
|
|
29
|
+
// one task's contract, so it must never be handed another's.
|
|
30
|
+
const PROCESS_FILTER = process.env.PROCESS ?? "script-node";
|
|
31
|
+
const TASK_FILTER = process.env.TASK ?? "eval_node";
|
|
32
|
+
if (!PROCESS_FILTER || !TASK_FILTER) {
|
|
33
|
+
console.error("PROCESS and TASK must both name the queue this worker serves; neither may be empty.");
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
30
36
|
|
|
31
37
|
type ObjectEntry = { path: (string | number)[]; ref: string; size: number };
|
|
32
38
|
|
|
@@ -36,7 +42,6 @@ type QueueTask = {
|
|
|
36
42
|
task: string;
|
|
37
43
|
external_input: unknown;
|
|
38
44
|
objects?: ObjectEntry[];
|
|
39
|
-
raises?: Record<string, unknown>;
|
|
40
45
|
deadline_in_ms?: number;
|
|
41
46
|
};
|
|
42
47
|
|
|
@@ -133,8 +138,8 @@ async function claim(n: number): Promise<QueueTask[]> {
|
|
|
133
138
|
worker_id: WORKER_ID,
|
|
134
139
|
limit: n,
|
|
135
140
|
lease_ms: LEASE_MS,
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
process: PROCESS_FILTER,
|
|
142
|
+
task: TASK_FILTER,
|
|
138
143
|
});
|
|
139
144
|
if (!ok) {
|
|
140
145
|
// A credential problem is not transient, and polling through it looks like a healthy idle
|