hydra-optuna-sweeper 1.4.0.dev4__tar.gz → 1.4.0.dev5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/PKG-INFO +1 -1
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_optuna_sweeper.egg-info/PKG-INFO +1 -1
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_plugins/hydra_optuna_sweeper/__init__.py +1 -1
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_plugins/hydra_optuna_sweeper/_impl.py +17 -5
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/tests/test_optuna_sweeper_plugin.py +6 -3
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/MANIFEST.in +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/README.md +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_optuna_sweeper.egg-info/SOURCES.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_optuna_sweeper.egg-info/dependency_links.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_optuna_sweeper.egg-info/requires.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_optuna_sweeper.egg-info/top_level.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_plugins/hydra_optuna_sweeper/config.py +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_plugins/hydra_optuna_sweeper/optuna_sweeper.py +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/hydra_plugins/hydra_optuna_sweeper/py.typed +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/pyproject.toml +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/setup.cfg +0 -0
- {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev5}/setup.py +0 -0
|
@@ -107,7 +107,9 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
107
107
|
or isinstance(value.stop, float)
|
|
108
108
|
or isinstance(value.step, float)
|
|
109
109
|
):
|
|
110
|
-
return DiscreteUniformDistribution(
|
|
110
|
+
return DiscreteUniformDistribution(
|
|
111
|
+
float(value.start), float(value.stop), float(value.step)
|
|
112
|
+
)
|
|
111
113
|
return IntUniformDistribution(
|
|
112
114
|
int(value.start), int(value.stop), step=int(value.step)
|
|
113
115
|
)
|
|
@@ -130,20 +132,25 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
130
132
|
|
|
131
133
|
def create_params_from_overrides(
|
|
132
134
|
arguments: List[str],
|
|
133
|
-
) -> Tuple[Dict[str, BaseDistribution], Dict[str, Any]]:
|
|
135
|
+
) -> Tuple[Dict[str, BaseDistribution], Dict[str, Any], List[str]]:
|
|
134
136
|
parser = OverridesParser.create()
|
|
135
137
|
parsed = parser.parse_overrides(arguments)
|
|
136
138
|
search_space_distributions = dict()
|
|
137
139
|
fixed_params = dict()
|
|
140
|
+
fixed_overrides = []
|
|
138
141
|
|
|
139
142
|
for override in parsed:
|
|
143
|
+
if override.is_delete():
|
|
144
|
+
assert override.input_line is not None
|
|
145
|
+
fixed_overrides.append(override.input_line)
|
|
146
|
+
continue
|
|
140
147
|
param_name = override.get_key_element()
|
|
141
148
|
value = create_optuna_distribution_from_override(override)
|
|
142
149
|
if isinstance(value, BaseDistribution):
|
|
143
150
|
search_space_distributions[param_name] = value
|
|
144
151
|
else:
|
|
145
152
|
fixed_params[param_name] = value
|
|
146
|
-
return search_space_distributions, fixed_params
|
|
153
|
+
return search_space_distributions, fixed_params, fixed_overrides
|
|
147
154
|
|
|
148
155
|
|
|
149
156
|
class OptunaSweeperImpl(Sweeper):
|
|
@@ -230,6 +237,7 @@ class OptunaSweeperImpl(Sweeper):
|
|
|
230
237
|
trials: List[Trial],
|
|
231
238
|
search_space_distributions: Dict[str, BaseDistribution],
|
|
232
239
|
fixed_params: Dict[str, Any],
|
|
240
|
+
fixed_overrides: List[str],
|
|
233
241
|
) -> Sequence[Sequence[str]]:
|
|
234
242
|
overrides = []
|
|
235
243
|
for trial in trials:
|
|
@@ -252,7 +260,10 @@ class OptunaSweeperImpl(Sweeper):
|
|
|
252
260
|
params = dict(trial.params)
|
|
253
261
|
params.update(fixed_params)
|
|
254
262
|
|
|
255
|
-
overrides.append(
|
|
263
|
+
overrides.append(
|
|
264
|
+
tuple(f"{name}={val}" for name, val in params.items())
|
|
265
|
+
+ tuple(fixed_overrides)
|
|
266
|
+
)
|
|
256
267
|
return overrides
|
|
257
268
|
|
|
258
269
|
def _parse_sweeper_params_config(self) -> List[str]:
|
|
@@ -294,6 +305,7 @@ class OptunaSweeperImpl(Sweeper):
|
|
|
294
305
|
(
|
|
295
306
|
override_search_space_distributions,
|
|
296
307
|
fixed_params,
|
|
308
|
+
fixed_overrides,
|
|
297
309
|
) = create_params_from_overrides(params_conf)
|
|
298
310
|
|
|
299
311
|
search_space_distributions = dict()
|
|
@@ -343,7 +355,7 @@ class OptunaSweeperImpl(Sweeper):
|
|
|
343
355
|
|
|
344
356
|
trials = [study.ask() for _ in range(batch_size)]
|
|
345
357
|
overrides = self._configure_trials(
|
|
346
|
-
trials, search_space_distributions, fixed_params
|
|
358
|
+
trials, search_space_distributions, fixed_params, fixed_overrides
|
|
347
359
|
)
|
|
348
360
|
|
|
349
361
|
returns = self.launcher.launch(overrides, initial_job_idx=self.job_idx)
|
|
@@ -119,11 +119,11 @@ def test_create_optuna_distribution_from_override(input: Any, expected: Any) ->
|
|
|
119
119
|
@mark.parametrize(
|
|
120
120
|
"input, expected",
|
|
121
121
|
[
|
|
122
|
-
(["key=choice(1,2)"], ({"key": CategoricalDistribution([1, 2])}, {})),
|
|
123
|
-
(["key=5"], ({}, {"key": "5"})),
|
|
122
|
+
(["key=choice(1,2)"], ({"key": CategoricalDistribution([1, 2])}, {}, [])),
|
|
123
|
+
(["key=5"], ({}, {"key": "5"}, [])),
|
|
124
124
|
(
|
|
125
125
|
["key1=choice(1,2)", "key2=5"],
|
|
126
|
-
({"key1": CategoricalDistribution([1, 2])}, {"key2": "5"}),
|
|
126
|
+
({"key1": CategoricalDistribution([1, 2])}, {"key2": "5"}, []),
|
|
127
127
|
),
|
|
128
128
|
(
|
|
129
129
|
["key1=choice(1,2)", "key2=5", "key3=range(1,3)"],
|
|
@@ -133,8 +133,11 @@ def test_create_optuna_distribution_from_override(input: Any, expected: Any) ->
|
|
|
133
133
|
"key3": IntUniformDistribution(1, 3),
|
|
134
134
|
},
|
|
135
135
|
{"key2": "5"},
|
|
136
|
+
[],
|
|
136
137
|
),
|
|
137
138
|
),
|
|
139
|
+
(["~z"], ({}, {}, ["~z"])),
|
|
140
|
+
(["~z=10"], ({}, {}, ["~z=10"])),
|
|
138
141
|
],
|
|
139
142
|
)
|
|
140
143
|
def test_create_params_from_overrides(input: Any, expected: Any) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|