mirror of
https://github.com/wassname/ray.git
synced 2026-07-02 04:25:18 +08:00
[tune] implement shim instantiation (#10456)
* Create ray.tune.suggest.create.create_scheduler * Update __init__.py * Resolve conflict in __init__.py * Create ray.tune.schedulers.create.create_scheduler * Update __init__.py * Move create_scheduler to tune.schedulers.__init__ * Move create_searcher to tune.suggest.__init__ * Delete tune.suggest.create * Delete tune.schedulers.create * Update imports for shim functions in tune.__init__ * Remove shim from tune.suggest.__init__.__all__ * Remove shim from tune.schedulers.__init__.__all__ * Add ShimCreationTest * Move ShimCreationTest to test_api * Delete test_shim.py * Add docstring for ray.tune.create_scheduler * Add docstring to ray.tune.create_searcher * Fix typo in ray.tune.create_scheduler docstring * Fix lint errors in tune.schedulers.__init__ * Fix lint errors in tune.suggest.__init__ * Fix lint errors in tune.suggest.__init__ * Fix lint errors in tune.schedulers.__init__ * Fix imports in test_api * Fix lint errors in test_api * Fix kwargs in create_searcher * Fix kwargs in create_scheduler * Merge branch 'master' into shim-instantiation * Update use-case in docs in tune.create_scheduler * Update use-case in docs in tune.create_searcher * Remove duplicate pytest run from test_api * Add check to create_searcher Co-authored-by: Richard Liaw <rliaw@berkeley.edu> * Add check to create_scheduler * lint * Compare types of instances in test_api Co-authored-by: Richard Liaw <rliaw@berkeley.edu> * Add tune.create_searcher to docs * Fix doc build * Fix tests * Add tune.create_scheduler to docs * Fix tests * Fix lint errors * Update Ax search for master * Fix metric kwarg for Ax in test_api * Fix doc build * Fix HyperOptSearch import in test_api * Fix HyperOptSearch import in create_searcher Co-authored-by: Richard Liaw <rliaw@berkeley.edu>
This commit is contained in:
@@ -14,7 +14,8 @@ from ray import tune
|
||||
from ray.tune import (DurableTrainable, Trainable, TuneError, Stopper,
|
||||
EarlyStopping)
|
||||
from ray.tune import register_env, register_trainable, run_experiments
|
||||
from ray.tune.schedulers import TrialScheduler, FIFOScheduler
|
||||
from ray.tune.schedulers import (TrialScheduler, FIFOScheduler,
|
||||
AsyncHyperBandScheduler)
|
||||
from ray.tune.trial import Trial
|
||||
from ray.tune.result import (TIMESTEPS_TOTAL, DONE, HOSTNAME, NODE_IP, PID,
|
||||
EPISODES_TOTAL, TRAINING_ITERATION,
|
||||
@@ -24,6 +25,8 @@ from ray.tune.logger import Logger
|
||||
from ray.tune.experiment import Experiment
|
||||
from ray.tune.resources import Resources
|
||||
from ray.tune.suggest import grid_search
|
||||
from ray.tune.suggest.hyperopt import HyperOptSearch
|
||||
from ray.tune.suggest.ax import AxSearch
|
||||
from ray.tune.suggest._mock import _MockSuggestionAlgorithm
|
||||
from ray.tune.utils import (flatten_dict, get_pinned_object,
|
||||
pin_in_object_store)
|
||||
@@ -1105,6 +1108,30 @@ class TrainableFunctionApiTest(unittest.TestCase):
|
||||
self.assertIn("LOG_STDERR", content)
|
||||
|
||||
|
||||
class ShimCreationTest(unittest.TestCase):
|
||||
def testCreateScheduler(self):
|
||||
kwargs = {"metric": "metric_foo", "mode": "min"}
|
||||
|
||||
scheduler = "async_hyperband"
|
||||
shim_scheduler = tune.create_scheduler(scheduler, **kwargs)
|
||||
real_scheduler = AsyncHyperBandScheduler(**kwargs)
|
||||
assert type(shim_scheduler) is type(real_scheduler)
|
||||
|
||||
def testCreateSearcher(self):
|
||||
kwargs = {"metric": "metric_foo", "mode": "min"}
|
||||
|
||||
searcher_ax = "ax"
|
||||
shim_searcher_ax = tune.create_searcher(searcher_ax, **kwargs)
|
||||
real_searcher_ax = AxSearch(space=[], **kwargs)
|
||||
assert type(shim_searcher_ax) is type(real_searcher_ax)
|
||||
|
||||
searcher_hyperopt = "hyperopt"
|
||||
shim_searcher_hyperopt = tune.create_searcher(searcher_hyperopt,
|
||||
**kwargs)
|
||||
real_searcher_hyperopt = HyperOptSearch({}, **kwargs)
|
||||
assert type(shim_searcher_hyperopt) is type(real_searcher_hyperopt)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
Reference in New Issue
Block a user