statusing
¶
Step
module-attribute
¶
Step = Literal['pending', 'generating', 'solving', 'done']
Steps a trial can have
-
Reference
mujoco_mojoutilsstatusingTrialStatusstep
TRIAL_STATUS_FNAME
module-attribute
¶
Filename of trial status files.
JOB_STATUS_FNAME
module-attribute
¶
Filename of job status files.
REQUIREMENTS_FNAME
module-attribute
¶
Filename of per-trial requirement result files.
FAILED_COMPLETIONS
module-attribute
¶
FAILED_COMPLETIONS = {FAILURE, TERMINATED}
Completion states counted as requirement failures (the trial ran, but requirements were not met).
-
Reference
mujoco_mojoutilsstatusingTIMED_COMPLETIONS
TIMED_COMPLETIONS
module-attribute
¶
TIMED_COMPLETIONS = {SUCCESS} | FAILED_COMPLETIONS
Completion states whose durations feed average_trial_duration and throughput estimates. Errored trials are excluded because a run that crashed (possibly instantly) says nothing about how long a real trial takes.
JobType
¶
Bases: StrEnum
Which mujoco-mojo run subcommand (or the reloaded viewer) produced a job.
-
Reference
mujoco_mojoutilsstatusingJobStatusjob_type
MONTE_CARLO
class-attribute
instance-attribute
¶
A mujoco-mojo run monte-carlo job: many trials sampled from randomized parameters.
OPTIMIZE
class-attribute
instance-attribute
¶
A mujoco-mojo run optimization job: trials driven by a parameter search/optimizer.
RELOADED
class-attribute
instance-attribute
¶
A mujoco-mojo reloaded job: interactive live-reload viewer, not a batch of trials.
ExecutionMode
¶
Bases: StrEnum
Where a job's trials actually run.
-
Reference
mujoco_mojoutilsstatusingJobStatusexecution_mode
-
Reference
mujoco_mojoutils
Completion
¶
Bases: StrEnum
How a trial ended, from "still running" through the different ways it can finish.
- User Guide Features Requirements Checker Completion states
-
Reference
mujoco_mojoutilsstatusingTrialStatuscompletion
INCOMPLETE
class-attribute
instance-attribute
¶
Neither completed nor failed. Indicates the process is ongoing.
-
Reference
mujoco_mojoutilsstatusingTrialStatuscompletion
SUCCESS
class-attribute
instance-attribute
¶
Completed successfully; all requirements passed (or none were registered).
-
Reference
mujoco_mojoutilsstatusingTIMED_COMPLETIONS
FAILURE
class-attribute
instance-attribute
¶
Completed without exceptions but one or more requirements failed.
-
Reference
mujoco_mojoutilsstatusingFAILED_COMPLETIONS
TERMINATED
class-attribute
instance-attribute
¶
Stopped early via SimulationStopped (user request or terminating requirement). Counted as a requirement failure in job statistics, not an error.
- User Guide Features Requirements Checker Live checks Early termination On Failure
-
Reference
mujoco_mojoutilsstatusingFAILED_COMPLETIONS
ERROR
class-attribute
instance-attribute
¶
An unhandled exception was raised while processing the trial. Distinct from FAILURE: the run broke, it did not merely miss its requirements.
RequirementResult
¶
Bases: MojoBaseModel
Result of a single requirement check evaluated at the end of a trial.
-
Reference
mujoco_mojoutilsstatusingTrialStatusrequirements
message
instance-attribute
¶
message: str
Human-readable message from the requirement function.
decided_at
class-attribute
instance-attribute
¶
decided_at: float = 0.0
Simulation time at which the verdict was determined: the time of the first live failure, the time it latched, or the trial's final sim time for a plain end-of-trial verdict.
every
class-attribute
instance-attribute
¶
every: int | None = None
Live-check cadence the requirement was registered with (steps), or None if it only ran once at end-of-trial.
terminate_on_fail
class-attribute
instance-attribute
¶
terminate_on_fail: bool = False
Whether a failing live check was configured to end the simulation early.
terminate_on_pass
class-attribute
instance-attribute
¶
terminate_on_pass: bool = False
Whether a passing live check was configured to end the simulation early.
StepStatus
¶
Bases: MojoBaseModel
-
Reference
mujoco_mojoutilsstatusingTrialStatus
-
Reference
mujoco_mojoutilsstatusingTrialStatus
started
class-attribute
instance-attribute
¶
started: datetime | None = None
Time the step started.
A None value indicates the step has not begun.
TrialStatus
¶
Bases: MojoBaseModel
Persistant state of a single trial, saved to disk.
- User Guide Features Requirements Checker
-
Reference
mujoco_mojoutils
-
Reference
mujoco_mojoutilsstatusingJobStatusupdate_trial
step
class-attribute
instance-attribute
¶
step: Step = 'pending'
The current step of the trial.
completion
class-attribute
instance-attribute
¶
completion: Completion = INCOMPLETE
The overall completion type.
Included here so that the MojoRunner can set the bulk status of the job with a try-except block.
pending
class-attribute
instance-attribute
¶
pending: StepStatus = Field(
default=StepStatus(started=now(UTC))
)
Pending step.
This is not really a real "step", it is really just an indicator the MuJoCo Mojo is waiting to run this trial.
generating
class-attribute
instance-attribute
¶
generating: StepStatus = Field(default_factory=StepStatus)
Generation step.
- Information on times during which the job sequencer is generating XML (not yet running MuJoCo).
- This step must be completed before moving to
solving. - It is the first step in the sequence.
solving
class-attribute
instance-attribute
¶
solving: StepStatus = Field(default_factory=StepStatus)
Solving step.
- Information on times during which the job sequencer is running MuJoCo.
- This step is the second step in the sequence.
- Completion of the step is the end of the trial.
requirements
class-attribute
instance-attribute
¶
requirements: list[RequirementResult] = Field(
default_factory=list
)
Results of all requirement checks evaluated at the end of this trial.
requirements_passed
property
¶
requirements_passed: bool | None
True if all requirements passed, False if any failed, None if no requirements were registered.
td
property
¶
td: timedelta
The current timedelta for the trial to be completed. Incomplete steps are assumed to have 0 runtime.
JobStatus
¶
Bases: MojoBaseModel
Orchestrates the global state of a job.
This class acts as a cache and aggregator for the individual TrialStatus files on disk. It provides high-level metrics needed for dashboards and job resumption.
- User Guide Features Requirements Checker Completion states
-
Reference
mujoco_mojoutils
id
class-attribute
instance-attribute
¶
Unique identifier generated each time a job is created.
Lets the Dojo detect that job_status.json now belongs to a different run than the one it has cached in memory (e.g. the user deleted the workdir and reran their analysis), so it can discard its stale JobStatus instead of overwriting the new file with old data.
started_by
class-attribute
instance-attribute
¶
Who owns the job.
execution_mode
instance-attribute
¶
execution_mode: ExecutionMode
What execution mode the job was run with.
slurm_job_id
class-attribute
instance-attribute
¶
slurm_job_id: str | None = None
The SLURM job id the job was submitted as. Set once sbatch accepts the submission, so the job can be looked up in the scheduler later (see mujoco-mojo run watch-workdir).
start_time
class-attribute
instance-attribute
¶
Initial start time of the job. For a SLURM job watched by watch_job, it moves forward to when the job's first trial began, since the job file is created when the wizard starts, long before any trial runs.
elapsed
class-attribute
instance-attribute
¶
Time elapsed running the job.
generator
instance-attribute
¶
What generator was used. Name of runtime, Path to the runtime, and linenumber.
runtime
instance-attribute
¶
What runtime was used. Name of runtime, Path to the runtime, and linenumber.
objective
instance-attribute
¶
What objective function was used. Name of function, Path to the function, and linenumber.
args_used
class-attribute
instance-attribute
¶
Each positional argument (--arg) passed to the generator, runtime, and objective, in order. A value that is not plain JSON is recorded as its repr.
kwargs_used
class-attribute
instance-attribute
¶
Each keyword argument (--kwarg) passed to the generator, runtime, and objective, by name. A value that is not plain JSON is recorded as its repr.
trial_nums
instance-attribute
¶
The exhaustive list of trial identifiers expected for this job.
pending_trial_nums
property
¶
Returns trial numbers which are either missing or marked as incomplete.
time_remaining_wall_clock
property
¶
time_remaining_wall_clock: timedelta
Calculates the estimated time ramianing based on elapsed wall-clock time.
For simulations which were not resumed, this property is more accurate than the time_remaining_average_success property.
time_remaining_average_success
property
¶
time_remaining_average_success: timedelta
Calculates the estimated time remaining based on the average completed-trial duration (successes and requirement failures; errored trials are excluded).
For simulations which were resumed, this property is more accurate than the time_remaining_wall_clock property.
parallelism
property
¶
parallelism: float
How many trials run at once, which turns one trial's average duration into the job's throughput and time remaining.
A local run has n_proc of them. For a job whose trials are run by other processes, such as the array tasks of a SLURM job, n_proc means nothing: it is the local default unless the user happened to set it for something else, and how many tasks run at once is up to the scheduler and changes as the cluster fills and empties. So it is measured instead, as the average number of trials in flight since the job began (see _measured_parallelism), and is n_proc only until a trial has run.
failure_rate
property
¶
failure_rate: float
Fraction of done trials that failed one or more requirements.
error_rate
property
¶
error_rate: float
Fraction of done trials that raised an unhandled exception.
n_failed
property
¶
n_failed: int
Number of done trials that failed one or more requirements (FAILURE or TERMINATED). Errored trials are counted separately in n_error.
failed_trial_nums
property
¶
Trials that completed but failed one or more requirements (FAILURE or TERMINATED).
error_trial_nums
property
¶
Trials that raised an unhandled exception (ERROR).
unsuccessful_trial_nums
property
¶
Union of failed and errored trials, for anything-went-wrong checks like process exit codes.
requirement_summary
property
¶
requirement_summary: list[RequirementSummary]
Per-requirement pass/fail counts aggregated across all cached trial statuses.
n_requirements_passed
property
¶
n_requirements_passed: int
Total number of individual requirement checks that passed across all trials.
n_requirements_failed
property
¶
n_requirements_failed: int
Total number of individual requirement checks that failed across all trials.
clear_cache
¶
reload_if_new_run
¶
reload_if_new_run() -> JobStatus | None
Checks workdir/JOB_STATUS_FNAME for a run_id different from this instance's.
If the user reran their analysis (e.g. after deleting the workdir), the file on disk now belongs to a different run and this instance's cached state (trial cache, trial_nums, generator, etc.) is stale. Returns a freshly-loaded JobStatus for the new run if so, or None if the file is missing, unreadable, or still belongs to this run.
Source code in src/mujoco_mojo/utils/statusing.py
get_trial_status
¶
get_trial_status(trial_num: int) -> TrialStatus | None
Returns the cached status for a trial, or None if not yet loaded.
refresh_from_disk
¶
refresh_from_disk(
n_proc: int = 1,
progress_callback: Callable[[float], None]
| None = None,
force_refetch: bool = False,
persist: bool = True,
start_from_trials: bool = False,
) -> None
Scans the workdir to identify which trials still need execution, but only for runs not already in the cache (i.e., completed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_proc
|
int
|
Number of worker threads used to scan trial status files. |
1
|
progress_callback
|
Callable[[float], None] | None
|
Optional callback invoked with scan progress (0-100). |
None
|
force_refetch
|
bool
|
If |
False
|
persist
|
bool
|
If |
True
|
start_from_trials
|
bool
|
If |
False
|
Source code in src/mujoco_mojo/utils/statusing.py
| Python | |
|---|---|
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 | |
get_trial_nums_with_status
¶
get_trial_nums_with_status(
*status: Completion, invert: bool = False
) -> list[int]
Returns a list of trial numbers which have the provided status. If invert is True it will provide trial numbers which do not match.
Source code in src/mujoco_mojo/utils/statusing.py
update_trial
¶
update_trial(
status: TrialStatus, save: bool = True
) -> None
Updates the internal registry and average trial duration and optionally persists the global status.
Source code in src/mujoco_mojo/utils/statusing.py
completion_timeline
¶
Reconstructs cumulative outcome counts over the job's wall-clock life, for the monitor's stacked progress histogram.
Each trial's completion time is taken as the latest recorded step end (started + elapsed). A trial counts as "running" from the moment it began generating or solving until it ends, or until now if it has not ended, so a trial that has since finished still shows as running over the time it ran. Claimed-but-not-yet-started trials (only pending.started set) count as pending. The axis runs from job start to now if any trial is currently running, or to the last completion event if the job is idle/abandoned (so a stalled job doesn't render a flat tail stretching to now). For each of n_bins evenly spaced timestamps in that range, the bin reports how many trials had succeeded, failed requirements, errored, or were running at that time; everything else is pending.
Source code in src/mujoco_mojo/utils/statusing.py
| Python | |
|---|---|
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 | |
to_monitor_json
¶
Returns a lightweight summary optimized for the Alpine.js dashboard.
Source code in src/mujoco_mojo/utils/statusing.py
describe_args
¶
describe_kwargs
¶
The keyword arguments as JobStatus.kwargs_used records them.