hydra-optuna-sweeper 1.4.0.dev6__tar.gz → 1.4.0.dev7__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.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/PKG-INFO +1 -1
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/PKG-INFO +1 -1
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/__init__.py +1 -1
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/_impl.py +9 -9
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/optuna_sweeper.py +11 -3
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/tests/test_optuna_sweeper_plugin.py +6 -2
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/MANIFEST.in +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/README.md +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/SOURCES.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/dependency_links.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/requires.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/top_level.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/config.py +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/py.typed +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/pyproject.toml +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/setup.cfg +0 -0
- {hydra_optuna_sweeper-1.4.0.dev6 → hydra_optuna_sweeper-1.4.0.dev7}/setup.py +0 -0
|
@@ -82,9 +82,9 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
82
82
|
if override.is_choice_sweep():
|
|
83
83
|
assert isinstance(value, ChoiceSweep)
|
|
84
84
|
for x in override.sweep_iterator(transformer=Transformer.encode):
|
|
85
|
-
assert isinstance(
|
|
86
|
-
|
|
87
|
-
)
|
|
85
|
+
assert isinstance(x, (str, int, float, bool, type(None))), (
|
|
86
|
+
f"A choice sweep expects str, int, float, bool, or None type. Got {type(x)}."
|
|
87
|
+
)
|
|
88
88
|
choices.append(x)
|
|
89
89
|
return CategoricalDistribution(choices)
|
|
90
90
|
|
|
@@ -94,9 +94,9 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
94
94
|
assert value.stop is not None
|
|
95
95
|
if value.shuffle:
|
|
96
96
|
for x in override.sweep_iterator(transformer=Transformer.encode):
|
|
97
|
-
assert isinstance(
|
|
98
|
-
|
|
99
|
-
)
|
|
97
|
+
assert isinstance(x, (str, int, float, bool, type(None))), (
|
|
98
|
+
f"A choice sweep expects str, int, float, bool, or None type. Got {type(x)}."
|
|
99
|
+
)
|
|
100
100
|
choices.append(x)
|
|
101
101
|
return CategoricalDistribution(choices)
|
|
102
102
|
if (
|
|
@@ -273,9 +273,9 @@ class OptunaSweeperImpl(Sweeper):
|
|
|
273
273
|
if isinstance(distribution, CategoricalDistribution):
|
|
274
274
|
return distribution.choices
|
|
275
275
|
elif isinstance(distribution, IntDistribution):
|
|
276
|
-
assert (
|
|
277
|
-
|
|
278
|
-
)
|
|
276
|
+
assert distribution.step is not None, (
|
|
277
|
+
"`step` of IntDistribution must be a positive integer."
|
|
278
|
+
)
|
|
279
279
|
n_items = (distribution.high - distribution.low) // distribution.step
|
|
280
280
|
return [distribution.low + i * distribution.step for i in range(n_items)]
|
|
281
281
|
elif (
|
|
@@ -3,17 +3,16 @@ from typing import Any, List, Optional
|
|
|
3
3
|
|
|
4
4
|
from hydra.plugins.sweeper import Sweeper
|
|
5
5
|
from hydra.types import HydraContext, TaskFunction
|
|
6
|
+
from hydra.utils import instantiate
|
|
6
7
|
from omegaconf import DictConfig
|
|
7
8
|
|
|
8
|
-
from .config import SamplerConfig
|
|
9
|
-
|
|
10
9
|
|
|
11
10
|
class OptunaSweeper(Sweeper):
|
|
12
11
|
"""Class to interface with Optuna"""
|
|
13
12
|
|
|
14
13
|
def __init__(
|
|
15
14
|
self,
|
|
16
|
-
sampler:
|
|
15
|
+
sampler: Any,
|
|
17
16
|
direction: Any,
|
|
18
17
|
storage: Optional[Any],
|
|
19
18
|
study_name: Optional[str],
|
|
@@ -26,6 +25,15 @@ class OptunaSweeper(Sweeper):
|
|
|
26
25
|
) -> None:
|
|
27
26
|
from ._impl import OptunaSweeperImpl
|
|
28
27
|
|
|
28
|
+
sampler = instantiate(
|
|
29
|
+
sampler,
|
|
30
|
+
_skip_instantiate_full_deepcopy_=True,
|
|
31
|
+
_target_whitelist_=(
|
|
32
|
+
"hydra_plugins.hydra_optuna_sweeper.*",
|
|
33
|
+
"optuna.samplers.*",
|
|
34
|
+
),
|
|
35
|
+
)
|
|
36
|
+
|
|
29
37
|
self.sweeper = OptunaSweeperImpl(
|
|
30
38
|
sampler,
|
|
31
39
|
direction,
|
|
@@ -387,7 +387,10 @@ def test_motpe_sampler_removed() -> None:
|
|
|
387
387
|
InstantiationException,
|
|
388
388
|
match="The 'motpe' sampler was removed in Optuna 4.0",
|
|
389
389
|
):
|
|
390
|
-
instantiate(
|
|
390
|
+
instantiate(
|
|
391
|
+
OmegaConf.structured(MOTPESamplerConfig),
|
|
392
|
+
_target_whitelist_="hydra_plugins.hydra_optuna_sweeper.config.raise_motpe_removed",
|
|
393
|
+
)
|
|
391
394
|
|
|
392
395
|
|
|
393
396
|
def test_example_with_removed_motpe(
|
|
@@ -406,4 +409,5 @@ def test_example_with_removed_motpe(
|
|
|
406
409
|
]
|
|
407
410
|
|
|
408
411
|
out, err = run_process(cmd, print_error=False, raise_exception=False)
|
|
409
|
-
assert "
|
|
412
|
+
assert "motpe" in err
|
|
413
|
+
assert "sampler was removed in Optuna 4.0" in err
|
|
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
|