remote runtime runs programs on a machine. When you have more than one, a
route policy picks the machine for each line.
Example
Run jobs on a CPU container by default, and GPU jobs on a GPU container:route.py
python3 /jobs/gpu/train.py runs in my-gpu, python3 /jobs/train.py
runs in my-box (the machine of the remote entry), and
cat data.csv | python3 -c "..." stays on monty.
Name the runtime too
Only theremote runtime runs on a machine. A route that names just a
machine changes where remote runs, not what remote runs:
In the example, monty captures
python3 first. So
{"kind": "route", "machine": "gpu"} alone would leave python3 on monty.
Name remote as well.
A route fails the line with a routing error when it names:
- a machine that is not under
machines: - a machine together with a runtime other than
remoteorworkspace - a machine in a workspace that has no
remoteruntime
One machine per session
ctx["session_id"] tells the script whose line it is, so each agent can
get its own machine:
route.py
In code
A route function returns aRoute to pick a machine:
ws.shell(line, machine="gpu"), or { machine: 'gpu' } in TypeScript.
A policy in code can return Route(machine=...)
too. At pre_command it moves one command: in ls; python3 train.py, only
python3 goes to the machine. Behind nohup, nice, setsid, stdbuf or
ionice, the wrapper goes where its program goes.
The rules of Route Runtime apply here
too, and ws.explain(line) shows the machine each command would run on.