hydra-optuna-sweeper 1.4.0.dev4__tar.gz → 1.4.0.dev6__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.
Files changed (18) hide show
  1. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/PKG-INFO +2 -3
  2. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_optuna_sweeper.egg-info/PKG-INFO +2 -3
  3. hydra_optuna_sweeper-1.4.0.dev6/hydra_optuna_sweeper.egg-info/requires.txt +2 -0
  4. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_plugins/hydra_optuna_sweeper/__init__.py +1 -1
  5. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_plugins/hydra_optuna_sweeper/_impl.py +39 -27
  6. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_plugins/hydra_optuna_sweeper/config.py +55 -13
  7. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/setup.py +1 -2
  8. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/tests/test_optuna_sweeper_plugin.py +40 -33
  9. hydra_optuna_sweeper-1.4.0.dev4/hydra_optuna_sweeper.egg-info/requires.txt +0 -3
  10. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/MANIFEST.in +0 -0
  11. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/README.md +0 -0
  12. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_optuna_sweeper.egg-info/SOURCES.txt +0 -0
  13. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_optuna_sweeper.egg-info/dependency_links.txt +0 -0
  14. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_optuna_sweeper.egg-info/top_level.txt +0 -0
  15. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_plugins/hydra_optuna_sweeper/optuna_sweeper.py +0 -0
  16. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/hydra_plugins/hydra_optuna_sweeper/py.typed +0 -0
  17. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/pyproject.toml +0 -0
  18. {hydra_optuna_sweeper-1.4.0.dev4 → hydra_optuna_sweeper-1.4.0.dev6}/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.dev4
3
+ Version: 1.4.0.dev6
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<3.0.0,>=2.10.0
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.dev4
3
+ Version: 1.4.0.dev6
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<3.0.0,>=2.10.0
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
@@ -0,0 +1,2 @@
1
+ hydra-core>=1.1.0.dev7
2
+ optuna<5.0.0,>=4.9.0
@@ -1,3 +1,3 @@
1
1
  # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2
2
 
3
- __version__ = "1.4.0.dev4"
3
+ __version__ = "1.4.0.dev6"
@@ -35,11 +35,8 @@ from optuna.distributions import (
35
35
  BaseDistribution,
36
36
  CategoricalChoiceType,
37
37
  CategoricalDistribution,
38
- DiscreteUniformDistribution,
39
- IntLogUniformDistribution,
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 IntLogUniformDistribution(int(param.low), int(param.high))
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 IntUniformDistribution(int(param.low), int(param.high), step=step)
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 LogUniformDistribution(param.low, param.high)
69
+ return FloatDistribution(param.low, param.high, log=True)
73
70
  if param.step is not None:
74
- return DiscreteUniformDistribution(param.low, param.high, param.step)
75
- return UniformDistribution(param.low, param.high)
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
 
@@ -107,10 +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 DiscreteUniformDistribution(value.start, value.stop, value.step)
111
- return IntUniformDistribution(
112
- int(value.start), int(value.stop), step=int(value.step)
113
- )
107
+ return FloatDistribution(
108
+ float(value.start),
109
+ float(value.stop),
110
+ step=float(value.step) if value.step else None,
111
+ )
112
+ return IntDistribution(int(value.start), int(value.stop), step=int(value.step))
114
113
 
115
114
  if override.is_interval_sweep():
116
115
  assert isinstance(value, IntervalSweep)
@@ -118,32 +117,37 @@ def create_optuna_distribution_from_override(override: Override) -> Any:
118
117
  assert value.end is not None
119
118
  if "log" in value.tags:
120
119
  if isinstance(value.start, int) and isinstance(value.end, int):
121
- return IntLogUniformDistribution(int(value.start), int(value.end))
122
- return LogUniformDistribution(value.start, value.end)
120
+ return IntDistribution(int(value.start), int(value.end), log=True)
121
+ return FloatDistribution(value.start, value.end, log=True)
123
122
  else:
124
123
  if isinstance(value.start, int) and isinstance(value.end, int):
125
- return IntUniformDistribution(value.start, value.end)
126
- return UniformDistribution(value.start, value.end)
124
+ return IntDistribution(value.start, value.end)
125
+ return FloatDistribution(value.start, value.end)
127
126
 
128
127
  raise NotImplementedError(f"{override} is not supported by Optuna sweeper.")
129
128
 
130
129
 
131
130
  def create_params_from_overrides(
132
131
  arguments: List[str],
133
- ) -> Tuple[Dict[str, BaseDistribution], Dict[str, Any]]:
132
+ ) -> Tuple[Dict[str, BaseDistribution], Dict[str, Any], List[str]]:
134
133
  parser = OverridesParser.create()
