|
5 | 5 |
|
6 | 6 | """Sub-module with utilities for parsing and loading configurations."""
|
7 | 7 |
|
8 |
| - |
| 8 | +import collections |
9 | 9 | import gymnasium as gym
|
10 | 10 | import importlib
|
11 | 11 | import inspect
|
@@ -55,9 +55,27 @@ def load_cfg_from_registry(task_name: str, entry_point_key: str) -> dict | objec
|
55 | 55 | cfg_entry_point = gym.spec(task_name.split(":")[-1]).kwargs.get(entry_point_key)
|
56 | 56 | # check if entry point exists
|
57 | 57 | if cfg_entry_point is None:
|
| 58 | + # get existing agents and algorithms |
| 59 | + agents = collections.defaultdict(list) |
| 60 | + for k in gym.spec(task_name.split(":")[-1]).kwargs: |
| 61 | + if k.endswith("_cfg_entry_point") and k != "env_cfg_entry_point": |
| 62 | + spec = ( |
| 63 | + k.replace("_cfg_entry_point", "") |
| 64 | + .replace("rl_games", "rl-games") |
| 65 | + .replace("rsl_rl", "rsl-rl") |
| 66 | + .split("_") |
| 67 | + ) |
| 68 | + agent = spec[0].replace("-", "_") |
| 69 | + algorithms = [item.upper() for item in (spec[1:] if len(spec) > 1 else ["PPO"])] |
| 70 | + agents[agent].extend(algorithms) |
| 71 | + msg = "\nExisting RL library (and algorithms) config entry points: " |
| 72 | + for agent, algorithms in agents.items(): |
| 73 | + msg += f"\n |-- {agent}: {', '.join(algorithms)}" |
| 74 | + # raise error |
58 | 75 | raise ValueError(
|
59 | 76 | f"Could not find configuration for the environment: '{task_name}'."
|
60 |
| - f" Please check that the gym registry has the entry point: '{entry_point_key}'." |
| 77 | + f"\nPlease check that the gym registry has the entry point: '{entry_point_key}'." |
| 78 | + f"{msg if agents else ''}" |
61 | 79 | )
|
62 | 80 | # parse the default config file
|
63 | 81 | if isinstance(cfg_entry_point, str) and cfg_entry_point.endswith(".yaml"):
|
|
0 commit comments