hydra-optuna-sweeper 1.4.0.dev5__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.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/PKG-INFO +2 -3
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/PKG-INFO +2 -3
- hydra_optuna_sweeper-1.4.0.dev7/hydra_optuna_sweeper.egg-info/requires.txt +2 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/__init__.py +1 -1
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/_impl.py +32 -32
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/config.py +55 -13
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/optuna_sweeper.py +11 -3
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/setup.py +1 -2
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/tests/test_optuna_sweeper_plugin.py +38 -30
- hydra_optuna_sweeper-1.4.0.dev5/hydra_optuna_sweeper.egg-info/requires.txt +0 -3
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/MANIFEST.in +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/README.md +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/SOURCES.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/dependency_links.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_optuna_sweeper.egg-info/top_level.txt +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/hydra_plugins/hydra_optuna_sweeper/py.typed +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/pyproject.toml +0 -0
- {hydra_optuna_sweeper-1.4.0.dev5 → hydra_optuna_sweeper-1.4.0.dev7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hydra-optuna-sweeper
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev7
|
|
4
4
|
Summary: Hydra Optuna Sweeper plugin
|
|
5
5
|
Home-page: https://github.com/facebookresearch/hydra/
|
|
6
6
|
Author: Toshihiko Yanase, Hiroyuki Vincent Yamazaki
|
|
@@ -17,8 +17,7 @@ Classifier: Development Status :: 4 - Beta
|
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
Requires-Dist: hydra-core>=1.1.0.dev7
|
|
20
|
-
Requires-Dist: optuna<
|
|
21
|
-
Requires-Dist: sqlalchemy~=1.3.0
|
|
20
|
+
Requires-Dist: optuna<5.0.0,>=4.9.0
|
|
22
21
|
Dynamic: author
|
|
23
22
|
Dynamic: author-email
|
|
24
23
|
Dynamic: classifier
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hydra-optuna-sweeper
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev7
|
|
4
4
|
Summary: Hydra Optuna Sweeper plugin
|
|
5
5
|
Home-page: https://github.com/facebookresearch/hydra/
|
|
6
6
|
Author: Toshihiko Yanase, Hiroyuki Vincent Yamazaki
|
|
@@ -17,8 +17,7 @@ Classifier: Development Status :: 4 - Beta
|
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
Requires-Dist: hydra-core>=1.1.0.dev7
|
|
20
|
-
Requires-Dist: optuna<
|
|
21
|
-
Requires-Dist: sqlalchemy~=1.3.0
|
|
20
|
+
Requires-Dist: optuna<5.0.0,>=4.9.0
|
|
22
21
|
Dynamic: author
|
|
23
22
|
Dynamic: author-email
|
|
24
23
|
Dynamic: classifier
|
|
@@ -35,11 +35,8 @@ from optuna.distributions import (
|
|
|
35
35
|
BaseDistribution,
|
|
36
36
|
CategoricalChoiceType,
|
|
37
37
|
CategoricalDistribution,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
IntUniformDistribution,
|
|
41
|
-
LogUniformDistribution,
|
|
42
|
-
UniformDistribution,
|
|
38
|
+
FloatDistribution,
|
|
39
|
+
IntDistribution,
|
|
43
40
|
)
|
|
44
41
|
from optuna.trial import Trial
|
|
45
42
|
|
|
@@ -62,17 +59,17 @@ def create_optuna_distribution_from_config(
|
|
|
62
59
|
assert param.low is not None
|
|
63
60
|
assert param.high is not None
|
|
64
61
|
if param.log:
|
|
65
|
-
return
|
|
62
|
+
return IntDistribution(int(param.low), int(param.high), log=True)
|
|
66
63
|
step = int(param.step) if param.step is not None else 1
|
|
67
|
-
return
|
|
64
|
+
return IntDistribution(int(param.low), int(param.high), step=step)
|
|
68
65
|
if param.type == DistributionType.float:
|
|
69
66
|
assert param.low is not None
|
|
70
67
|
assert param.high is not None
|
|
71
68
|
if param.log:
|
|
72
|
-
return
|
|
69
|
+
return FloatDistribution(param.low, param.high, log=True)
|
|
73
70
|
if param.step is not None:
|
|
74
|
-
return
|
|
75
|
-
return
|
|
71
|
+
return FloatDistribution(param.low, param.high, step=param.step)
|
|
72
|
+
return FloatDistribution(param.low, param.high)
|
|
76
73
|
raise NotImplementedError(f"{param.type} is not supported by Optuna sweeper.")
|
|
77
74
|
|
|
78
75
|
|
|
@@ -85,9 +82,9 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
85
82
|
if override.is_choice_sweep():
|
|
86
83
|
assert isinstance(value, ChoiceSweep)
|
|
87
84
|
for x in override.sweep_iterator(transformer=Transformer.encode):
|
|
88
|
-
assert isinstance(
|
|
89
|
-
|
|
90
|
-
)
|
|
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
|
+
)
|
|
91
88
|
choices.append(x)
|
|
92
89
|
return CategoricalDistribution(choices)
|
|
93
90
|
|
|
@@ -97,9 +94,9 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
97
94
|
assert value.stop is not None
|
|
98
95
|
if value.shuffle:
|
|
99
96
|
for x in override.sweep_iterator(transformer=Transformer.encode):
|
|
100
|
-
assert isinstance(
|
|
101
|
-
|
|
102
|
-
)
|
|
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
|
+
)
|
|
103
100
|
choices.append(x)
|
|
104
101
|
return CategoricalDistribution(choices)
|
|
105
102
|
if (
|
|
@@ -107,12 +104,12 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
107
104
|
or isinstance(value.stop, float)
|
|
108
105
|
or isinstance(value.step, float)
|
|
109
106
|
):
|
|
110
|
-
return
|
|
111
|
-
float(value.start),
|
|
107
|
+
return FloatDistribution(
|
|
108
|
+
float(value.start),
|
|
109
|
+
float(value.stop),
|
|
110
|
+
step=float(value.step) if value.step else None,
|
|
112
111
|
)
|
|
113
|
-
return
|
|
114
|
-
int(value.start), int(value.stop), step=int(value.step)
|
|
115
|
-
)
|
|
112
|
+
return IntDistribution(int(value.start), int(value.stop), step=int(value.step))
|
|
116
113
|
|
|
117
114
|
if override.is_interval_sweep():
|
|
118
115
|
assert isinstance(value, IntervalSweep)
|
|
@@ -120,12 +117,12 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
|
|
|
120
117
|
assert value.end is not None
|
|
121
118
|
if "log" in value.tags:
|
|
122
119
|
if isinstance(value.start, int) and isinstance(value.end, int):
|
|
123
|
-
return
|
|
124
|
-
return
|
|
120
|
+
return IntDistribution(int(value.start), int(value.end), log=True)
|
|
121
|
+
return FloatDistribution(value.start, value.end, log=True)
|
|
125
122
|
else:
|
|
126
123
|
if isinstance(value.start, int) and isinstance(value.end, int):
|
|
127
|
-
return
|
|
128
|
-
return
|
|
124
|
+
return IntDistribution(value.start, value.end)
|
|
125
|
+
return FloatDistribution(value.start, value.end)
|
|
129
126
|
|
|
130
127
|
raise NotImplementedError(f"{override} is not supported by Optuna sweeper.")
|
|
131
128
|
|
|
@@ -275,15 +272,18 @@ class OptunaSweeperImpl(Sweeper):
|
|
|
275
272
|
def _to_grid_sampler_choices(self, distribution: BaseDistribution) -> Any:
|
|
276
273
|
if isinstance(distribution, CategoricalDistribution):
|
|
277
274
|
return distribution.choices
|
|
278
|
-
elif isinstance(distribution,
|
|
279
|
-
assert (
|
|
280
|
-
|
|
281
|
-
)
|
|
275
|
+
elif isinstance(distribution, IntDistribution):
|
|
276
|
+
assert distribution.step is not None, (
|
|
277
|
+
"`step` of IntDistribution must be a positive integer."
|
|
278
|
+
)
|
|
282
279
|
n_items = (distribution.high - distribution.low) // distribution.step
|
|
283
280
|
return [distribution.low + i * distribution.step for i in range(n_items)]
|
|
284
|
-
elif
|
|
285
|
-
|
|
286
|
-
|
|
281
|
+
elif (
|
|
282
|
+
isinstance(distribution, FloatDistribution)
|
|
283
|
+
and distribution.step is not None
|
|
284
|
+
):
|
|
285
|
+
n_items = int((distribution.high - distribution.low) // distribution.step)
|
|
286
|
+
return [distribution.low + i * distribution.step for i in range(n_items)]
|
|
287
287
|
else:
|
|
288
288
|
raise ValueError("GridSampler only supports discrete distributions.")
|
|
289
289
|
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
3
|
from enum import Enum
|
|
4
|
-
from typing import Any, Dict, List, Optional
|
|
4
|
+
from typing import Any, Dict, List, NoReturn, Optional
|
|
5
5
|
|
|
6
6
|
from hydra.core.config_store import ConfigStore
|
|
7
7
|
from omegaconf import MISSING
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
def raise_motpe_removed(*args: Any, **kwargs: Any) -> NoReturn:
|
|
11
|
+
raise ValueError(
|
|
12
|
+
"The 'motpe' sampler was removed in Optuna 4.0. "
|
|
13
|
+
"Use 'hydra/sweeper/sampler=tpe' instead. "
|
|
14
|
+
"TPESampler now handles multi-objective optimization."
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
|
|
10
18
|
class DistributionType(Enum):
|
|
11
19
|
int = 1
|
|
12
20
|
float = 2
|
|
@@ -43,14 +51,14 @@ class TPESamplerConfig(SamplerConfig):
|
|
|
43
51
|
_target_: str = "optuna.samplers.TPESampler"
|
|
44
52
|
seed: Optional[int] = None
|
|
45
53
|
|
|
46
|
-
consider_prior: bool =
|
|
47
|
-
prior_weight: float =
|
|
48
|
-
consider_magic_clip: bool =
|
|
49
|
-
consider_endpoints: bool =
|
|
54
|
+
consider_prior: Optional[bool] = None
|
|
55
|
+
prior_weight: Optional[float] = None
|
|
56
|
+
consider_magic_clip: Optional[bool] = None
|
|
57
|
+
consider_endpoints: Optional[bool] = None
|
|
50
58
|
n_startup_trials: int = 10
|
|
51
59
|
n_ei_candidates: int = 24
|
|
52
60
|
multivariate: bool = False
|
|
53
|
-
warn_independent_sampling: bool =
|
|
61
|
+
warn_independent_sampling: Optional[bool] = None
|
|
54
62
|
|
|
55
63
|
|
|
56
64
|
@dataclass
|
|
@@ -101,19 +109,39 @@ class NSGAIISamplerConfig(SamplerConfig):
|
|
|
101
109
|
|
|
102
110
|
@dataclass
|
|
103
111
|
class MOTPESamplerConfig(SamplerConfig):
|
|
112
|
+
_target_: str = "hydra_plugins.hydra_optuna_sweeper.config.raise_motpe_removed"
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass
|
|
116
|
+
class GPSamplerConfig(SamplerConfig):
|
|
104
117
|
"""
|
|
105
|
-
https://optuna.readthedocs.io/en/stable/reference/generated/optuna.samplers.
|
|
118
|
+
https://optuna.readthedocs.io/en/stable/reference/samplers/generated/optuna.samplers.GPSampler.html
|
|
106
119
|
"""
|
|
107
120
|
|
|
108
|
-
_target_: str = "optuna.samplers.
|
|
121
|
+
_target_: str = "optuna.samplers.GPSampler"
|
|
109
122
|
seed: Optional[int] = None
|
|
110
123
|
|
|
111
|
-
|
|
112
|
-
prior_weight: float = 1.0
|
|
113
|
-
consider_magic_clip: bool = True
|
|
114
|
-
consider_endpoints: bool = False
|
|
124
|
+
independent_sampler: Optional[Any] = None
|
|
115
125
|
n_startup_trials: int = 10
|
|
116
|
-
|
|
126
|
+
deterministic_objective: bool = False
|
|
127
|
+
constraints_func: Optional[Any] = None
|
|
128
|
+
warn_independent_sampling: bool = True
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
@dataclass
|
|
132
|
+
class QMCSamplerConfig(SamplerConfig):
|
|
133
|
+
"""
|
|
134
|
+
https://optuna.readthedocs.io/en/stable/reference/samplers/generated/optuna.samplers.QMCSampler.html
|
|
135
|
+
"""
|
|
136
|
+
|
|
137
|
+
_target_: str = "optuna.samplers.QMCSampler"
|
|
138
|
+
seed: Optional[int] = None
|
|
139
|
+
|
|
140
|
+
qmc_type: str = "sobol"
|
|
141
|
+
scramble: bool = False
|
|
142
|
+
independent_sampler: Optional[Any] = None
|
|
143
|
+
warn_asynchronous_seeding: bool = True
|
|
144
|
+
warn_independent_sampling: bool = True
|
|
117
145
|
|
|
118
146
|
|
|
119
147
|
@dataclass
|
|
@@ -234,3 +262,17 @@ ConfigStore.instance().store(
|
|
|
234
262
|
node=GridSamplerConfig,
|
|
235
263
|
provider="optuna_sweeper",
|
|
236
264
|
)
|
|
265
|
+
|
|
266
|
+
ConfigStore.instance().store(
|
|
267
|
+
group="hydra/sweeper/sampler",
|
|
268
|
+
name="gp",
|
|
269
|
+
node=GPSamplerConfig,
|
|
270
|
+
provider="optuna_sweeper",
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
ConfigStore.instance().store(
|
|
274
|
+
group="hydra/sweeper/sampler",
|
|
275
|
+
name="qmc",
|
|
276
|
+
node=QMCSamplerConfig,
|
|
277
|
+
provider="optuna_sweeper",
|
|
278
|
+
)
|
|
@@ -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,
|
|
@@ -8,6 +8,7 @@ from typing import Any, List, Optional
|
|
|
8
8
|
import optuna
|
|
9
9
|
from hydra.core.override_parser.overrides_parser import OverridesParser
|
|
10
10
|
from hydra.core.plugins import Plugins
|
|
11
|
+
from hydra.errors import InstantiationException
|
|
11
12
|
from hydra.plugins.sweeper import Sweeper
|
|
12
13
|
from hydra.test_utils.test_utils import (
|
|
13
14
|
TSweepRunner,
|
|
@@ -15,22 +16,20 @@ from hydra.test_utils.test_utils import (
|
|
|
15
16
|
run_process,
|
|
16
17
|
run_python_script,
|
|
17
18
|
)
|
|
19
|
+
from hydra.utils import instantiate
|
|
18
20
|
from omegaconf import DictConfig, OmegaConf
|
|
19
21
|
from optuna.distributions import (
|
|
20
22
|
BaseDistribution,
|
|
21
23
|
CategoricalDistribution,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
IntUniformDistribution,
|
|
25
|
-
LogUniformDistribution,
|
|
26
|
-
UniformDistribution,
|
|
24
|
+
FloatDistribution,
|
|
25
|
+
IntDistribution,
|
|
27
26
|
)
|
|
28
27
|
from optuna.samplers import RandomSampler
|
|
29
|
-
from pytest import mark, warns
|
|
28
|
+
from pytest import mark, raises, warns
|
|
30
29
|
|
|
31
30
|
from hydra_plugins.hydra_optuna_sweeper import _impl
|
|
32
31
|
from hydra_plugins.hydra_optuna_sweeper._impl import OptunaSweeperImpl
|
|
33
|
-
from hydra_plugins.hydra_optuna_sweeper.config import Direction
|
|
32
|
+
from hydra_plugins.hydra_optuna_sweeper.config import Direction, MOTPESamplerConfig
|
|
34
33
|
from hydra_plugins.hydra_optuna_sweeper.optuna_sweeper import OptunaSweeper
|
|
35
34
|
|
|
36
35
|
chdir_plugin_root()
|
|
@@ -68,24 +67,24 @@ def check_distribution(expected: BaseDistribution, actual: BaseDistribution) ->
|
|
|
68
67
|
{"type": "categorical", "choices": [1, 2, 3]},
|
|
69
68
|
CategoricalDistribution([1, 2, 3]),
|
|
70
69
|
),
|
|
71
|
-
({"type": "int", "low": 0, "high": 10},
|
|
70
|
+
({"type": "int", "low": 0, "high": 10}, IntDistribution(0, 10)),
|
|
72
71
|
(
|
|
73
72
|
{"type": "int", "low": 0, "high": 10, "step": 2},
|
|
74
|
-
|
|
73
|
+
IntDistribution(0, 10, step=2),
|
|
75
74
|
),
|
|
76
|
-
({"type": "int", "low": 0, "high": 5},
|
|
75
|
+
({"type": "int", "low": 0, "high": 5}, IntDistribution(0, 5)),
|
|
77
76
|
(
|
|
78
77
|
{"type": "int", "low": 1, "high": 100, "log": True},
|
|
79
|
-
|
|
78
|
+
IntDistribution(1, 100, log=True),
|
|
80
79
|
),
|
|
81
|
-
({"type": "float", "low": 0, "high": 1},
|
|
80
|
+
({"type": "float", "low": 0, "high": 1}, FloatDistribution(0, 1)),
|
|
82
81
|
(
|
|
83
82
|
{"type": "float", "low": 0, "high": 10, "step": 2},
|
|
84
|
-
|
|
83
|
+
FloatDistribution(0, 10, step=2),
|
|
85
84
|
),
|
|
86
85
|
(
|
|
87
86
|
{"type": "float", "low": 1, "high": 100, "log": True},
|
|
88
|
-
|
|
87
|
+
FloatDistribution(1, 100, log=True),
|
|
89
88
|
),
|
|
90
89
|
],
|
|
91
90
|
)
|
|
@@ -101,12 +100,12 @@ def test_create_optuna_distribution_from_config(input: Any, expected: Any) -> No
|
|
|
101
100
|
("key=choice(true, false)", CategoricalDistribution([True, False])),
|
|
102
101
|
("key=choice('hello', 'world')", CategoricalDistribution(["hello", "world"])),
|
|
103
102
|
("key=shuffle(range(1,3))", CategoricalDistribution((1, 2))),
|
|
104
|
-
("key=range(1,3)",
|
|
105
|
-
("key=interval(1, 5)",
|
|
106
|
-
("key=int(interval(1, 5))",
|
|
107
|
-
("key=tag(log, interval(1, 5))",
|
|
108
|
-
("key=tag(log, int(interval(1, 5)))",
|
|
109
|
-
("key=range(0.5, 5.5, step=1)",
|
|
103
|
+
("key=range(1,3)", IntDistribution(1, 3)),
|
|
104
|
+
("key=interval(1, 5)", FloatDistribution(1, 5)),
|
|
105
|
+
("key=int(interval(1, 5))", IntDistribution(1, 5)),
|
|
106
|
+
("key=tag(log, interval(1, 5))", FloatDistribution(1, 5, log=True)),
|
|
107
|
+
("key=tag(log, int(interval(1, 5)))", IntDistribution(1, 5, log=True)),
|
|
108
|
+
("key=range(0.5, 5.5, step=1)", FloatDistribution(0.5, 5.5, step=1)),
|
|
110
109
|
],
|
|
111
110
|
)
|
|
112
111
|
def test_create_optuna_distribution_from_override(input: Any, expected: Any) -> None:
|
|
@@ -130,7 +129,7 @@ def test_create_optuna_distribution_from_override(input: Any, expected: Any) ->
|
|
|
130
129
|
(
|
|
131
130
|
{
|
|
132
131
|
"key1": CategoricalDistribution([1, 2]),
|
|
133
|
-
"key3":
|
|
132
|
+
"key3": IntDistribution(1, 3),
|
|
134
133
|
},
|
|
135
134
|
{"key2": "5"},
|
|
136
135
|
[],
|
|
@@ -383,23 +382,32 @@ def test_failure_rate(max_failure_rate: float, tmpdir: Path) -> None:
|
|
|
383
382
|
assert error_string not in err
|
|
384
383
|
|
|
385
384
|
|
|
386
|
-
def
|
|
385
|
+
def test_motpe_sampler_removed() -> None:
|
|
386
|
+
with raises(
|
|
387
|
+
InstantiationException,
|
|
388
|
+
match="The 'motpe' sampler was removed in Optuna 4.0",
|
|
389
|
+
):
|
|
390
|
+
instantiate(
|
|
391
|
+
OmegaConf.structured(MOTPESamplerConfig),
|
|
392
|
+
_target_whitelist_="hydra_plugins.hydra_optuna_sweeper.config.raise_motpe_removed",
|
|
393
|
+
)
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def test_example_with_removed_motpe(
|
|
387
397
|
tmpdir: Path,
|
|
388
398
|
) -> None:
|
|
389
399
|
cmd = [
|
|
390
|
-
|
|
391
|
-
"example/
|
|
400
|
+
sys.executable,
|
|
401
|
+
"example/multi-objective.py",
|
|
392
402
|
"--multirun",
|
|
393
403
|
"--config-dir=tests/conf",
|
|
394
|
-
"--config-name=
|
|
404
|
+
"--config-name=test_motpe",
|
|
395
405
|
"hydra.sweep.dir=" + str(tmpdir),
|
|
396
406
|
"hydra.job.chdir=True",
|
|
397
407
|
"hydra.sweeper.n_trials=20",
|
|
398
408
|
"hydra.sweeper.n_jobs=1",
|
|
399
409
|
]
|
|
400
410
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
assert
|
|
404
|
-
assert returns.name == "optuna"
|
|
405
|
-
assert abs(returns["best_params"]["x"]) <= 5.5
|
|
411
|
+
out, err = run_process(cmd, print_error=False, raise_exception=False)
|
|
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
|