settings
¶
Global user settings for mujoco_mojo, persisted to ~/.mujoco-mojo/settings.toml.
PROJECT_SETTINGS_DIR_NAME
module-attribute
¶
Name of the directory, at the root of a project, that holds its project-local files. The settings live in .mujoco-mojo/settings.toml, and the directory is the place for any other project-local file added later.
DEFAULT_MAX_REQUESTS
module-attribute
¶
The default of dojo.sensai.max_requests.
DEFAULT_MAX_VERSUS_TRIALS
module-attribute
¶
The default of dojo.sensai.max_versus_trials.
SlurmSettingsSource
dataclass
¶
SlurmSettingsSource(
label: str,
path: Path,
exists: bool,
entries: dict[str, Any] = dict(),
error: str | None = None,
)
One settings file that can contribute [slurm] entries.
-
Reference
mujoco_mojosettingsslurm_settings_sources
entries
class-attribute
instance-attribute
¶
The raw [slurm] entries this file defines, empty if it has none or couldn't be read.
VisualizationSettings
¶
Bases: BaseModel
Colors for force, torque, contact, and proximity overlays rendered during simulation.
SensAIModelEntry
¶
Bases: BaseModel
One entry in SensAISettings.models - a provider paired with that provider's own model identifier.
SensAISettings
¶
Bases: BaseModel
Settings for the SensAI assistant embedded in the Dojo dashboard.
-
Reference
mujoco_mojoutilslayersdojorouterssensaipost_config
SlurmExtraSettings
¶
GeneralSettings
¶
Bases: BaseModel
General-purpose defaults shared across mujoco-mojo's CLI commands, plus asset-bundling behavior.
ReloadedKeySettings
¶
Bases: BaseModel
Keyboard shortcuts of the Reloaded terminal UI. Each action takes a list of Textual key names such as f2 or ctrl+g, and the first one is shown in the footer.
-
Reference
mujoco_mojoutilslayersreloaded
ReloadedStudioSettings
¶
Bases: BaseModel
Which parts of MuJoCo Studio show when it opens, as Studio's own show_ options, which its View menu still toggles. Not used by the opengl viewer. The defaults are Studio's own.
-
Reference
mujoco_mojoutilslayersreloaded
MonteCarloRunSettings
¶
Bases: _RunDefaults
Settings for mujoco-mojo run monte-carlo.
SingleRunSettings
¶
Bases: _RunDefaults
Settings for mujoco-mojo run single.
OptimizeRunSettings
¶
Bases: _RunDefaults
Settings for mujoco-mojo run optimization.
GenerateJsonSchemaWithDefaults
¶
Bases: GenerateJsonSchema
Appends each field's default value to its description, so editors that only surface description on hover (e.g. VS Code's Even Better TOML) still show it, without hand-duplicating every Field(default=...) into its own description text.
Also attaches an x-enum-descriptions extension (value -> that member's own attribute-docstring, via _enum_value_descriptions above) to every enum schema - generic to any StrEnum with attribute-docstring'd members, not specific to whichever model happens to use this generator, so a consumer like the Dojo settings panel and PlotConfig's Plot Editor/JSON editor tooltips (dojo/plot_config.py) both get per-dropdown-option descriptions for free from the same one generator, rather than each redefining this behavior in its own subclass.
get_default_value
¶
get_default_value(schema: WithDefaultSchema) -> Any
Pydantic's own default implementation only ever surfaces a static default=, never a default_factory= result, since a factory could be expensive or side-effecting. Every default_factory actually used across this codebase (dict, list, lambda: SlurmExtraSettings({}), and the nested settings-group constructors) is cheap and side-effect-free, so calling it here is safe, and it's what lets _append_defaults below show a real "Default: ..." for fields like PlotConfig.y_axes/annotations/shapes that would otherwise silently show none.
Source code in src/mujoco_mojo/settings.py
MujocoMojoSettings
¶
Bases: BaseSettings
Global user-level settings persisted to ~/.mujoco-mojo/settings.toml, layered with an optional project-local override file, found by searching the current directory and its parents - the same User-settings-vs-Workspace-settings model VS Code uses.
Instantiate to load. Sources are checked in priority order: constructor kwargs > environment variables > .env file (env_file in model_config) > project settings file (project_settings_file(), the nearest .mujoco-mojo/settings.toml in the current directory or a parent) > global settings file (~/.mujoco-mojo/settings.toml) > defaults. Every field can be overridden at the project level, not just a specific subset - a project file is expected to hold only the handful of keys that genuinely differ from the global defaults (e.g. per-project SLURM extras or force-scaling), not a full copy. Environment variables (real ones and .env entries alike) use the prefix MUJOCO_MOJO_ with __ as the nested delimiter, e.g. MUJOCO_MOJO_DOJO__SENSAI__MODEL_NAME=llama3.2:3b.
-
Reference
mujoco_mojosettingsMujocoMojoSettingsdefaults
defaults
classmethod
¶
defaults() -> MujocoMojoSettings
Builds a fresh instance from pure code-level defaults, ignoring environment variables and any existing settings.toml.
A constructor kwarg left unset resolves against this class's other settings sources (env vars, then the TOML file) rather than the field's own default - that layering is the entire reason BaseSettings exists - so every field's default must be passed explicitly here to get a true reset. Iterating model_fields rather than hand-listing field names means a newly added settings field is automatically covered, with nothing to remember to update.
Returns:
| Type | Description |
|---|---|
MujocoMojoSettings
|
A |
Source code in src/mujoco_mojo/settings.py
set_project_value
classmethod
¶
Sets a single dotted-path setting (e.g. "assets.symlink") in the project-local settings file, creating any intermediate tables as needed, without touching anything else already there.
key.split(".") is ambiguous for a free-form group like slurm (a RootModel[dict[str, ...]]), whose own keys legitimately contain literal dots (e.g. "sbatch.account") - "slurm.sbatch.account" must set that one flat key, not descend two more table levels. Resolved by walking the declared field types (not the current data) until a RootModel field is reached; everything after that point is rejoined into a single literal key instead of split further.
Validated by overlaying the new value onto the full currently-effective settings (project + global + env + defaults) and calling model_validate on the result - model_config forbids extra fields on every fixed-shape settings group, so a typo'd leaf and a wrong-typed value both raise pydantic.ValidationError before anything is written. The validated and re-dumped leaf value is what actually gets persisted, not the raw value argument, so e.g. the CLI's loosely-typed input string "true" for a bool field is written to TOML as a real boolean, not a quoted string. Only that one changed leaf is written into the project file, keeping it a small, deliberate diff rather than a full mirror of every setting - contrast with save(), which always persists every field (correct for the global file, wrong here).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Dotted path, e.g. "dojo.sensai.max_requests", "assets.symlink", or "slurm.sbatch.account". |
required |
value
|
Any
|
The value to set, already parsed to its target Python type. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The project settings file that was written: the one found by searching the current directory and its parents, or a new one in the current directory if there wasn't one. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If an intermediate segment of |
ValidationError
|
If the resulting settings are invalid (unknown leaf, wrong type, etc.). |
Source code in src/mujoco_mojo/settings.py
| Python | |
|---|---|
1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 | |
save
¶
Persist settings to directory (defaults to the global settings directory, ~/.mujoco-mojo), alongside a freshly (re)generated settings.schema.json/.taplo.toml pair (see write_schema_files) - one method covers both the global settings file and a project-local override file, so there's no separate init_project_file-style method to keep in sync with this one.
project=False (the default - the global file): every field's current value is merged into settings.toml with tomlkit, preserving any comments or formatting added by hand. A key that exists in the file but no longer has a corresponding settings value (e.g. a removed slurm entry) is left as-is rather than deleted.
project=True (for a project's .mujoco-mojo/settings.toml): self's field values are never written - a project file is meant to hold only a small, deliberate diff from the global defaults, not a full mirror of every setting (see set_project_value) - so an existing file's contents are left completely untouched, and a fresh one gets just the #:schema header. Also drops a .gitignore (*) next to it if one isn't already there, so a project's local overrides - which may be machine-specific - don't get committed by accident.
Either way, a brand-new file starts with a #:schema header pointing at the colocated settings.schema.json - a bare relative filename, resolved by taplo against the TOML file's own directory, rather than a cross-directory reference to another directory's schema. The latter is what broke under SSH/SSHFS-style setups where only one of the two directories was visible to the editor - every settings directory is now self-contained. An existing file that's missing that header (written before schema support existed, or hand-edited to drop the line) gets it prepended on the next save too, except for the already-exists project-file case just above, which skips reading the file at all.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Path | None
|
Where to write |
None
|
project
|
bool
|
Write the sparse project-local form described above instead of the full global one. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
The |
Source code in src/mujoco_mojo/settings.py
write_schema_files
classmethod
¶
write_schema_files(directory: Path | None = None) -> None
Writes settings.schema.json and a companion .taplo.toml into directory, so taplo-based editors (VS Code's Even Better TOML, Neovim, etc.) get hover hints and validation for whatever settings.toml lives there. Safe to re-run any time, e.g. after upgrading mujoco-mojo changes the settings shape.
The schema and taplo config are always colocated with the settings.toml they describe, rather than one directory's file referencing another's schema by absolute path - that cross-directory reference is exactly what broke under SSH/SSHFS-style setups where only one of the two directories (typically just the project one) is visible to the editor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
directory
|
Path | None
|
Where to write |
None
|
Source code in src/mujoco_mojo/settings.py
find_project_settings_file
¶
Searches start (default: the current directory) and then each parent directory for a project settings file, .mujoco-mojo/settings.toml, the way uv looks for its own configuration.
The nearest file wins and the search stops there: files in further parent directories are not merged in. The global settings directory (~/.mujoco-mojo) is skipped, since it holds the global settings and would otherwise be found as the "project" of anything under the home directory. A directory that cannot be read counts as not having a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
Path | None
|
Directory to start from. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
Path | None
|
The nearest project settings file, or |
Source code in src/mujoco_mojo/settings.py
project_settings_file
¶
project_settings_file() -> Path
Path to the project-local settings file in effect: the nearest .mujoco-mojo/settings.toml found by searching the current directory and its parents (see find_project_settings_file).
If there isn't one, this is the file that would be created for the current directory, <cwd>/.mujoco-mojo/settings.toml, which is where settings set --project writes first.
Returns:
| Type | Description |
|---|---|
Path
|
The discovered file, or |
Source code in src/mujoco_mojo/settings.py
slurm_settings_sources
¶
slurm_settings_sources() -> list[SlurmSettingsSource]
The settings files that can contribute [slurm] entries, lowest priority first (global, then project), each read on its own.
MujocoMojoSettings().slurm only has the merged result, which hides a project file that wasn't found, since the project file is looked up relative to the current directory. This reports each file separately so a submission can say where it looked and what each one contributed.
Source code in src/mujoco_mojo/settings.py
default_user_interface
¶
default_user_interface() -> UserInterface
The viewer for this machine: Studio in a browser where this MuJoCo build can serve it, and the classic OpenGL window where it cannot. The native Studio window is never chosen automatically, but studio can still be set.