session
¶
MojoReloaded
dataclass
¶
MojoReloaded(
generator: str | None,
runtime: str | None,
workdir: Path,
ui: UserInterface,
overrides_path: Path | None,
config_path: Path | None,
trial_num: int,
seed: int | None,
model_config_name: str | None,
xml_name: str,
args: list[Any],
kwargs: dict[str, Any],
port: int | None,
gfx: StudioGraphics = DEFAULT,
watch: bool = False,
record: bool = False,
keys: ReloadedKeySettings = ReloadedKeySettings(),
studio: ReloadedStudioSettings = ReloadedStudioSettings(),
_sync_hook: SyncHook | None = None,
_viewer_lock: Callable[[], AbstractContextManager[Any]]
| None = None,
playback_speed: float = 1.0,
_current_trial_dir: Path | None = None,
_job_status: JobStatus | None = None,
stop_event: Event = Event(),
run_control: RunControl = RunControl(),
output_sink: Callable[[str], None] | None = None,
)
A reloaded session: regenerates the model on command, runs the runtime on it, and shows it in a viewer while the terminal UI controls it.
generator
instance-attribute
¶
generator: str | None
Import path of the generate function, such as sim.Experiment.generate. Mutually exclusive with config_path.
runtime
instance-attribute
¶
runtime: str | None
Import path of the runtime function to run on the generated model, or None to only generate.
workdir
instance-attribute
¶
workdir: Path
Workspace directory that the trial folders and the job status are written to.
ui
instance-attribute
¶
ui: UserInterface
Which viewer shows the model: the classic opengl window, a native studio window, or web for Studio in a browser.
overrides_path
instance-attribute
¶
overrides_path: Path | None
A JSON file of NamedValue overrides applied to the generated model, or None for no overrides.
config_path
instance-attribute
¶
config_path: Path | None
A saved model_config.json to load instead of calling a generator. Its seed and trial number replace seed and trial_num, and its folder becomes the workdir when that is still the default.
seed
instance-attribute
¶
seed: int | None
The seed that the random draws are tied to, or None when no seed was given.
model_config_name
instance-attribute
¶
model_config_name: str | None
File name the model's config is saved under in each trial folder, or None to not save it.
xml_name
instance-attribute
¶
xml_name: str
File name the generated MJCF is written to in each trial folder.
args
instance-attribute
¶
Positional arguments (--arg) passed to the generator and the runtime after the ones Mojo passes itself.
kwargs
instance-attribute
¶
Keyword arguments (--kwarg) passed to the generator and the runtime, each receiving only the ones it accepts.
port
instance-attribute
¶
port: int | None
The first port to try for the browser viewer, or None to start from the viewer's default. Only web uses it.
gfx
class-attribute
instance-attribute
¶
gfx: StudioGraphics = DEFAULT
How the native Studio window is drawn. The web and opengl viewers ignore it.
watch
class-attribute
instance-attribute
¶
watch: bool = False
Whether saving a *.py file reloads with the last command. The watch command turns it on and off during the session.
record
class-attribute
instance-attribute
¶
record: bool = False
Whether telemetry is recorded to each trial's telemetry.parquet and video recorders capture frames. The record command turns it on and off during the session.
keys
class-attribute
instance-attribute
¶
keys: ReloadedKeySettings = field(
default_factory=ReloadedKeySettings
)
The keys that trigger the terminal UI's actions, from the reloaded.keys settings.
studio
class-attribute
instance-attribute
¶
studio: ReloadedStudioSettings = field(
default_factory=ReloadedStudioSettings
)
Which parts of Studio are showing when it opens, from the reloaded.studio settings.
playback_speed
class-attribute
instance-attribute
¶
playback_speed: float = 1.0
Speed handed to each run's RuntimeManager: 1 is real time, 0 waits at every step, and inf runs as fast as it can.
stop_event
class-attribute
instance-attribute
¶
Set to abort the run in progress. Handed to every RuntimeManager this session creates.
run_control
class-attribute
instance-attribute
¶
run_control: RunControl = field(default_factory=RunControl)
How the interface pauses, steps, and changes the speed of a run in progress. Handed to every RuntimeManager this session creates.
output_sink
class-attribute
instance-attribute
¶
When set, messages that would be printed to the terminal are passed to this callable as rich markup strings instead. The terminal UI uses it to show them in its log pane.
trial_dir_for
¶
Per-trial output directory, mirroring the layout Trial/MojoRunner use.
Keeping this layout lets mujoco-mojo dojo discover and plot reloaded runs the same way it discovers Monte Carlo / Optimize trials.
Source code in src/mujoco_mojo/utils/layers/reloaded/session.py
generate_construct
¶
generate_construct(
use_runtime: bool,
on_reload_callback: OnReloadCallback | None,
) -> MjState
Helper to run a generation.
Source code in src/mujoco_mojo/utils/layers/reloaded/session.py
| Python | |
|---|---|
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 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 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 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 | |
recursive_reload
¶
recursive_reload(
module,
project_root: Path,
visited: set[ModuleType] | None = None,
) -> None
Recursively reloads modules, but only if they live inside project_root.