mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00
[tune] Improve missing search dependency info (#23691)
Replaces FLAML searchers with a dummy class that throws an informative error on init if FLAML is not installed, removes ConfigSpace import in BOHB example code, adds a note to examples using external dependencies.
This commit is contained in:
parent
a6bcb6cd1e
commit
434d457ad1
20 changed files with 59 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of AxSearch with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the Ax library to be installed (`pip install ax-platform sqlalchemy`).
|
||||
"""
|
||||
import numpy as np
|
||||
import time
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of BayesOpt with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the BayesOpt library to be installed (`pip install bayesian-optimization`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of BlendSearch with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the FLAML library to be installed (`pip install flaml`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""This example demonstrates the usage of BOHB with Ray Tune.
|
||||
|
||||
Requires the HpBandSter and ConfigSpace libraries to be installed
|
||||
(`pip install hpbandster ConfigSpace`).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import time
|
||||
|
@ -45,8 +51,6 @@ class MyTrainableClass(Trainable):
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import ConfigSpace as CS # noqa: F401
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--server-address",
|
||||
|
@ -70,6 +74,7 @@ if __name__ == "__main__":
|
|||
}
|
||||
|
||||
# Optional: Pass the parameter space yourself
|
||||
# import ConfigSpace as CS
|
||||
# config_space = CS.ConfigurationSpace()
|
||||
# config_space.add_hyperparameter(
|
||||
# CS.UniformFloatHyperparameter("width", lower=0, upper=20))
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of CFO with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the FLAML library to be installed (`pip install flaml`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of Dragonfly with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the Dragonfly library to be installed (`pip install dragonfly-opt`).
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of HEBO with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the HEBO library to be installed (`pip install 'HEBO>=0.2.0'`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the HyperOpt library to be installed (`pip install hyperopt`).
|
||||
|
||||
For an example of using a Tune search space, see
|
||||
:doc:`/tune/examples/hyperopt_example`.
|
||||
"""
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of Nevergrad with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the Nevergrad library to be installed (`pip install nevergrad`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the Optuna library to be installed (`pip install optuna`).
|
||||
|
||||
For an example of using a Tune search space, see
|
||||
:doc:`/tune/examples/optuna_example`.
|
||||
"""
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the Optuna library to be installed (`pip install optuna`).
|
||||
|
||||
For an example of using an Optuna define-by-run function, see
|
||||
:doc:`/tune/examples/optuna_define_by_run_example`.
|
||||
"""
|
||||
|
|
|
@ -3,6 +3,8 @@ multi-objective optimization.
|
|||
|
||||
Please note that schedulers may not work correctly with multi-objective
|
||||
optimization.
|
||||
|
||||
Requires the Optuna library to be installed (`pip install optuna`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of SigOpt with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the SigOpt library to be installed (`pip install sigopt`).
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
"""Example using Sigopt's multi-objective functionality."""
|
||||
"""
|
||||
Example using Sigopt's multi-objective functionality.
|
||||
|
||||
Requires the SigOpt library to be installed (`pip install sigopt`).
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
""""Example using Sigopt's support for prior beliefs."""
|
||||
""""
|
||||
Example using Sigopt's support for prior beliefs.
|
||||
|
||||
Requires the SigOpt library to be installed (`pip install sigopt`).
|
||||
"""
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
"""This example demonstrates the usage of Skopt with Ray Tune.
|
||||
"""This example demonstrates the usage of SkOpt with Ray Tune.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the SkOpt library to be installed (`pip install scikit-optimize`).
|
||||
"""
|
||||
import time
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
"""This example demonstrates the usage of ZOOptSearch.
|
||||
|
||||
It also checks that it is usable with a separate scheduler.
|
||||
|
||||
Requires the ZOOpt library to be installed (`pip install zoopt`).
|
||||
"""
|
||||
import time
|
||||
|
||||
from ray import tune
|
||||
from ray.tune.suggest.zoopt import ZOOptSearch
|
||||
from ray.tune.schedulers import AsyncHyperBandScheduler
|
||||
from zoopt import ValueType # noqa: F401
|
||||
|
||||
|
||||
def evaluation_fn(step, width, height):
|
||||
|
@ -50,6 +51,7 @@ if __name__ == "__main__":
|
|||
num_samples = 10 if args.smoke_test else 1000
|
||||
|
||||
# Optional: Pass the parameter space yourself
|
||||
# from zoopt import ValueType
|
||||
# space = {
|
||||
# # for continuous dimensions: (continuous, search_range, precision)
|
||||
# "height": (ValueType.CONTINUOUS, [-10, 10], 1e-2),
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
try:
|
||||
from flaml import BlendSearch, CFO
|
||||
except ImportError:
|
||||
BlendSearch = CFO = None
|
||||
|
||||
class _DummyErrorRaiser:
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
raise ImportError(
|
||||
"FLAML must be installed! "
|
||||
"You can install FLAML with the command: "
|
||||
"`pip install flaml`."
|
||||
)
|
||||
|
||||
BlendSearch = CFO = _DummyErrorRaiser
|
||||
|
|
|
@ -139,7 +139,7 @@ class HEBOSearch(Searcher):
|
|||
):
|
||||
assert hebo is not None, (
|
||||
"HEBO must be installed! You can install HEBO with"
|
||||
" the command: `pip install 'HEBO>=0.2.0'."
|
||||
" the command: `pip install 'HEBO>=0.2.0'`."
|
||||
"This error may also be caused if HEBO"
|
||||
" dependencies have bad versions. Try updating HEBO"
|
||||
" first."
|
||||
|
|
|
@ -15,7 +15,7 @@ class TestSoftImports(unittest.TestCase):
|
|||
|
||||
# ensure that the dependencies aren't actually installed
|
||||
if searcher and name not in ("variant_generator", "random"):
|
||||
with self.assertRaises(AssertionError):
|
||||
with self.assertRaises((AssertionError, ImportError)):
|
||||
searcher()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue