Skip to content

Commit 143d0ef

Browse files
committed
Fix validate_mc_scenarios error message; update load_optim_config docstring
validate_mc_scenarios was still converting indices to 1-based in its error message after the 0-based switch. Error now reports the raw 0-based indices and the correct range (0–N-1). load_optim_config docstring replaced: removes the stale 'components_path' reference and documents the two extra steps the function performs beyond plain YAML parsing (relative path resolution and eager scenario_ids population). https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
1 parent 94aa8e7 commit 143d0ef

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/gems/optim_config/parsing.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,17 @@ class OptimConfig(ModifiedBaseModel):
286286

287287

288288
def load_optim_config(config_path: Path) -> Optional[OptimConfig]:
289-
"""Load optim-config.yml from the same directory as components_path.
289+
"""Load and fully resolve an ``optim-config.yml`` file.
290290
291-
Returns None if the file does not exist.
292-
Raises ValueError on parsing or validation failure.
291+
Returns ``None`` if the file does not exist.
292+
Raises ``ValueError`` on any parsing, validation, or playlist I/O failure.
293+
294+
Beyond plain YAML parsing, this function:
295+
296+
- Resolves a relative ``playlist-file`` path against the directory that
297+
contains the config file.
298+
- Eagerly populates ``scenario_ids`` so that playlist file errors surface
299+
immediately rather than at first use.
293300
"""
294301
if not config_path.exists():
295302
return None

src/gems/study/scenario_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ def validate_mc_scenarios(self, scenario_ids: List[int]) -> List[str]:
8181
out_of_bounds = [idx for idx in scenario_ids if idx >= len(arr)]
8282
if out_of_bounds:
8383
errors.append(
84-
f"Scenario indices {[i + 1 for i in out_of_bounds]} (1-based) are not defined "
85-
f"for scenario group '{group}' (defined range: 1{len(arr)})"
84+
f"Scenario indices {out_of_bounds} are not defined "
85+
f"for scenario group '{group}' (defined range: 0{len(arr) - 1})"
8686
)
8787
return errors
8888

0 commit comments

Comments
 (0)