def _op_init_pending_run(op, run_dir): run_dir = run_dir or op.run_dir run = op_util.init_run(run_dir) log.debug("initializing run in %s", run.dir) run.init_skel() op_util.set_run_pending(run) return run
def init_trial_run(batch_run, trial_flag_vals, run_dir=None): run = op_util.init_run(run_dir) _link_to_trial(batch_run, run) proto_run = batch_run.batch_proto assert proto_run, "proto_run not initialized for batch %s (%s)" % ( batch_run.id, batch_run.dir, ) util.copytree(proto_run.dir, run.dir) run.write_attr("flags", trial_flag_vals) run.write_attr("label", _trial_label(proto_run, trial_flag_vals)) run.write_attr("op", _trial_op_attr(proto_run, trial_flag_vals)) op_util.set_run_pending(run) op_util.set_run_started(run) return run
def _next_run(state): """Returns the next run for the queue. Note that this call is NOT safe across multiple queue instances. Use `safe_next_run` to ensure that multiple queues is proper locking. """ blocking = _blocking_runs(state) staged = _staged_runs() _sync_state(blocking, staged, state) _log_state(state) for run in staged: if _can_start(run, blocking, state): op_util.set_run_pending(run) return run return None
def _unsafe_next_run(state): """Returns the next run for the queue. Note that this call is NOT safe across multiple queue instances. Use `safe_next_run` to ensure that multiple queues use proper locking. """ blocking = _blocking_runs(state) staged = _staged_runs() _sync_state(blocking, staged, state) _log_state(state) for run in staged: if _can_start(run, blocking, state): # Setting run to PENDING takes it out of the running for # other queues to start. op_util.set_run_pending(run) return run return None
def _unsafe_next_runs(state): """Returns the next runs for the queue. Note that this call is NOT safe across multiple queue instances. Use `safe_next_run` to ensure that multiple queues use proper locking. """ blocking = _blocking_runs(state) staged = _staged_runs() _sync_state_for_blocking(blocking, state) _sync_state_for_staged(staged, state) if state.sync_state_cb: state.sync_state_cb(state, blocking=blocking, staged=staged) startable_runs = [ run for run in staged if _can_start(run, blocking, state) ] next_runs = _limit_startable_runs(startable_runs, state) for run in next_runs: # Setting run to PENDING takes it out of the running for # other queues to start. op_util.set_run_pending(run) return next_runs
def _next_run(state): """Returns the next run for the queue. Note that this call is NOT safe across multiple queue instances. Use `safe_next_run` to ensure that multiple queues is proper locking. """ for run in _staged_runs(): if not state.ignore_running: running = _running(state) if running: if run.id not in state.waiting: log.info( "Found staged run %s (waiting for runs " "to finish: %s)", run.short_id, _runs_desc(running), ) state.logged_waiting = True state.waiting.add(run.id) continue op_util.set_run_pending(run) return run return None