watching
¶
Keeps a job's status file and runtime report current while other processes run its trials.
WatchOutcome
¶
watch_job
¶
watch_job(
workdir: Path,
*,
interval: float = 10.0,
n_proc: int = 1,
console: Console | None = None,
sleep: Callable[[float], None] = sleep,
) -> WatchOutcome
Keeps a job's job_status.json and runtime report current until its trials are done.
This is for jobs whose trials are run by other processes, such as the array tasks of a SLURM job. Those write only their own trial's status, and nothing else writes the job-level file, so without this it stays exactly as it was at submission (no elapsed time, no trial durations) and the report is never written. Every interval seconds this reads the trials' status files, saves the refreshed job status, and rewrites the report when the number of finished trials changed. The job's start time is moved forward to when its first trial began, since the job file is created when the wizard starts, which can be long before the job is submitted or any trial runs; the time a job spends waiting in the queue is therefore not counted. It returns when every trial is done, or, for a job submitted to SLURM by Mojo, when SLURM no longer has the job; either way the final report, with its alerts, is written.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workdir
|
Path
|
The job's workdir, which holds |
required |
interval
|
float
|
Seconds between passes. |
10.0
|
n_proc
|
int
|
Threads used to read trial status files. |
1
|
console
|
Console | None
|
Where to print progress. Nothing is printed without one. |
None
|
sleep
|
Callable[[float], None]
|
How to wait between passes; replaceable so tests need not wait. |
sleep
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the workdir has no |