protomotions.utils.config_utils module¶
- protomotions.utils.config_utils.import_experiment_relative_eval_overrides(relative_experiment_path)[source]¶
Dynamically import and return the apply_inference_overrides function from an experiment module.
This utility uses Python’s inspect module to determine the caller’s directory and loads an experiment module relative to that location. This allows evaluation scripts to import their corresponding training experiment’s eval override function without hardcoding paths.
- Parameters:
relative_experiment_path (str) – Path to the experiment module relative to the caller’s directory. E.g., “mlp.py” if in the same directory, or “../other/experiment.py”
- Returns:
The apply_inference_overrides callable from the loaded experiment module.
- Raises:
AttributeError – If the loaded module doesn’t have an apply_inference_overrides function.
FileNotFoundError – If the experiment module file doesn’t exist.
ImportError – If the module cannot be loaded or executed.
- Return type:
Example
# In examples/experiments/mimic/mlp_deploy.py apply_inference_overrides = import_experiment_relative_eval_overrides(“mlp.py”) # This loads apply_inference_overrides from examples/experiments/mimic/mlp.py
- protomotions.utils.config_utils.apply_config_overrides(overrides, env_config, simulator_config, robot_config, agent_config=None, terrain_config=None, motion_lib_config=None, scene_lib_config=None)[source]¶
Apply configuration overrides to config objects.
This is a general-purpose utility that works for both training and evaluation. Overrides are specified in dot notation: “env.field.subfield”: value. Supports both object attribute access and dictionary key access for nested paths. Raises ValueError if any override fails (field not found or invalid).
- Parameters:
overrides (Dict[str, Any]) – Dictionary of overrides to apply. Format is {“config_type.field.subfield”: value, …}
env_config – Environment configuration to modify in-place
simulator_config – Simulator configuration to modify in-place
robot_config – Robot configuration to modify in-place
agent_config – Optional agent configuration to modify in-place
terrain_config – Optional terrain configuration to modify in-place
motion_lib_config – Optional motion library configuration to modify in-place
scene_lib_config – Optional scene library configuration to modify in-place
- Supported config types:
‘env’: Environment config
‘simulator’: Simulator config
‘robot’: Robot config
‘agent’: Agent config (training only)
‘terrain’: Terrain config
‘motion_lib’: Motion library config
‘scene_lib’: Scene library config
- Raises:
ValueError – If override key is invalid or field not found (prevents typos)
Example:
apply_config_overrides( { "env.max_episode_length": 1000, "simulator.num_envs": 4096, "env.reward_config.pow_rew.weight": 2e-6, # dict key access "terrain.horizontal_scale": 0.1, }, env_config, simulator_config, robot_config, terrain_config=terrain_config )
- protomotions.utils.config_utils.parse_cli_overrides(override_strings)[source]¶
Parse command-line override strings into a dictionary.
Supports the format: “key=value” where value can be: - Numbers: “env.max_episode_length=1000” - Floats: “agent.learning_rate=1e-5” - Booleans: “env.enable_terrain=True” - Strings: “env.terrain.type=flat” - None: “env.early_termination=None”
- Parameters:
override_strings (list) – List of “key=value” strings
- Returns:
Dictionary of parsed overrides
- Return type:
Example
parse_cli_overrides([“env.max_episode_length=1000”, “simulator.num_envs=4096”]) # Returns: {“env.max_episode_length”: 1000, “simulator.num_envs”: 4096}