Skip to content

Commit

Permalink
Add IDLE message to optimizer to allow idle executors (logicalclocks#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzmeister authored May 14, 2020
1 parent 5355046 commit 17d6816
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions maggy/core/experimentdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,17 @@ def _target_function(self):
msg["partition_id"], None
)
self.experiment_done = True
elif trial == "IDLE":
self.add_message(
{
"type": "IDLE",
"partition_id": msg["partition_id"],
"idle_start": time.time(),
}
)
self.server.reservations.assign_trial(
msg["partition_id"], None
)
else:
with trial.lock:
trial.start = time.time()
Expand All @@ -464,6 +475,34 @@ def _target_function(self):
)
self.add_trial(trial)

# 4. Let executor be idle
elif msg["type"] == "IDLE":
# execute only every 0.1 seconds but do not block thread
if (
self.experiment_type == "optimization"
and time.time() - msg["idle_start"] > 0.1
):
trial = self.optimizer.get_suggestion()
if trial is None:
self.server.reservations.assign_trial(
msg["partition_id"], None
)
self.experiment_done = True
elif trial == "IDLE":
# reset timeout
msg["idle_start"] = time.time()
self.add_message(msg)
else:
with trial.lock:
trial.start = time.time()
trial.status = Trial.SCHEDULED
self.server.reservations.assign_trial(
msg["partition_id"], trial.trial_id
)
self.add_trial(trial)
elif self.experiment_type == "optimization":
self.add_message(msg)

# 4. REG
elif msg["type"] == "REG":
if self.experiment_type == "optimization":
Expand Down

0 comments on commit 17d6816

Please sign in to comment.