Skip to content

Configuration and utilities

rlrom.cfg_utils is deliberately light: standard library, numpy and ruamel.yaml only. That is why rlr show and rlr plot work without the training stack installed.

load_cfg(cfg, verbose=1)

Load a configuration file, expanding its references recursively.

Values ending in .yml are replaced by that file's content, values ending in .stl by its text, and import_module is imported. The process then chdir()s to the configuration's folder (this_cfg_pathdir), so every relative path in the config resolves from there.

verbose only controls what is printed while loading: expansion always happens.

find_subcfg(cfg, key)

Return the sub-configuration selected by key.

key may be either a dot-separated path (e.g. cfg_train.a.b) or a single key name, in which case the first occurrence found at any depth is returned. Raises KeyError if nothing matches.

set_rec_cfg_field(cfg, **kargs)

Environments

rlrom.utils.make_env_from_cfg builds the environment from the configuration: it separates env_id from env_name, forwards env_kwargs, applies render_mode, and reports the family's registered ids when an id does not exist. custom_env_factory finds an example's make_env_* function through import_module.

Algorithms

The cfg_train.algo key selects from rlrom.utils.ALGO_NAMES_CLASSES, which maps names to stable-baselines3, sb3-contrib, SBX and morl-baselines classes, plus qlearning for discrete environments. Anything the chosen class accepts as a constructor keyword can be written in the algorithm block.

Results as dataframes

Training results are also available as polars dataframes, which is what the plotting code consumes: get_training_folders, get_training_res, get_df_all_trainings, get_metric_series, get_selection_df in rlrom.utils.