statusing
¶
Step
module-attribute
¶
Step = Literal['pending', 'generating', 'solving', 'done']
Steps a trial can have
-
Code 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.
JobType
¶
Bases: StrEnum
Which mujoco-mojo run subcommand (or the reloaded viewer) produced a job.
-
Code 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 optimize 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.
-
Code Reference
mujoco_mojoutilsstatusingJobStatusexecution_mode
-
Code Reference
mujoco_mojoutils
LOCAL
class-attribute
instance-attribute
¶
Trials run as local processes/threads on the machine that launched the job.
-
Code Reference
mujoco_mojoutils
SLURM
class-attribute
instance-attribute
¶
Trials are submitted as SLURM jobs to a cluster scheduler.
Completion
¶
Bases: StrEnum
How a trial ended, from "still running" through the different ways it can finish.
-
Code Reference
mujoco_mojoutilsstatusingTrialStatuscompletion
-
Code Reference
mujoco_mojoutilsstatusingJobStatusget_trial_nums_with_status
INCOMPLETE
class-attribute
instance-attribute
¶
Neither completed nor failed. Indicates the process is ongoing.
-
Code Reference
mujoco_mojoutilsstatusingTrialStatuscompletion
SUCCESS
class-attribute
instance-attribute
¶
Completed successfully; all requirements passed (or none were registered).
FAILURE
class-attribute
instance-attribute
¶
Completed without exceptions but one or more requirements failed.
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.
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.
-
Code 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
-
Code Reference
mujoco_mojoutilsstatusingTrialStatus
-
Code 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.
-
Code Reference
mujoco_mojoutils
-
Code 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.
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.
-
Code Reference
mujoco_mojoutils
-
Code Reference
mujoco_mojoutilslayers
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.
start_time
class-attribute
instance-attribute
¶
Initial start time of the job.
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.
gen_args_used
instance-attribute
¶
gen_args_used: bool
Whether or not *args were used for the generator.
gen_kwargs_used
instance-attribute
¶
gen_kwargs_used: bool
Whether or not **kwargs were used for the generator.
run_args_used
instance-attribute
¶
run_args_used: bool
Whether or not *args were used for the runtime.
run_kwargs_used
instance-attribute
¶
run_kwargs_used: bool
Whether or not **kwargs were used for the runtime.
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.
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,
) -> 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
|
Source code in src/mujoco_mojo/utils/statusing.py
| Python | |
|---|---|
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | |
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 that is still INCOMPLETE but has begun generating or solving counts as "running" from that start time onward rather than "pending"; claimed-but-not-yet-started trials (only pending.started set) still 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 by that time; everything else is pending.
Source code in src/mujoco_mojo/utils/statusing.py
to_monitor_json
¶
Returns a lightweight summary optimized for the Alpine.js dashboard.