Repository navigation
feat(cli): add gym job list, status and info - #5344
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP WITH CARE — 5 RISK findings and 2 NOTE suggestions.
Completed the light, broad review of all 17 changed files and their affected paths. The findings cover incorrect terminal-state reporting, failed file reads becoming false failures, error rendering suppressing healthy results, malformed index entries, and two user-facing inconsistencies.
Read-only source review: no tests or live Slurm commands were executed. Suggested patches and acceptance checks require author verification.
Inline comments (escaped v1):
-
nemo_gym/cli/job_render.pyline 99: RISK — Multiline connection errors abort the entire text reportFailure: SSH connection failures contain newlines, which status preserves in
detail. For example,detail="RuntimeError: SSH failed\nPermission denied"produces multiple physical table rows. The subsequentsplitlines()andzip(..., strict=True)raiseValueError, so text status exits with a zip-length error and prints neither the unreachable submission nor healthy submissions. Expected: UNKNOWN with the connection reason, while other results remain visible.Correction: Could you keep this table cell single-line, without changing the underlying status or JSON? Replace this line with:
detail = " ".join((job.detail or "-").splitlines()) or "-" rows.append((job.benchmark, job.state.value, job_id, detail))Preservation / acceptance: Proposed regression: query two connections, one raising
RuntimeError("SSH failed\nPermission denied")and one returning SUCCEEDED. Text output must contain both submissions, UNKNOWN with both error fragments, and SUCCEEDED, without exiting unsuccessfully. JSON must still parse and retain the original newline indetail. Retain the exact existing status-rendering assertion, including resumed-versus-recorded IDs and failure/logs lines. Static reasoning only; please verify the suggestion before adoption. -
nemo_gym/orchestration/executors/slurm_status.pyline 201: RISK — Preserve queue-query failures before consulting accountingFailure: With recorded ID 100, no state files, failing
squeue, and accounting output100|COMPLETED|0:0,_observe()returns SUCCEEDED before reaching this error branch. A newer job started in the same directory cannot be discovered after the queue query fails, so an old completion can falsely describe the current run and the error disappears. This contradicts the UNKNOWN-on-scheduler-error contract.Correction: Move the existing guard immediately before the accounting-selection loop, removing its old copy:
if squeue_error: return ObservedStatus(state=JobState.UNKNOWN, detail=f"squeue failed: {squeue_error}", **common)
The invariant is that a failed queue query cannot establish the absence of newer active work merely because a known ID has accounting data.
Preservation / acceptance: Keep all known IDs and readable files in the UNKNOWN result, allowing existing file reconciliation to operate. Proposed checks: failing
squeueplus the completed accounting row above must yield UNKNOWN withsqueue failed; adding a readable state file must retain it infiles. Healthy queue queries must retain the finished-accounting assertions. A RUNNING queue row with failingsacctmust still yield RUNNING. These checks were not executed; please verify the proposed move. -
nemo_gym/orchestration/executors/slurm_status.pyline 192: RISK — Do not substitute a predecessor's outcome for missing newest accountingFailure: With chain
100\n101\n, an empty successful queue response, no state files, and accounting containing only100|TIMEOUT|0:0, this loop skips missing ID 101 and reports FAILED for 100. An older COMPLETED row similarly produces false success. The newest attempt's outcome is unknown, not the predecessor's outcome; the resume producer explicitly accommodates accounting lag.Correction: Only the newest known ID may supply the terminal accounting verdict. Since
job_idsis already sorted ascending, replace this loop header with:for job_id in job_ids[-1:]:If that ID has no accounting row, fall through to UNKNOWN/error handling rather than borrowing an older result.
Preservation / acceptance: Keep active-state selection ahead of accounting, retain the full ID list and readable files, and allow UNKNOWN to be reconciled by existing state-file rules. Proposed regressions: chain 100/101 with only predecessor TIMEOUT or COMPLETED must yield UNKNOWN; adding
101|COMPLETED|0:0must yield SUCCEEDED with ID 101. Retain the existing newest-chain assertion and the RUNNING-800-over-PENDING-900 assertion. Static reasoning only; verify the suggestion before adoption. -
nemo_gym/orchestration/executors/slurm_status.pyline 83: RISK — Omit failed state-file reads instead of emitting empty contentFailure: An existing but unreadable
.gym_chain_incompletepasses-f. Whenheadfails, the remaining pipeline andechostill emit a file marker containing empty content. The parser treats that as a real marker, and reconciliation turns it into FAILED, potentially overriding a completed job. The file contract instead requires unreadable files to be absent.Correction: Emit a marker only when the bounded read and encoding succeed. Replace the current generated
if/echolines inside the file loop with these list entries:f' if [ -f "$dir/$_f" ] && _encoded=$(set -o pipefail; head -c {_STATE_FILE_BYTES} "$dir/$_f" 2>/dev/null | base64 | tr -d "\\n"); then', f' echo "{_MARK}file:{tag}:$_f:$_encoded"', ' fi',
Subshell-local
pipefailchecks the read without changing surrounding error handling. Successfully read empty files must remain distinguishable from failed reads.Preservation / acceptance: Proposed regression: use a
headstand-in that exits nonzero for the incomplete marker; it must be absent fromfiles, and a completed job must remain SUCCEEDED. A readable empty marker must still return""and trigger the existing incomplete-chain rule. Another readable state file and scheduler results must survive the failed read. Retain the 4096-byte bound and the quotes/newlines/Unicode and quoted-directory assertions. No shell checks were executed; please verify the suggested code. -
nemo_gym/orchestration/jobs.pyline 460: RISK — Skip valid JSON that is not a record objectFailure: Alongside a valid indexed submission, put
[]in another*.jsonindex file. Decoding succeeds, but SubmissionRecord.load() callspayload.get(), raisingAttributeErroroutside this handler. Offline listing and status without IDs then abort instead of warning and returning valid submissions.null, strings, and numbers fail similarly.Correction: Validate the decoded shape before calling
load(), routing malformed cache data through the existing warning-and-skip branch. Replace the current load statement with:payload = json.loads(path.read_text(encoding="utf-8")) if not isinstance(payload, dict): raise ValueError("Job record must be a JSON object") records.append(SubmissionRecord.load(payload))
This restores the invariant that one malformed index entry cannot hide valid records, without broadly catching programming errors.
Preservation / acceptance: Proposed regression: parameterize a second indexed file over
[],null,"not a record", and123, alongside one valid record. Listing must return the valid record and warn with the bad filename;limit=1must still return it. Retain the existing index assertions: newest-first sorting, limiting, and warnings for invalid JSON and future schemas. Keep older-record compatibility. Explicit-ID loading need not change for this localized repair. Tests were not executed; please verify the suggested code. -
nemo_gym/cli/job.pyline 48: NOTE — Suggestion: count matching submissions in the pagination hintFailure: With one
gpqasubmission and onerulersubmission,gym job status --benchmark gpqashows every matching result but prints1 of 2 submissions shown (--all for the rest). Adding--allcannot reveal the excluded submission because selection precedes limiting. The hint should describe omitted matching results, not excluded records.Correction: Replace this line with a count using the same eligibility rule:
eligible = list_submissions() if benchmarks: wanted = set(benchmarks) eligible = [record for record in eligible if wanted <= {job.benchmark for job in record.benchmarks}] total = len(eligible)Preservation / acceptance: Extend the selector test with text output: its two-record setup must show
gpqawithout a pagination hint. With three matching records, one nonmatching record, and--limit 1, expect1 of 3, not1 of 4. Retain the unfiltered1 of 2assertion and absence of a hint with--all. Explicit-ID and JSON behavior should remain unchanged. Proposed checks only; verify the suggestion before adoption. -
fern/versions/latest/pages/orchestration/troubleshooting.mdxline 216: NOTE — Suggestion: update the status FAQ for the new commandsFailure: This answer still says no Gym command tracks status, which becomes incorrect with the newly registered command. Users entering through troubleshooting are directed away from the feature this PR adds.
Correction: Replace the paragraph with the supported workflow while retaining scheduler tools as an option:
Use `gym job status ID` for one submission, or `gym job status` for the newest submissions in this machine's index. `gym job info ID` shows directories and planned logs. See [Job Management](/main/orchestration/job-management). Slurm's `squeue` and `sacct` remain available for scheduler details.Preservation / acceptance: Static check: the FAQ no longer denies the command's existence, distinguishes live status from descriptive info, and links to the new guide at its auto-discovered bleeding-edge route. Keep scheduler tools available as an alternative; do not imply
job listreports live state. No documentation build was executed.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
marta-sd
left a comment
There was a problem hiding this comment.
Approving with some non-blocking suggestions
| ) | ||
| for record in records | ||
| ] | ||
| return _table(("ID", "SUBMITTED", "CLUSTER", "EXECUTOR", "BENCHMARKS"), rows) |
There was a problem hiding this comment.
Maybe we could re-use table printing logic we have for listing commands?
There was a problem hiding this comment.
I kept the plain one on purpose: rich.Table wraps long ids at 80 columns when piped, which breaks copy/grep of a job id. Happy to switch if you think that is not worth it.
…cutor Adds connection_key, query_states, terminate and stream_logs, which raise UnsupportedOperationError until an executor implements them, the optional read_run_files and read_progress with defaults, and log_sources, which reads the planned sources from the record. They are not abstract so that executors that only submit keep working. Co-Authored-By: Claude Opus 4.7 <[email protected]> Signed-off-by: Tomasz Grzegorzek <[email protected]>
…cutor Adds status, info, cancel, cancel_submission and logs to BaseExecutor with their contracts, and the JobInfo and BenchmarkInfo types info returns. Their bodies land with the logic in the following changes; cancel_submission takes its confirmation as a required keyword so a whole submission is never cancelled by accident. Signed-off-by: Tomasz Grzegorzek <[email protected]>
…lities BaseExecutor now requires only run. Resubmit, status, cancel and logs are opt-in capability interfaces (Resubmittable, Inspectable, Terminable, LogReadable) in executors/capabilities.py, with every method abstract so a capability cannot be half implemented. The job operations move off the executor into functions in operations.py that take an executor typed as the capability they need and import no executor module; a test enforces that. Slurm is Resubmittable; Kubernetes drops its raising resubmit stub and submit.resubmit reports the missing capability through require. Signed-off-by: Tomasz Grzegorzek <[email protected]>
BaseExecutor no longer imports BenchmarkJob, and the Kubernetes executor no longer imports UnsupportedOperationError; neither was a name the module defined. Signed-off-by: Tomasz Grzegorzek <[email protected]>
…pability Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
Signed-off-by: Tomasz Grzegorzek <[email protected]>
…module The stats file path added on main uses LOGS_DIRNAME, which the log path helper had made unused here. Signed-off-by: Tomasz Grzegorzek <[email protected]>
status groups the records by connection and asks each connection once, all connections at the same time, then reconciles what the executor reports with the files the job wrote: a chain that stopped early or the exit code of the run decides a finished job, and a cancelled job is never overridden. A connection that fails makes its jobs UNKNOWN and hides nothing else. info describes a submission with the job ids observed and its resolved config. Also adds the local-index lister and ObservedStatus.job_ids. Signed-off-by: Tomasz Grzegorzek <[email protected]>
SlurmExecutor is Inspectable: one script per host runs a single squeue for the whole batch and a single sacct over every job id any of them has had, and reads each job directory's state files. Jobs are found by the directory they run in, compared as the same file, so resumed jobs, jobs started by hand and symlinked directories are still seen. Signed-off-by: Tomasz Grzegorzek <[email protected]>
gym job list reads this machine's job index and never touches the network; gym job status is the only command that asks the scheduler, for the given ids or the newest submissions; gym job info describes one submission and where its parts are. Documented in a new Job Management page. Signed-off-by: Tomasz Grzegorzek <[email protected]>
The functions that turn data into the text a person reads now live in job_render.py and import nothing that talks to a scheduler; a test checks that. job.py keeps the commands, which call the dispatch layer, prompt and set exit codes. Signed-off-by: Tomasz Grzegorzek <[email protected]>
… detector Signed-off-by: Tomasz Grzegorzek <[email protected]>
Slurm status: name the answer kinds, never let an old accounting row stand in for a failed queue query or a missing newest job, and drop a state file that could not be read instead of reporting it empty. Skip index files that are valid JSON but not a record. CLI: keep a multi-line detail in its table row, count only matching submissions in the pagination note, name the command in the override error, and move the clean-exit handling into a decorator next to the config-error one. Update the status FAQ. Signed-off-by: Tomasz Grzegorzek <[email protected]>
…ion group unknown Signed-off-by: Tomasz Grzegorzek <[email protected]>
…tion package Signed-off-by: Tomasz Grzegorzek <[email protected]>
fbfc988 to
bb42d3a
Compare
|
/ok to test bb42d3a |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44494132889 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/44497330925 |
Summary
Stacked on #5295: this branch is based on
prokotg/gym-job-foundation, so the diff shows only this PR. I retarget it tomainwhen #5295 merges.gym job list,statusandinfo.listreads this machine's job index and never touches the network.statusis the only command that asks the scheduler, for the given ids or the newest submissions.infodescribes one submission and where its parts are.statusandinfooperations (operations.py).statusgroups records byconnection_keyand asks each connection once, all connections at the same time. A connection that fails makes its jobsUNKNOWNand hides nothing else. The executor's state is then reconciled with the files the job wrote (below).Inspectable(slurm_status.py). One script per host runs a singlesqueue --me --allfor the whole batch, a singlesacct -jover every job id any of them has had, and reads each job directory's state files. Jobs are found by the directory they run in, compared as the same file (-ef), so a resumed job, a job started by hand and a symlinked directory are still seen.ObservedStatus.job_ids(every job id seen, soinfocan show a chain without knowing any executor's files),jobs.list_submissions, and the two state-file names as constants injobs.py.cli/job_render.py, which imports nothing that talks to a scheduler (a test checks it).cli/job.pykeeps the commands.Reconciliation, in this order: an active state stands; otherwise
.gym_chain_incompletemakes the jobFAILEDwith the reason the job wrote; otherwiseeval.exitdecidesSUCCEEDEDorFAILED; otherwise the executor's state stands.CANCELLEDis never overridden, because a file left by an earlier attempt would mask a cancel. Roll-up per submission: running wins, then queued, failed, cancelled; only all-succeeded succeeds.PR plan
Five PRs, Slurm only. Goal: status, cancel and logs for a submitted run without going to the scheduler.
statusandinfo, SlurmInspectable,gym job list,status,info.gym job cancelandgym job logs(--tail): the logic ofcancel,cancel_submissionandlogs, SlurmTerminableandLogReadable.gym eval submittells you what to type next.gym job resubmit;gym eval resubmitstays as a deprecated alias until 2026-11-23, with a test that fails then.What it prints
That is real output of the CLI over a job index and job directories, with stand-ins for
squeueandsacct.statustakes several ids;--benchmarkis strict with ids and a selector without;--jsonprints the same data.Validation
squeueandsacct(same-file matching through a symlink, onesqueueand onesacctfor a whole batch, state files with quotes and newlines,squeueorsacctfailing, a job directory with spaces and quotes, a non-numeric recorded id never reaching the script). The CLI is driven throughmain()and its whole stdout is parsed as JSON.eval submitandgym jobCLIs): 836 passed, 3 failed. All 3 also fail on cleanmainon macOS (two use GNUsed -i;test_memory_profiler_uses_spawned_server_metadata).origin/main(sandbox, docker compose, harbor,super35launcher, CI-environment, telemetry, theopensandboxSlurm-eval tests, and thesedtests above).ruffand pre-commit pass.Known gaps
squeue --me --all --noheader --format='%i|%T|%Z'andsacct -j IDS -X -P -n -o JobID,State,ExitCode; if a cluster hassacctdisabled, a finished job readsUNKNOWNunless its files say how it ended.eval.exitis written by the export wrapper, which is not onmain; without it a finished job takes the scheduler's verdict.progressis not reported yet.statusandinfofail withUnsupportedOperationError.cancel,cancel_submissionandlogsare still declared only.Rollout evidence
N/A: no agent, verifier or model behavior is touched; the commands only read.