def work_done(worker_id): worker = db.get_worker_by_id(worker_id) if worker: changes = worker.clear_task() return db.update_worker(changes, worker_id) return None
def add_status(worker_id, progress, message): worker = get_worker(worker_id) if worker: changes = worker.set_status(progress, message) return db.update_worker(changes, worker_id) return None
def _assign_parent_task(worker_id, worker): with mutex: scheduled_experiment = scheduler.get_next() if not scheduled_experiment: return None task_id, task = ts.search_task_by_order(scheduled_experiment) assigned_task_id, experiment_ids = _assign_task( worker_id, task.assemble_task_id, ats, True) if not assigned_task_id: assigned_task_id, experiment_ids = _assign_task( worker_id, task.learn_task_id, lts, False) if not assigned_task_id: return None for exp_id in experiment_ids: task_id, task = ts.search_task_by_order(exp_id) if not task_id: scheduler.remove_experiment(exp_id) task_dict = ats.get_config_by_task_id( assigned_task_id) or lts.get_config_by_task_id(assigned_task_id) worker_changes = worker.new_task(assigned_task_id) worker_result_id = db.update_worker(worker_changes, worker_id) if not worker_result_id or not assigned_task_id: return None return task_dict
def assign_task(worker_id, worker, task_store): task_id, task = task_store.get_unassigned_task() if task_id: task_dict = task_store.get_config_by_task_id(task_id) if not task_dict: return None, None worker_changes = worker.new_task(task_id) task_changes = task.assign_to(worker_id) worker_result_id = db.update_worker(worker_changes, worker_id) task_result_id = task_store.update_task(task_changes, task_id) if worker_result_id and task_result_id: return task_id, task_dict return None, None
def ping_worker(worker_id, worker): changes = worker.ping() return db.update_worker(changes, worker_id)
def update_worker(changes, task_id): return db.update_worker(changes, task_id)
def update_worker(changes, worker_id): return db.update_worker(changes, worker_id)