135
134
  parsed = parser.parse_overrides(arguments)
136
135
  search_space_distributions = dict()
137
136
  fixed_params = dict()
137
+ fixed_overrides = []
138
138
 
139
139
  for override in parsed:
140
+ if override.is_delete():
141
+ assert override.input_line is not None
142
+ fixed_overrides.append(override.input_line)
143
+ continue
140
144
  param_name = override.get_key_element()
141
145
  value = create_optuna_distribution_from_override(override)
142
146
  if isinstance(value, BaseDistribution):
143
147
  search_space_distributions[param_name] = value
144
148
  else:
145
149
  fixed_params[param_name] = value
146
- return search_space_distributions, fixed_params
150
+ return search_space_distributions, fixed_params, fixed_overrides
147
151
 
148
152
 
149
153
  class OptunaSweeperImpl(Sweeper):
@@ -230,6 +234,7 @@ class OptunaSweeperImpl(Sweeper):
230
234
  trials: List[Trial],
231
235
  search_space_distributions: Dict[str, BaseDistribution],
232
236
  fixed_params: Dict[str, Any],
237
+ fixed_overrides: List[str],
233
238
  ) -> Sequence[Sequence[str]]:
234
239
  overrides = []
235
240
  for trial in trials:
@@ -252,7 +257,10 @@ class OptunaSweeperImpl(Sweeper):
252
257
  params = dict(trial.params)
253
258
  params.update(fixed_params)
254
259
 
255
- overrides.append(tuple(f"{name}={val}" for name, val in params.items()))
260
+ overrides.append(
261
+ tuple(f"{name}={val}" for name, val in params.items())
262
+ + tuple(fixed_overrides)
263
+ )
256
264
  return overrides
257
265
 
258
266
  def _parse_sweeper_params_config(self) -> List[str]:
@@ -264,15 +272,18 @@ class OptunaSweeperImpl(Sweeper):
264
272
  def _to_grid_sampler_choices(self, distribution: BaseDistribution) -> Any:
265
273
  if isinstance(distribution, CategoricalDistribution):
266
274
  return distribution.choices
267
- elif isinstance(distribution, IntUniformDistribution):
275
+ elif isinstance(distribution, IntDistribution):
268
276
  assert (
269
277
  distribution.step is not None
270
- ), "`step` of IntUniformDistribution must be a positive integer."
278
+ ), "`step` of IntDistribution must be a positive integer."
271
279
  n_items = (distribution.high - distribution.low) // distribution.step
272
280
  return [distribution.low + i * distribution.step for i in range(n_items)]
273
- elif isinstance(distribution, DiscreteUniformDistribution):
274
- n_items = int((distribution.high - distribution.low) // distribution.q)
275
- return [distribution.low + i * distribution.q for i in range(n_items)]
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)]
276
287
  else:
277
288
  raise ValueError("GridSampler only supports discrete distributions.")
278
289
 
