@@ -455,6 +455,17 @@ def _target_function(self):
455
455
msg ["partition_id" ], None
456
456
)
457
457
self .experiment_done = True
458
+ elif trial == "IDLE" :
459
+ self .add_message (
460
+ {
461
+ "type" : "IDLE" ,
462
+ "partition_id" : msg ["partition_id" ],
463
+ "idle_start" : time .time (),
464
+ }
465
+ )
466
+ self .server .reservations .assign_trial (
467
+ msg ["partition_id" ], None
468
+ )
458
469
else :
459
470
with trial .lock :
460
471
trial .start = time .time ()
@@ -464,6 +475,34 @@ def _target_function(self):
464
475
)
465
476
self .add_trial (trial )
466
477
478
+ # 4. Let executor be idle
479
+ elif msg ["type" ] == "IDLE" :
480
+ # execute only every 0.1 seconds but do not block thread
481
+ if (
482
+ self .experiment_type == "optimization"
483
+ and time .time () - msg ["idle_start" ] > 0.1
484
+ ):
485
+ trial = self .optimizer .get_suggestion ()
486
+ if trial is None :
487
+ self .server .reservations .assign_trial (
488
+ msg ["partition_id" ], None
489
+ )
490
+ self .experiment_done = True
491
+ elif trial == "IDLE" :
492
+ # reset timeout
493
+ msg ["idle_start" ] = time .time ()
494
+ self .add_message (msg )
495
+ else :
496
+ with trial .lock :
497
+ trial .start = time .time ()
498
+ trial .status = Trial .SCHEDULED
499
+ self .server .reservations .assign_trial (
500
+ msg ["partition_id" ], trial .trial_id
501
+ )
502
+ self .add_trial (trial )
503
+ elif self .experiment_type == "optimization" :
504
+ self .add_message (msg )
505
+
467
506
# 4. REG
468
507
elif msg ["type" ] == "REG" :
469
508
if self .experiment_type == "optimization" :
0 commit comments