module moplayground.config
Single access point between YAML config files and the moplayground package.
This is the only module that knows YAML key names. Scripts call :func:load to read a config, then use the getter functions to pull plain values out of it and pass those values to package functions. Package code never indexes a config directly.
Canonical layout:
name, save_dir, description, algorithm, env, backend, gaitlib_path env_config: {...} learning_params: ppo_params: {learning_rate, num_envs, ...} sampling_params: {alpha, k, sampling, warmup_frac} morlax_params: {hypertype, hypersize, num_features, policy_hidden_layer_sizes, value_hidden_layer_sizes} amor_params: {policy_hidden_layer_sizes, value_hidden_layer_sizes} morlax_warmup_params: {enabled, policy}
:func:load renames keys from older layouts to the canonical layout, so saved config.yaml files from old runs still load.
Global Variables
- ALGORITHMS
- ENVS
- SAMPLING_MODES
- HYPERTYPES
function load
load(path) → ConfigDict
Read a YAML config, convert it to the canonical layout, and validate it.
Args:
path: Path to a YAML config file. Either a file inconfig/or aconfig.yamlsaved in a run directory.
Returns:
ConfigDict in the canonical layout.
Raises:
ValueError: If the config fails validation. The message lists every problem found.
function save
save(cfg, run_dir, warn_github_changes=True) → Path
Create run_dir and write config.yaml into it.
A run named test may reuse an existing run_dir and does not record a git hash. Any other name raises if run_dir already exists, and records the current git hash as cfg.git_hash.
Args:
cfg: Config returned by :func:load. Modified in place (git_hash).run_dir: Run directory, normally :func:run_dirofcfg.warn_github_changes: Forwarded to the git-hash lookup.
Returns:
Path to the written config.yaml.
function algorithm
algorithm(cfg) → str
'morlax' or 'amor'.
function env_name
env_name(cfg) → str
Environment class name, e.g. 'MOCheetah'.
function backend
backend(cfg, for_training=False) → str
'jnp' when building an env for training, else the configured backend.
function env_params
env_params(cfg) → ConfigDict
The env_config section, given to env classes as env_params.
function gaitlib_path
gaitlib_path(cfg)
Gait library path (NaviGait only), or None.
function ppo_params
ppo_params(cfg) → dict
PPO settings shared by both algorithms.
function sampling_params
sampling_params(cfg) → dict
Preference-sampling settings: alpha, k, sampling, warmup_frac.
function network_params
network_params(cfg) → dict
Network settings for the configured algorithm.
function normalize_observations
normalize_observations(cfg) → bool
Whether training keeps a running observation normalizer.
function objectives
objectives(cfg) → list
Reward keys per objective, one list per reward dimension.
function num_objectives
num_objectives(cfg) → int
Number of objectives (length of the reward vector).
function objective_labels
objective_labels(cfg)
Display names for the objectives, or None if not set.
function run_name
run_name(cfg) → str
Run name.
function run_dir
run_dir(cfg) → Path
Run directory: save_dir / name.
function check_same_env
check_same_env(cfgs)
Raise ValueError unless every config deploys the same environment.
Compares env and the full env_config section. Use this before evaluating several runs together (e.g. eval.pareto.get_morlax_fronts with a list of run directories).
function set_name
set_name(cfg, value)
function set_hypertype
set_hypertype(cfg, value)
function set_sampling
set_sampling(cfg, value)
function set_k
set_k(cfg, value)
function apply_overrides
apply_overrides(cfg, overrides, where='overrides')
Write each value in a nested dict into cfg at the same key path.
overrides mirrors the config layout, e.g. {'learning_params': {'ppo_params': {'learning_rate': 3e-4}}}. A wandb sweep with nested parameters gives its sampled values in this form.
Args:
cfg: Config returned by :func:load. Modified in place.overrides: Nested dict of values to write.where: Name foroverridesin error messages.
Raises:
ValueError: If a key path inoverridesdoes not exist incfg(e.g. a typo in a sweep file), or if the result fails validation.