From c6f46f1d99dea247ddb866738808fc9ad6716584 Mon Sep 17 00:00:00 2001 From: Calvin Date: Fri, 24 Nov 2023 19:48:42 +0200 Subject: [PATCH 1/3] Fixed Capitalisation & added more trsh tests --- arc/job/trsh.py | 2 +- arc/job/trsh_test.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/arc/job/trsh.py b/arc/job/trsh.py index 3b9defc340..1ac60cb122 100644 --- a/arc/job/trsh.py +++ b/arc/job/trsh.py @@ -1625,7 +1625,7 @@ def trsh_keyword_nosymm(job_status, ess_trsh_methods, trsh_keyword, couldnt_trsh """ Check if the job requires change of nosymm """ - if 'NoSymm' in job_status['keywords'] and 'nosymm' not in ess_trsh_methods: + if 'NoSymm' in job_status['keywords'] and 'NoSymm' not in ess_trsh_methods: ess_trsh_methods.append('NoSymm') trsh_keyword.append('nosymm') couldnt_trsh = False diff --git a/arc/job/trsh_test.py b/arc/job/trsh_test.py index dd25ccb51b..81bb847741 100644 --- a/arc/job/trsh_test.py +++ b/arc/job/trsh_test.py @@ -311,8 +311,30 @@ def test_trsh_ess_job(self): num_heavy_atoms, cpu_cores, ess_trsh_methods) self.assertTrue(remove_checkfile) + self.assertEqual(ess_trsh_methods, ['change_node', 'int=(Acc2E=14)', 'checkfile=None', 'cartesian', 'NoSymm']) self.assertEqual(trsh_keyword, ['opt=(cartesian)', 'int=(Acc2E=14)', 'nosymm'] ) + # Gaussian: test 3 + job_status = {'keywords': ['SCF', 'GL502', 'NoSymm']} + output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \ + memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status, + job_type, software, fine, memory_gb, + num_heavy_atoms, cpu_cores, ess_trsh_methods) + + self.assertTrue(remove_checkfile) + self.assertIn('scf=(qc)', ess_trsh_methods) + self.assertFalse(couldnt_trsh) + + # Gaussian: test 5 + job_status = {'keywords': ['DiskSpace']} + output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \ + memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status, + job_type, software, fine, memory_gb, + num_heavy_atoms, cpu_cores, ess_trsh_methods) + + self.assertTrue(couldnt_trsh) + self.assertIn('Error: Could not troubleshoot opt for ethanol! The job ran out of disc space on server1; ', output_errors) + # Test Q-Chem software = 'qchem' ess_trsh_methods = ['change_node'] From 5512880e5846dc60c246c5e459d0305c07ce6eed Mon Sep 17 00:00:00 2001 From: Calvin Date: Fri, 24 Nov 2023 19:49:44 +0200 Subject: [PATCH 2/3] Update combine param function and tests --- arc/job/adapters/common.py | 3 ++- arc/job/adapters/common_test.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/arc/job/adapters/common.py b/arc/job/adapters/common.py index 69c7c8157e..247a94a02d 100644 --- a/arc/job/adapters/common.py +++ b/arc/job/adapters/common.py @@ -514,7 +514,8 @@ def combine_parameters(input_dict: dict, terms: list) -> Tuple[dict, List]: for key, value in input_dict_copy.items(): if isinstance(value, str): - for term in terms: + # Sort terms by length in descending order to handle overlapping terms + for term in sorted(terms, key=len, reverse=True): matches = re.findall(term, value) for match in matches: if match: diff --git a/arc/job/adapters/common_test.py b/arc/job/adapters/common_test.py index b693c43e2a..7250384371 100644 --- a/arc/job/adapters/common_test.py +++ b/arc/job/adapters/common_test.py @@ -205,6 +205,30 @@ def test_combine_parameters_no_match(self): self.assertEqual(modified_dict, expected_dict) self.assertEqual(parameters, expected_parameters) + def test_combine_parameters_multiple_occurrences(self): + """Test the combine_parameters function with multiple occurrences of the same term.""" + input_dict = {'param1': 'value1 term1 value2 term1', 'param2': 'another term2 value term2'} + terms = ['term1', 'term2'] + expected_dict = {'param1': 'value1 value2 ', 'param2': 'another value '} + expected_parameters = ['term1', 'term2'] + + modified_dict, parameters = common.combine_parameters(input_dict, terms) + + self.assertEqual(modified_dict, expected_dict) + self.assertEqual(sorted(parameters), expected_parameters) + + def test_combine_parameters_overlapping_terms(self): + """Test the combine_parameters function with overlapping terms.""" + input_dict = {'param1': 'value term1 term123', 'param2': 'another term2 value'} + terms = ['term1', 'term123', 'term2'] + expected_dict = {'param1': 'value ', 'param2': 'another value'} + expected_parameters = ['term1', 'term123', 'term2'] + + modified_dict, parameters = common.combine_parameters(input_dict, terms) + + self.assertEqual(modified_dict, expected_dict) + self.assertEqual(sorted(parameters), expected_parameters) + def test_input_dict_strip(self): """Test the input_dict_strip() function""" input_dict = { From b0745286fda8372caafe1ac24a1faf244ded8b7d Mon Sep 17 00:00:00 2001 From: Calvin Date: Fri, 24 Nov 2023 19:50:01 +0200 Subject: [PATCH 3/3] Extra Gauss Test --- arc/job/adapters/gaussian_test.py | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/arc/job/adapters/gaussian_test.py b/arc/job/adapters/gaussian_test.py index eda7add8a6..b80365ed9f 100644 --- a/arc/job/adapters/gaussian_test.py +++ b/arc/job/adapters/gaussian_test.py @@ -274,6 +274,28 @@ def setUpClass(cls): args=args ) + # Gaussian: Checkfile error and SCF error + # First SCF error - qc,nosymm + job_status = {'keywords': ['SCF', 'NoSymm', 'GL301']} + output_errors, ess_trsh_methods, remove_checkfile, level_of_theory, software, job_type, fine, trsh_keyword, \ + memory, shift, cpu_cores, couldnt_trsh = trsh.trsh_ess_job(label, level_of_theory, server, job_status, + job_type, software, fine, memory_gb, + num_heavy_atoms, cpu_cores, ess_trsh_methods) + args = {'keyword': {}, 'block': {}} + if trsh_keyword: + args['trsh'] = {'trsh': trsh_keyword} + cls.job_16 = GaussianAdapter(execution_type='local', + job_type='sp', + level=Level(method='wb97xd'), + fine=True, + ess_trsh_methods=ess_trsh_methods, + project='test', + project_directory=os.path.join(ARC_PATH, 'arc', 'testing', 'test_GaussianAdapter'), + species=[spc_11], + testing=True, + args=args + ) + def test_set_cpu_and_mem(self): """Test assigning number of cpu's and memory""" self.job_8.input_file_memory = None @@ -619,6 +641,34 @@ def test_trsh_write_input_file(self): """ self.assertEqual(content_15, job_15_expected_input_file) + self.job_16.write_input_file() + with open(os.path.join(self.job_16.local_path, input_filenames[self.job_16.job_adapter]), 'r') as f: + content_16 = f.read() + + job_16_expected_input_file = """%chk=check.chk +%mem=14336mb +%NProcShared=8 + +#P opt=(cartesian) integral=(grid=ultrafine, Acc2E=14) guess=mix wb97xd IOp(2/9=2000) nosymm scf=(NDump=30,NoDIIS,direct,tight,xqc) + +ethanol + +0 1 +C 1.16582100 -0.40435500 0.00000000 +C 0.00000000 0.55180500 0.00000000 +O -1.18946000 -0.21419400 0.00000000 +H -1.94125800 0.37518500 0.00000000 +H 2.10540200 0.14511600 0.00000000 +H 1.13062400 -1.03878500 0.88303200 +H 1.13062400 -1.03878500 -0.88303200 +H 0.04768200 1.19305700 0.88359100 +H 0.04768200 1.19305700 -0.88359100 + + +""" + + self.assertEqual(content_16, job_16_expected_input_file) + @classmethod def tearDownClass(cls): """