Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IDLE message to optimizer to allow idle executors #49

Merged
merged 2 commits into from
May 14, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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