mirror of
https://github.com/wassname/ray.git
synced 2026-09-11 12:43:20 +08:00
[tune] lazy trials (#10802)
* Lazily fill trial queue * Update interface * Update end to end reporter test * Removed `next_trials()` method * Lint * Print total number of samples to be generated in progress reporter. Allow infinite samples. * Nit check
This commit is contained in:
@@ -56,6 +56,8 @@ class AutoMLSearcher(SearchAlgorithm):
|
||||
self._unfinished_count = 0
|
||||
self._running_trials = {}
|
||||
self._completed_trials = {}
|
||||
self._next_trials = []
|
||||
self._next_trial_iter = None
|
||||
|
||||
self._iteration = 0
|
||||
self._total_trial_num = 0
|
||||
@@ -68,10 +70,27 @@ class AutoMLSearcher(SearchAlgorithm):
|
||||
"""Returns the Trial object with the best reward_attr"""
|
||||
return self.best_trial
|
||||
|
||||
def next_trials(self):
|
||||
def next_trial(self):
|
||||
if not self._next_trial_iter:
|
||||
self._generate_next_trials()
|
||||
if not self._next_trials:
|
||||
self.set_finished()
|
||||
return None
|
||||
self._next_trial_iter = iter(self._next_trials)
|
||||
|
||||
try:
|
||||
return next(self._next_trial_iter)
|
||||
except StopIteration:
|
||||
self._next_trials = []
|
||||
self._next_trial_iter = None
|
||||
return None
|
||||
|
||||
def _generate_next_trials(self):
|
||||
self._next_trials = []
|
||||
|
||||
if self._unfinished_count > 0:
|
||||
# Last round not finished
|
||||
return []
|
||||
return
|
||||
|
||||
trials = []
|
||||
raw_param_list, extra_arg_list = self._select()
|
||||
@@ -110,7 +129,7 @@ class AutoMLSearcher(SearchAlgorithm):
|
||||
"new": ntrial,
|
||||
"total": self._total_trial_num
|
||||
})
|
||||
return trials
|
||||
self._next_trials = trials
|
||||
|
||||
def on_trial_result(self, trial_id, result):
|
||||
if not result:
|
||||
|
||||
Reference in New Issue
Block a user