Repository navigation
Commit f2c42b4
fix: allow PipelineVariable keys in HyperparameterTuner hyperparameter_ranges annotation (#6327)
The HyperparameterTuner constructor annotated hyperparameter_ranges as
Dict[str, ParameterRange], but the tuner accepts a PipelineVariable (e.g. a
pipeline ParameterString) as a dict key -- the hyperparameter name -- which is
a documented, working pattern when building a tuning step inside a pipeline.
The narrow annotation makes mypy report a false positive (dict-item) on valid
code. Broaden the key type to Union[str, PipelineVariable] (Union and
PipelineVariable are already imported) and update the __init__ and create()
docstrings. Annotation/docstring-only: runtime behavior is unchanged and
ParameterString subclasses PipelineVariable, so the union is exact.
Adds an annotation regression guard plus a runtime sanity test.
Fixes #5243
Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>1 parent ef40811 commit f2c42b4
2 files changed
Lines changed: 48 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
594 | 594 | | |
595 | 595 | | |
596 | 596 | | |
597 | | - | |
| 597 | + | |
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| |||
624 | 624 | | |
625 | 625 | | |
626 | 626 | | |
627 | | - | |
628 | | - | |
| 627 | + | |
| 628 | + | |
629 | 629 | | |
630 | | - | |
| 630 | + | |
| 631 | + | |
631 | 632 | | |
632 | 633 | | |
633 | 634 | | |
| |||
1906 | 1907 | | |
1907 | 1908 | | |
1908 | 1909 | | |
1909 | | - | |
1910 | | - | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
1911 | 1913 | | |
1912 | 1914 | | |
1913 | 1915 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
2230 | 2232 | | |
2231 | 2233 | | |
2232 | 2234 | | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
0 commit comments