mirror of
https://github.com/wassname/ray.git
synced 2026-07-24 13:20:22 +08:00
[tune] Cancel Experiment via Client (#7719)
* init cancel * testing * Update python/ray/tune/tests/test_tune_server.py Co-Authored-By: Richard Liaw <rliaw@berkeley.edu> * Apply suggestions from code review * Apply suggestions from code review * finished * set_finished Co-authored-by: ijrsvt <ian.rodney@gmail.com>
This commit is contained in:
@@ -73,7 +73,7 @@ class BasicVariantGenerator(SearchAlgorithm):
|
||||
trials = list(self._trial_generator)
|
||||
if self._shuffle:
|
||||
random.shuffle(trials)
|
||||
self._finished = True
|
||||
self.set_finished()
|
||||
return trials
|
||||
|
||||
def _generate_trials(self, num_samples, unresolved_spec, output_path=""):
|
||||
@@ -104,6 +104,3 @@ class BasicVariantGenerator(SearchAlgorithm):
|
||||
evaluated_params=flatten_resolved_vars(resolved_vars),
|
||||
trial_id=trial_id,
|
||||
experiment_tag=experiment_tag)
|
||||
|
||||
def is_finished(self):
|
||||
return self._finished
|
||||
|
||||
@@ -10,6 +10,7 @@ class SearchAlgorithm:
|
||||
|
||||
See also: `ray.tune.suggest.BasicVariantGenerator`.
|
||||
"""
|
||||
_finished = False
|
||||
|
||||
def add_configurations(self, experiments):
|
||||
"""Tracks given experiment specifications.
|
||||
@@ -62,4 +63,8 @@ class SearchAlgorithm:
|
||||
|
||||
Can return True before all trials have finished executing.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
return self._finished
|
||||
|
||||
def set_finished(self):
|
||||
"""Marks the search algorithm as finished."""
|
||||
self._finished = True
|
||||
|
||||
@@ -34,11 +34,11 @@ class SuggestionAlgorithm(SearchAlgorithm):
|
||||
self._parser = make_parser()
|
||||
self._trial_generator = []
|
||||
self._counter = 0
|
||||
self._finished = False
|
||||
self._metric = metric
|
||||
assert mode in ["min", "max"]
|
||||
self._mode = mode
|
||||
self._use_early_stopped = use_early_stopped_trials
|
||||
self._finished = False
|
||||
|
||||
def add_configurations(self, experiments):
|
||||
"""Chains generator given experiment specifications.
|
||||
@@ -69,7 +69,7 @@ class SuggestionAlgorithm(SearchAlgorithm):
|
||||
return trials
|
||||
trials += [trial]
|
||||
|
||||
self._finished = True
|
||||
self.set_finished()
|
||||
return trials
|
||||
|
||||
def _generate_trials(self, num_samples, experiment_spec, output_path=""):
|
||||
@@ -105,9 +105,6 @@ class SuggestionAlgorithm(SearchAlgorithm):
|
||||
experiment_tag=tag,
|
||||
trial_id=trial_id)
|
||||
|
||||
def is_finished(self):
|
||||
return self._finished
|
||||
|
||||
def suggest(self, trial_id):
|
||||
"""Queries the algorithm to retrieve the next set of parameters.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user