def test_not_defaults(self): with patch("custodian.qchem.jobs.os.putenv") as putenv_patch: myjob = QCJob(qchem_command="qchem -slurm", multimode="mpi", input_file="different.qin", output_file="not_default.qout", max_cores=12, scratch_dir="/not/default/scratch/", backup=False) self.assertEqual(myjob.current_command, ["qchem", "-slurm", "-np", "12", "different.qin", "not_default.qout"]) myjob.setup() self.assertEqual(putenv_patch.call_args_list[0][0][0], "QCSCRATCH") self.assertEqual(putenv_patch.call_args_list[0][0][1], "/not/default/scratch/")
def test_defaults(self): with patch("custodian.qchem.jobs.shutil.copy") as copy_patch: myjob = QCJob(qchem_command="qchem", max_cores=32) self.assertEqual(myjob.current_command, "qchem -nt 32 mol.qin mol.qout scratch") myjob.setup() self.assertEqual(copy_patch.call_args_list[0][0][0], "mol.qin") self.assertEqual(copy_patch.call_args_list[0][0][1], "mol.qin.orig") self.assertEqual(os.environ["QCSCRATCH"], os.getcwd()) self.assertEqual(os.environ["QCTHREADS"], "32") self.assertEqual(os.environ["OMP_NUM_THREADS"], "32")
def test_save_scratch(self): with patch("custodian.qchem.jobs.shutil.copy") as copy_patch: myjob = QCJob(qchem_command="qchem -slurm", max_cores=32, scratch_dir=os.getcwd(), save_scratch=True, save_name="freq_scratch") self.assertEqual(myjob.current_command, ' qchem -slurm -nt 32 mol.qin mol.qout freq_scratch') myjob.setup() self.assertEqual(copy_patch.call_args_list[0][0][0], "mol.qin") self.assertEqual(copy_patch.call_args_list[0][0][1], "mol.qin.orig") self.assertEqual(os.environ["QCSCRATCH"],os.getcwd()) self.assertEqual(os.environ["QCTHREADS"],"32") self.assertEqual(os.environ["OMP_NUM_THREADS"],"32")
def run_QChem(label, encode=None, rem=None, pcm=None, solvent=None, more_info=None, self_correct=True): inname = label + '.inp' outname = label + '.out' logname = label + '.log' command = 'qchem' handlers = [QChemErrorHandler(input_file=inname, output_file=outname)] """If no encoding provided, assume this is the first Firework in workflow and that input file is already written. 'label' is the name of the file without the extension (e.g. .inp, .out). otherwise, take encoding, form new QCInput and write input file, then run. """ if encode != None: qcin = encode_to_QCInput(encode=encode, rem=rem, pcm=pcm, solvent=solvent) qcin.write_file(inname) if self_correct: jobs = [ QCJob(input_file=inname, output_file=outname, qchem_command=command, max_cores=multiprocessing.cpu_count(), qclog_file=logname) ] c = Custodian(handlers, jobs, max_errors=10) c.run() else: job = QCJob(input_file=inname, output_file=outname, qchem_command=command, max_cores=multiprocessing.cpu_count(), qclog_file=logname) job.setup() p = job.run() p.wait() """ qclog = open(logname, "w") current_command = ['qchem', '-nt', '20',inname] print(current_command) subprocess.run(current_command, stdout=qclog, shell=True) """ try: output = [QCOutput(filename=outname)] except: output = QCOutput.multiple_outputs_from_file(QCOutput, filename) return QCOutput_to_encode(output, more_info=more_info)
def test_defaults(self): with patch("custodian.qchem.jobs.os.putenv") as putenv_patch: with patch("custodian.qchem.jobs.shutil.copy") as copy_patch: myjob = QCJob(qchem_command="qchem") self.assertEqual(myjob.current_command, ["qchem", "-nt", "32", "mol.qin", "mol.qout"]) myjob.setup() self.assertEqual(copy_patch.call_args_list[0][0][0], "mol.qin") self.assertEqual(copy_patch.call_args_list[0][0][1], "mol.qin.orig") self.assertEqual(putenv_patch.call_args_list[0][0][0], "QCSCRATCH") self.assertEqual(putenv_patch.call_args_list[0][0][1], "/dev/shm/qcscratch/") self.assertEqual(putenv_patch.call_args_list[1][0][0], "QCTHREADS") self.assertEqual(putenv_patch.call_args_list[1][0][1], "32") self.assertEqual(putenv_patch.call_args_list[2][0][0], "OMP_NUM_THREADS") self.assertEqual(putenv_patch.call_args_list[2][0][1], "32")
def test_not_defaults(self): myjob = QCJob( qchem_command="qchem -slurm", multimode="mpi", input_file="different.qin", output_file="not_default.qout", max_cores=12, calc_loc="/not/default/", backup=False, ) self.assertEqual(myjob.current_command, "qchem -slurm -np 12 different.qin not_default.qout scratch") myjob.setup() self.assertEqual(os.environ["QCSCRATCH"], os.getcwd()) self.assertEqual(os.environ["QCLOCALSCR"], "/not/default/")
def test_defaults(self): with patch("custodian.qchem.jobs.os.putenv") as putenv_patch: with patch("custodian.qchem.jobs.shutil.copy") as copy_patch: myjob = QCJob(qchem_command="qchem", max_cores=32) self.assertEqual(myjob.current_command, ["qchem", "-nt", "32", "mol.qin", "mol.qout"]) myjob.setup() self.assertEqual(copy_patch.call_args_list[0][0][0], "mol.qin") self.assertEqual(copy_patch.call_args_list[0][0][1], "mol.qin.orig") self.assertEqual(putenv_patch.call_args_list[0][0][0], "QCSCRATCH") self.assertEqual(putenv_patch.call_args_list[0][0][1], "/dev/shm/qcscratch/") self.assertEqual(putenv_patch.call_args_list[1][0][0], "QCTHREADS") self.assertEqual(putenv_patch.call_args_list[1][0][1], "32") self.assertEqual(putenv_patch.call_args_list[2][0][0], "OMP_NUM_THREADS") self.assertEqual(putenv_patch.call_args_list[2][0][1], "32")
def test_not_defaults(self): myjob = QCJob(qchem_command="qchem -slurm", multimode="mpi", input_file="different.qin", output_file="not_default.qout", max_cores=12, scratch_dir="/not/default/scratch/", backup=False) self.assertEqual(myjob.current_command, ' qchem -slurm -np 12 different.qin not_default.qout') myjob.setup() self.assertEqual(os.environ["QCSCRATCH"],"/not/default/scratch/")