[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:
Richard Liaw
2020-03-24 20:30:12 -07:00
committed by GitHub
co-authored by ijrsvt
parent a519b4f2a9
commit 54a892bb84
8 changed files with 58 additions and 29 deletions
+1 -4
View File
@@ -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
+6 -1
View File
@@ -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
+2 -5
View File
@@ -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.