Commit 77a743c
Replace nb-scenarios with scenario playlist in scenario-scope (#206)
* Replace nb-scenarios with scenario playlist in scenario-scope
The scenario-scope config now accepts either an inline include/exclude
declaration (with support for 1-based integer indices and 'a-b' range
strings) or a playlist-file reference pointing to a flat JSON array of
1-based integers. Both forms resolve to a sorted, deduplicated list of
0-based MC scenario indices consumed by the solver.
nb-scenarios is removed: the pydantic extra="forbid" policy makes any
YAML that still uses it a hard validation error. All test fixtures and
inline config strings have been migrated to the new include form.
validate_optim_config gains an optional scenario_builder parameter to
cross-check playlist indices against every defined scenario group.
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Update uv.lock after dependency resolution
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Fix black and isort formatting
Two lines wrapped to 88 chars in parsing.py; one extra blank line
removed after import in the test file.
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Improve scenario-scope: string ints, eager cache, missing tests
- _expand_entries now accepts string integers like "5" in addition to
int 5 and range "1-10", treating them identically after stripping
- ScenarioScopeConfig stores scenario_ids in a PrivateAttr cache so
resolution happens at most once per instance
- load_optim_config triggers eager resolution after path resolution,
so the playlist file is read exactly once at load time and I/O
errors surface immediately
- New tests: string-integer entries, cache identity (file deleted after
load), and validate_optim_config ScenarioBuilder cross-check
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Fix playlist loading: wrap I/O errors as ValueError, reject JSON booleans
FileNotFoundError and json.JSONDecodeError from _load_playlist now surface
as ValueError so callers always receive a consistent exception type.
JSON boolean values (true/false) are now explicitly rejected — bool is a
subclass of int in Python so they previously slipped through the isinstance
check silently. Three new tests cover each case.
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Update documentation for scenario-scope playlist feature
- optim-config.md: replace nb-scenarios section with full description of
the inline (include/exclude) and playlist-file forms, with examples,
validation rules, and updated Python API snippets
- scenario-builder.md: remove stale nb-scenarios reference; link to
validate_optim_config cross-check
- CHANGELOG.md: add [Unreleased] entry summarising the playlist changes;
fix the 0.1.0 entry that still mentioned nb_scenarios
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Reject boolean values in inline include/exclude lists
Pydantic coerces True/False to 1/0 before _expand_entries sees them, so
the check must happen at the field_validator(mode="before") layer. A
field_validator on include and exclude now raises ValueError for any bool
item, making the behaviour consistent with playlist-file which already
rejects JSON booleans. Two new tests cover include=[True] and
exclude=[False].
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Switch scenario-scope to 0-based indexing throughout
All user-facing scenario index surfaces (optim-config.yml include/exclude
and JSON playlist files) now use 0-based indices, consistent with the
modeler-scenariobuilder.dat convention. The internal representation is
unchanged (already 0-based), so only the boundary conversion code is
affected:
- _expand_entries: removed the '- 1' offset; lower bound is now >= 0
- _load_playlist: removed the '- 1' offset; lower bound is now >= 0
- _resolve_inline warning: no longer adds 1 back when reporting orphans
- Range 'a-b' now means [a, b] inclusive (both 0-based)
All test fixtures, inline config strings, unit tests and documentation
updated accordingly. 'include: [0]' now means the first scenario (was 1).
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Fix CHANGELOG: restore accurate 0.1.0 entry, add inline boolean note
- 0.1.0 entry: restore nb_scenarios description (that is what was shipped
in 0.1.0; the playlist feature is in [Unreleased])
- [Unreleased] other-changes bullet: broaden boolean rejection note to
cover both inline include/exclude lists and JSON playlist files
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* Allow exclude with playlist-file; update docstrings throughout
exclude is no longer restricted to the inline include form — it now applies
to both base-set forms (include and playlist-file). The exclude logic was
lifted out of _resolve_inline (now removed) into _compute_scenario_ids so
it runs uniformly after the base set is built.
- _check_constraints: 'exclude' now requires include OR playlist-file
- _load_playlist: returns Set[int] instead of List[int]; sorting deferred
to _compute_scenario_ids after exclude is applied
- _compute_scenario_ids: single unified method handles both forms + exclude
- Warning message updated: 'include set' → 'base set'
Docstrings updated:
- ScenarioScopeConfig: full class docstring documenting both forms,
exclude compatibility, caching behaviour, and index convention
- _expand_entries: clarified entry formats and boolean handling note
- validate_optim_config: enumerated bullet-point list of all checks
- ScenarioBuilder.validate_mc_scenarios: documents return contract
Four new tests cover playlist-file + exclude (basic, range, all-excluded,
orphan warning). Updated test for the relaxed exclude-without-base error.
https://claude.ai/code/session_01EfjU9tBfdyZ9nZmQFCe5uU
* 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
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2178cfb commit 77a743c
15 files changed
Lines changed: 820 additions & 41 deletions
File tree
- docs
- user-guide
- src/gems
- optim_config
- session
- study
- tests
- e2e/functional
- studies
- 13_1/input
- 13_2/input
- 7_4/input
- unittests/optim_config
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
5 | 53 | | |
6 | 54 | | |
7 | 55 | | |
| |||
26 | 74 | | |
27 | 75 | | |
28 | 76 | | |
29 | | - | |
| 77 | + | |
30 | 78 | | |
31 | 79 | | |
32 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
69 | 82 | | |
70 | 83 | | |
71 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
72 | 92 | | |
73 | | - | |
74 | | - | |
75 | | - | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
76 | 179 | | |
77 | 180 | | |
78 | 181 | | |
| |||
238 | 341 | | |
239 | 342 | | |
240 | 343 | | |
241 | | - | |
| 344 | + | |
242 | 345 | | |
243 | 346 | | |
244 | | - | |
| 347 | + | |
245 | 348 | | |
246 | 349 | | |
247 | 350 | | |
248 | 351 | | |
249 | 352 | | |
250 | 353 | | |
251 | 354 | | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
252 | 362 | | |
253 | 363 | | |
254 | 364 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| |||
0 commit comments