@@ -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)
@@ -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 = True
47
- prior_weight: float = 1.0
48
- consider_magic_clip: bool = True
49
- consider_endpoints: bool = False
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 = True
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.MOTPESampler.html
118
+ https://optuna.readthedocs.io/en/stable/reference/samplers/generated/optuna.samplers.GPSampler.html
106
119
  """
107
120
 
108
- _target_: str = "optuna.samplers.MOTPESampler"
121
+ _target_: str = "optuna.samplers.GPSampler"
109
122
  seed: Optional[int] = None
110
123
 
111
- consider_prior: bool = True
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
- n_ehvi_candidates: int = 24
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
+ )
@@ -29,8 +29,7 @@ setup(
29
29
  python_requires=">=3.10",
30
30
  install_requires=[
31
31
  "hydra-core>=1.1.0.dev7",
32
- "optuna>=2.10.0,<3.0.0",
33
- "sqlalchemy~=1.3.0", # TODO: Unpin when upgrading to optuna v3.0
32
+ "optuna>=4.9.0,<5.0.0",
34
33
  ],
35
34
  include_package_data=True,
36
35
  )
@@ -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
- DiscreteUniformDistribution,
23
- IntLogUniformDistribution,
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}, IntUniformDistribution(0, 10)),
70
+ ({"type": "int", "low": 0, "high": 10}, IntDistribution(0, 10)),
72
71
  (
73
72
  {"type": "int", "low": 0, "high": 10, "step": 2},
74
- IntUniformDistribution(0, 10, step=2),
73
+ IntDistribution(0, 10, step=2),
75
74
  ),
76
- ({"type": "int", "low": 0, "high": 5}, IntUniformDistribution(0, 5)),
75
+ ({"type": "int", "low": 0, "high": 5}, IntDistribution(0, 5)),
77
76
  (
78
77
  {"type": "int", "low": 1, "high": 100, "log": True},
79
- IntLogUniformDistribution(1, 100),
78
+ IntDistribution(1, 100, log=True),
80
79
  ),
81
- ({"type": "float", "low": 0, "high": 1}, UniformDistribution(0, 1)),
80
+ ({"type": "float", "low": 0, "high": 1}, FloatDistribution(0, 1)),
82
81
  (
83
82
  {"type": "float", "low": 0, "high": 10, "step": 2},
84
- DiscreteUniformDistribution(0, 10, 2),
83
+ FloatDistribution(0, 10, step=2),
85
84
  ),
86
85
  (
87
86
  {"type": "float", "low": 1, "high": 100, "log": True},
88
- LogUniformDistribution(1, 100),
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)", IntUniformDistribution(1, 3)),
105
- ("key=interval(1, 5)", UniformDistribution(1, 5)),
106
- ("key=int(interval(1, 5))", IntUniformDistribution(1, 5)),
107
- ("key=tag(log, interval(1, 5))", LogUniformDistribution(1, 5)),
108
- ("key=tag(log, int(interval(1, 5)))", IntLogUniformDistribution(1, 5)),
109
- ("key=range(0.5, 5.5, step=1)", DiscreteUniformDistribution(0.5, 5.5, 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:
@@ -119,22 +118,25 @@ def test_create_optuna_distribution_from_override(input: Any, expected: Any) ->
119
118
  @mark.parametrize(
120
119
  "input, expected",
121
120
  [
122
- (["key=choice(1,2)"], ({"key": CategoricalDistribution([1, 2])}, {})),
123
- (["key=5"], ({}, {"key": "5"})),
121
+ (["key=choice(1,2)"], ({"key": CategoricalDistribution([1, 2])}, {}, [])),
122
+ (["key=5"], ({}, {"key": "5"}, [])),
124
123
  (
125
124
  ["key1=choice(1,2)", "key2=5"],
126
- ({"key1": CategoricalDistribution([1, 2])}, {"key2": "5"}),
125
+ ({"key1": CategoricalDistribution([1, 2])}, {"key2": "5"}, []),
127
126
  ),
128
127
  (
129
128
  ["key1=choice(1,2)", "key2=5", "key3=range(1,3)"],
130
129
  (
131
130
  {
132
131
  "key1": CategoricalDistribution([1, 2]),
133
- "key3": IntUniformDistribution(1, 3),
132
+ "key3": IntDistribution(1, 3),
134
133
  },
135
134
  {"key2": "5"},
135
+ [],
136
136
  ),
137
137
  ),
138
+ (["~z"], ({}, {}, ["~z"])),
139
+ (["~z=10"], ({}, {}, ["~z=10"])),
138
140
  ],
139
141
  )
140
142
  def test_create_params_from_overrides(input: Any, expected: Any) -> None:
@@ -380,23 +382,28 @@ def test_failure_rate(max_failure_rate: float, tmpdir: Path) -> None:
380
382
  assert error_string not in err
381
383
 
382
384
 
383
- def test_example_with_deprecated_search_space(
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(OmegaConf.structured(MOTPESamplerConfig))
391
+
392
+
393
+ def test_example_with_removed_motpe(
384
394
  tmpdir: Path,
385
395
  ) -> None:
386
396
  cmd = [
387
- "-W ignore::UserWarning",
388
- "example/sphere.py",
397
+ sys.executable,
398
+ "example/multi-objective.py",
389
399
  "--multirun",
390
400
  "--config-dir=tests/conf",
391
- "--config-name=test_deprecated_search_space",
401
+ "--config-name=test_motpe",
392
402
  "hydra.sweep.dir=" + str(tmpdir),
393
403
  "hydra.job.chdir=True",
394
404
  "hydra.sweeper.n_trials=20",
395
405
  "hydra.sweeper.n_jobs=1",
396
406
  ]
397
407
 
398
- run_optuna_script(cmd)
399
- returns = OmegaConf.load(f"{tmpdir}/optimization_results.yaml")
400
- assert isinstance(returns, DictConfig)
401
- assert returns.name == "optuna"
402
- assert abs(returns["best_params"]["x"]) <= 5.5
408
+ out, err = run_process(cmd, print_error=False, raise_exception=False)
409
+ assert "The 'motpe' sampler was removed in Optuna 4.0" in err
@@ -1,3 +0,0 @@
1
- hydra-core>=1.1.0.dev7
2
- optuna<3.0.0,>=2.10.0
3
- sqlalchemy~=1.3.0