def persist_result(job_type, task_store, task_id, get_result_func, result): try: result = get_result_func(result) if result: experiments = {} task = task_store.get_task_by_id(task_id) change = task.completed(result) success = task_store.update_task(change, task_id) parent_tasks = [(t_id, ts.get_task_by_id(t_id)) for t_id in task.parent_tasks] for p_task_id, p_task in parent_tasks: if p_task.experiment_id in experiments: exp = experiments[p_task.experiment_id] else: exp = ess.get_experiment_summary(p_task.experiment_id) if exp: experiments[p_task.experiment_id] = exp if job_type == "assembling": exp_change = exp.set_assemble_result(p_task_id, result) else: exp_change = exp.set_learn_result(p_task_id, result) success = success and ess.update_experiment_summary(exp_change, p_task.experiment_id) change = p_task.completed(task_id) success = success and ts.update_task(change, p_task_id) return success except Exception as e: return False
def rerun_task(self, exp_id, task_id): exp_sum = ess.get_experiment_summary(exp_id) success, task, a_task, l_task = self._rerun_task(task_id) if success: sum_changes = exp_sum.update_task(task_id, self.create_summary_task(a_task, l_task, task.created_ts)) success = ess.update_experiment_summary(sum_changes, exp_id) return success
def edit_experiment(exp_id, name, md, priority): exp = get_experiment(exp_id) success = True if priority != exp.priority and ts.search_task_by_order(exp_id): scheduler.change_exp_priority(exp_id, priority) changes = exp.edit_experiment(name, md, priority) edit_id = update_experiment(changes, exp_id) return ess.update_experiment_summary(changes, edit_id) and success and edit_id
def rerun_all_tasks(self, exp, exp_id): exp_sum = ess.get_experiment_summary(exp_id) sum_changes = None success = True for t_id in exp.tasks: t_success, task, a_task, l_task = self._rerun_task(t_id) if t_success: sum_changes = exp_sum.update_task(t_id, self.create_summary_task(a_task, l_task, task.created_ts)) if sum_changes: success = success and ess.update_experiment_summary(sum_changes, exp_id) return success
def persist_result(job_type, task_store, task_id, get_result_func, result): try: result = get_result_func(result) if result: experiments = {} task = task_store.get_task_by_id(task_id) change = task.completed(result) success = task_store.update_task(change, task_id) parents = ts.get_assembling_parents( task_id ) if job_type == "assembling" else ts.get_learning_parents( task_id) for p_task_id, p_task in parents: change = p_task.completed(task_id) success = ts.update_task(change, p_task_id) and success if p_task.experiment_id in experiments: exp_sum = experiments[p_task.experiment_id] else: if p_task.learn_task_id: exp = es.get_experiment(p_task.experiment_id) if exp: scheduler.check_experiment( p_task.experiment_id, exp.priority) exp_sum = ess.get_experiment_summary( p_task.experiment_id) if exp_sum: experiments[p_task.experiment_id] = exp_sum if job_type == "assembling": exp_change = exp_sum.set_assemble_result( p_task_id, result) else: exp_change = exp_sum.set_learn_result( p_task_id, result) if exp_sum else None if exp_change: success = ess.update_experiment_summary( exp_change, p_task.experiment_id) and success return bool(success) except Exception as e: return False