EMRY-067: emry slurm-wrap sidecar helper #112

Merged
vxfemboy merged 2 commits from emry-067-slurm-wrap into main 2026-07-02 22:30:14 +00:00
vxfemboy commented 2026-07-02 21:55:37 +00:00 (Migrated from github.com)

What

Adds emry slurm-wrap — a one-command wrapper for the SLURM sidecar pattern:

emry slurm-wrap --project llama-sft --log-dir "$SCRATCH/emry-logs" -- srun python train.py

It collapses the start-engine / wait-for-socket / run / drain boilerplate from the SLURM runbook §3 into a single command.

How it works

  1. Start the engine as a child of the current executable (std::env::current_exe()engine --project … --socket … [--log-dir …]), so it works without emry on PATH.
  2. Wait (bounded, ~10s) for the engine to bind the Unix socket; bails out if the engine exits early.
  3. Run the training command (everything after --) with EMRY_MODE=sidecar and EMRY_SOCKET exported and stdio inherited.
  4. Drain & clean up: grace-wait (~5s) for the engine to exit on RUN_FINISHED, terminate it if still blocked on accept(), remove the socket.
  5. Propagate the training command's exit code.

The socket path defaults to $TMPDIR/emry-$SLURM_JOB_ID.sock (falling back to the wrapper's pid off-cluster); --socket overrides.

Tests

  • slurm_socket_path_prefers_explicit_then_job_id_then_pid — the pure path-resolution helper.
  • slurm_wrap_captures_command_after_dashdash / slurm_wrap_requires_a_command — arg parsing.

The orchestration body spawns processes and calls std::process::exit, so it's not unit-tested — consistent with cmd_engine/cmd_tui/cmd_web.

Docs: new "Shortcut: emry slurm-wrap" section in the SLURM runbook.

Closes #111

## What Adds `emry slurm-wrap` — a one-command wrapper for the SLURM sidecar pattern: ```bash emry slurm-wrap --project llama-sft --log-dir "$SCRATCH/emry-logs" -- srun python train.py ``` It collapses the start-engine / wait-for-socket / run / drain boilerplate from the [SLURM runbook](docs/emry/slurm.md) §3 into a single command. ## How it works 1. **Start the engine** as a child of the current executable (`std::env::current_exe()` → `engine --project … --socket … [--log-dir …]`), so it works without `emry` on `PATH`. 2. **Wait (bounded, ~10s)** for the engine to bind the Unix socket; bails out if the engine exits early. 3. **Run the training command** (everything after `--`) with `EMRY_MODE=sidecar` and `EMRY_SOCKET` exported and stdio inherited. 4. **Drain & clean up**: grace-wait (~5s) for the engine to exit on `RUN_FINISHED`, terminate it if still blocked on `accept()`, remove the socket. 5. **Propagate** the training command's exit code. The socket path defaults to `$TMPDIR/emry-$SLURM_JOB_ID.sock` (falling back to the wrapper's pid off-cluster); `--socket` overrides. ## Tests - `slurm_socket_path_prefers_explicit_then_job_id_then_pid` — the pure path-resolution helper. - `slurm_wrap_captures_command_after_dashdash` / `slurm_wrap_requires_a_command` — arg parsing. The orchestration body spawns processes and calls `std::process::exit`, so it's not unit-tested — consistent with `cmd_engine`/`cmd_tui`/`cmd_web`. Docs: new "Shortcut: `emry slurm-wrap`" section in the SLURM runbook. Closes #111
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
femboy/emry!112
No description provided.