Skip to content

Commit

Permalink
Merge pull request #823 from bouthilx/hotfix/reduce_db_io
Browse files Browse the repository at this point in the history
Reduce DB I/O during optimization
  • Loading branch information
bouthilx authored Mar 7, 2022
2 parents 6a3f9be + 588fd27 commit 7905dd5
Show file tree
Hide file tree
Showing 5 changed files with 479 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
repo_root = os.path.dirname(os.path.abspath(__file__))


tests_require = ["pytest>=3.0.0", "scikit-learn"]
tests_require = ["pytest>=3.0.0", "scikit-learn", "ptera>=1.1.0"]


packages = [ # Packages must be sorted alphabetically to ease maintenance and merges.
Expand Down
11 changes: 9 additions & 2 deletions src/orion/client/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def run(self):
def should_sample(self):
"""Check if more trials could be generated"""

if self.is_broken or self.is_done:
if self.free_worker <= 0 or (self.is_broken or self.is_done):
return 0

pending = len(self.pending_trials) + self.trials
Expand Down Expand Up @@ -332,8 +332,9 @@ def gather(self):

to_be_raised = None
log.debug(f"Gathered new results {len(results)}")

# register the results
# NOTE: For Ptera instrumentation
trials = 0 # pylint:disable=unused-variable
for result in results:
trial = self.pending_trials.pop(result.future)

Expand All @@ -342,6 +343,8 @@ def gather(self):
# NB: observe release the trial already
self.client.observe(trial, result.value)
self.trials += 1
# NOTE: For Ptera instrumentation
trials = self.trials # pylint:disable=unused-variable
except InvalidResult as exception:
# stop the optimization process if we received `InvalidResult`
# as all the trials are assumed to be returning those
Expand Down Expand Up @@ -413,15 +416,19 @@ def _suggest_trials(self, count):

# non critical errors
except WaitingForTrials:
log.debug("Runner cannot sample because WaitingForTrials")
break

except ReservationRaceCondition:
log.debug("Runner cannot sample because ReservationRaceCondition")
break

except LockAcquisitionTimeout:
log.debug("Runner cannot sample because LockAcquisitionTimeout")
break

except CompletedExperiment:
log.debug("Runner cannot sample because CompletedExperiment")
break

return trials
Loading

0 comments on commit 7905dd5

Please sign in to comment.