From 9a0ce9f2af90ad7ae09541ceeda5d0d45f5a51de Mon Sep 17 00:00:00 2001 From: Florent Pollet Date: Sat, 28 Nov 2026 11:35:45 -0500 Subject: [PATCH] Print each stage's SLURM job ID and the receipt path after submission The runner printed only 'Submitted: ', so job IDs had to be looked up in submission.json. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NJQdbHt5icm1CgFVHsHTNx --- src/meds_algorithm/ORCHESTRATION.md | 3 ++- src/meds_algorithm/orchestration/cli.py | 18 +++++++++++++++++- tests/test_orchestration.py | 19 +++++++++++++++++++ 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/meds_algorithm/ORCHESTRATION.md b/src/meds_algorithm/ORCHESTRATION.md index 76cb37a..b147dda 100644 --- a/src/meds_algorithm/ORCHESTRATION.md +++ b/src/meds_algorithm/ORCHESTRATION.md @@ -158,7 +158,8 @@ The existing runner saves `config.json`, `request.json` and `manifest.yaml` insi artifact, including resolved algorithm settings, input identities, seed and resource measurements. Scheduling settings are in `plan.json`; they do not alter algorithm-compatibility digests. -SLURM additionally writes Submitit's logs and a `submission.json` receipt with stage/job IDs. +SLURM additionally writes Submitit's logs and a `submission.json` receipt with stage/job IDs; the command prints +each stage's job ID and the receipt's path after submission. If submission fails partway through, the coordinator attempts to cancel already submitted jobs and records cancellation errors. `submitted` means accepted by the scheduler, not completed successfully. Monitor job IDs with the cluster's normal tools and inspect artifacts/logs before claiming success. diff --git a/src/meds_algorithm/orchestration/cli.py b/src/meds_algorithm/orchestration/cli.py index 92a3e04..ba0f49b 100644 --- a/src/meds_algorithm/orchestration/cli.py +++ b/src/meds_algorithm/orchestration/cli.py @@ -39,4 +39,20 @@ def main(repository, *, module: str, argv: list[str] | None = None): print(json.dumps(plan.to_dict(), indent=2)) else: RunCoordinator().execute(plan) - print(f"{'Submitted' if plan.execution == 'slurm' else 'Completed'}: {plan.output_dir}") + if plan.execution == "slurm": + print(submission_summary(plan.output_dir)) + else: + print(f"Completed: {plan.output_dir}") + + +def submission_summary(output_dir: Path) -> str: + """What a SLURM submission prints: the run directory, each stage's job ID, and where they are recorded.""" + receipt = output_dir / "submission.json" + jobs = json.loads(receipt.read_text(encoding="utf-8"))["jobs"] + width = max((len(job["stage"]) for job in jobs), default=0) + lines = [ + f"Submitted: {output_dir}", + *(f" {job['stage']:<{width}} job {job['job_id']}" for job in jobs), + f"Job IDs are recorded in {receipt}; step logs are in {output_dir / 'logs'}.", + ] + return "\n".join(lines) diff --git a/tests/test_orchestration.py b/tests/test_orchestration.py index 1b6a720..c57bec0 100644 --- a/tests/test_orchestration.py +++ b/tests/test_orchestration.py @@ -133,6 +133,25 @@ def test_cli_dry_run_has_no_output_or_scheduler_side_effects(setup, monkeypatch, assert set(setup.repo.parent.rglob("*")) == before +def test_slurm_submission_prints_job_ids_and_receipt(tmp_path): + from meds_algorithm.orchestration.cli import submission_summary + + (tmp_path / "submission.json").write_text( + json.dumps( + { + "status": "submitted", + "jobs": [{"stage": "preprocess_data", "job_id": "11"}, {"stage": "pretrain", "job_id": "12"}], + } + ) + ) + assert submission_summary(tmp_path).splitlines() == [ + f"Submitted: {tmp_path}", + " preprocess_data job 11", + " pretrain job 12", + f"Job IDs are recorded in {tmp_path / 'submission.json'}; step logs are in {tmp_path / 'logs'}.", + ] + + def test_missing_inputs_and_invalid_resources_fail_before_execution(setup): with pytest.raises(ValueError, match="labels_dir"): setup.planner.resolve(replace(setup.config, inputs=RunInputs(meds_dir=str(setup.inputs))))