Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/meds_algorithm/ORCHESTRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 17 additions & 1 deletion src/meds_algorithm/orchestration/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 19 additions & 0 deletions tests/test_orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))))
Expand Down
Loading