def test_load_next_ready_for_pass_error(self): ed = ExperimentDefinition() self.addCleanup(self._del_table, "experiment") ed.create_table(self._db) ed_1 = ExperimentDefinition() ed_2 = ExperimentDefinition() ed_3 = ExperimentDefinition() ed_4 = ExperimentDefinition() ed_1._workflow_handling = "manifest" ed_1._work_state = "analysis_done" ed_2._workflow_handling = "multi" ed_2._work_state = "analysis_done" ed_3._workflow_handling = "multi" ed_3._work_state = "analysis_done" target_trace_id = ed_1.store(self._db) ed_2.store(self._db) ed_3.store(self._db) ed_4.store(self._db) #ed_1 to ed_4 should be skipped. ed_1b = ExperimentDefinition() ed_2b = ExperimentDefinition() ed_3b = ExperimentDefinition() ed_1b._workflow_handling = "manifest" ed_1b._work_state = "analysis_done" ed_2b._workflow_handling = "single" ed_2b._work_state = "analysis_done" ed_3b._workflow_handling = "multi" ed_3b._work_state = "analysis_done" target_trace_id_b = ed_1b.store(self._db) ed_2b.store(self._db) ed_3b.store(self._db) ed.load_next_ready_for_pass(self._db) self.assertEqual(target_trace_id_b, ed._trace_id)
def do_work_second_pass(self, db_obj, pre_trace_id): """Takes three experiments, and repeast the workflow analysis for each experiment but only taking into account the first n workflows in each one. n = minimum number of workflows acroos the three traces. Args: - db_obj: DB object configured to access the analysis database. - trace_id: If set to an integer, it will analyze the experiments identified by trace_id, trace_id+1, trace_id+2. """ there_are_more=True while there_are_more: ed_manifest = ExperimentDefinition() ed_single = ExperimentDefinition() ed_multi = ExperimentDefinition() if pre_trace_id: trace_id=int(pre_trace_id) ed_manifest.load(db_obj, trace_id) there_are_more=True else: there_are_more = ed_manifest.load_next_ready_for_pass(db_obj) trace_id=int(ed_manifest._trace_id) if there_are_more: ed_single.load(db_obj, trace_id+1) ed_multi.load(db_obj, trace_id+2) ed_list=[ed_manifest, ed_single, ed_multi] print(("Reading workflow info for traces: {0}".format( [ed._trace_id for ed in ed_list]))) if (ed_manifest._workflow_handling!="manifest" or ed_single._workflow_handling!="single" or ed_multi._workflow_handling!="multi"): print(("Incorrect workflow handling for traces" "({0}, {1}, {2}): ({3}, {4}, {5})",format( ed_manifest._trace_id, ed_single._trace_id, ed_multi._trace_id, ed_manifest._workflow_handling, ed_single._workflow_handling, ed_multi._workflow_handling) )) print ("Exiting...") exit() for ed in ed_list: ed.mark_pre_second_pass(db_obj) num_workflows=None for ed in ed_list: exp_wfs=self.get_num_workflows(db_obj, ed._trace_id) if num_workflows is None: num_workflows = exp_wfs else: num_workflows=min(num_workflows, exp_wfs) print(("Final workflow count: {0}".format(num_workflows))) for ed in ed_list: print(("Doing second pass for trace: {0}".format( ed._trace_id))) er = AnalysisRunnerSingle(ed) er.do_workflow_limited_analysis(db_obj, num_workflows) print(("Second pass completed for {0}".format( [ed._trace_id for ed in ed_list]))) if pre_trace_id: break