def itest_input_wf(self, lp, fworker, tmpdir, input_scf_si_low, use_autoparal): """ Tests a simple scf run with the InputFWWorkflow """ wf = InputFWWorkflow(input_scf_si_low, task_type=ScfFWTask, autoparal=use_autoparal) scf_fw_id = wf.fw.fw_id old_new = wf.add_to_db(lpad=lp) scf_fw_id = old_new[scf_fw_id] rapidfire(lp, fworker, m_dir=str(tmpdir)) fw = lp.get_fw_by_id(scf_fw_id) assert fw.state == "COMPLETED" wf = lp.get_wf_by_fw_id(scf_fw_id) assert wf.state == "COMPLETED" assert len(wf.leaf_fw_ids) == 1 if self.check_numerical_values: task = load_abitask(lp.get_fw_by_id(wf.leaf_fw_ids[0])) with task.open_gsr() as gsr: assert gsr.energy == pytest.approx(-241.239839134, rel=0.05)
def itest_scf(self, lp, fworker, fwp, tmpdir, benchmark_input_scf): wf = InputFWWorkflow(benchmark_input_scf, task_type=ScfFWTask) scf_fw_id = wf.fw.fw_id old_new = wf.add_to_db(lpad=lp) scf_fw_id = old_new[scf_fw_id] rapidfire(lp, fworker, m_dir=str(tmpdir)) fw = lp.get_fw_by_id(scf_fw_id) assert fw.state == "COMPLETED" # Build the flow flow = abilab.Flow(fwp.workdir, manager=fwp.manager) work = flow.register_task(benchmark_input_scf, task_class=abilab.ScfTask) flow.allocate() flow.build_and_pickle_dump() # Run t0, and check status t0 = work[0] t0.start_and_wait() t0.check_status() assert t0.status == t0.S_OK assert match_results(fw, t0)
def itest_run(self, lp, fworker, tmpdir, input_scf_si_low): wf = InputFWWorkflow(input_scf_si_low, task_type=ScfFWTask) scf_fw_id = wf.fw.fw_id old_new = wf.add_to_db(lpad=lp) scf_fw_id = old_new[scf_fw_id] rapidfire(lp, fworker, m_dir=str(tmpdir)) fw = lp.get_fw_by_id(scf_fw_id) assert fw.state == "COMPLETED"
def itest_scf_not_converged(self, lp, fworker, fwp, tmpdir, benchmark_input_scf): old_cwd = os.getcwd() benchmark_input_scf.set_vars(nstep=4) wf = InputFWWorkflow(benchmark_input_scf, task_type=ScfFWTask) scf_fw_id = wf.fw.fw_id old_new = wf.add_to_db(lpad=lp) scf_fw_id = old_new[scf_fw_id] while lp.run_exists(fworker): rapidfire(lp, fworker, m_dir=str(tmpdir)) wf = lp.get_wf_by_fw_id(scf_fw_id) assert wf.state == "COMPLETED" num_restarts_fw = wf.fws[-1].tasks[0].restart_info.num_restarts # Build the flow flow = abilab.Flow(fwp.workdir, manager=fwp.manager) work = flow.register_task(benchmark_input_scf, task_class=abilab.ScfTask) flow.allocate() flow.build_and_pickle_dump() # go to the main dir (to have the abipy configuration files) os.chdir(old_cwd) # Run t0, and check status t0 = work[0] assert flow.make_scheduler().start() == 0 num_restarts_abiflow = t0.num_restarts assert num_restarts_fw == num_restarts_abiflow assert match_results(lp.get_wf_by_fw_id(scf_fw_id).fws[-1], t0)
def itest_not_converged(self, lp, fworker, tmpdir, input_scf_si_low): input_scf_si_low.set_vars(nstep=5) wf = InputFWWorkflow(input_scf_si_low, task_type=ScfFWTask) scf_fw_id = wf.fw.fw_id old_new = wf.add_to_db(lpad=lp) scf_fw_id = old_new[scf_fw_id] rapidfire(lp, fworker, m_dir=str(tmpdir), nlaunches=1) fw = lp.get_fw_by_id(scf_fw_id) assert fw.state == "COMPLETED" launch = fw.launches[-1] assert any(event['@class'] == 'ScfConvergenceWarning' for event in launch.action.stored_data['events']) links = lp.get_wf_by_fw_id(scf_fw_id).links assert scf_fw_id in links fw_child_id = links[scf_fw_id][0] fw_child = lp.get_fw_by_id(fw_child_id) assert fw_child.state == "READY" rapidfire(lp, fworker, m_dir=str(tmpdir), nlaunches=1) fw_child = lp.get_fw_by_id(scf_fw_id) assert fw_child.state == "COMPLETED" # check that the new fw didn't generate further fws assert fw_child not in lp.get_wf_by_fw_id(scf_fw_id).links