From dfb53bd50ab7f178ec6526bb10ec448395c88227 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Tue, 30 Aug 2022 10:19:14 -0600 Subject: [PATCH 01/11] create_test: fix compiler inferring If the user does this: create_test SMS.GRID.CASE.mappy_gnu9 ... create_test should not assume the compiler is gnu even though that's the default compiler for mappy. It should behave as if the user provided --compiler=gnu9 which will allow the test to find the correct baselines. --- CIME/Tools/get_case_env | 5 ++-- CIME/get_tests.py | 33 +++++++++++++++++++-------- CIME/scripts/create_test.py | 16 +++++++++---- CIME/tests/test_sys_test_scheduler.py | 12 ++++++++++ docker/config_machines.xml | 4 ++-- 5 files changed, 52 insertions(+), 18 deletions(-) diff --git a/CIME/Tools/get_case_env b/CIME/Tools/get_case_env index 3a67d06961d..83e2ce5c132 100755 --- a/CIME/Tools/get_case_env +++ b/CIME/Tools/get_case_env @@ -60,8 +60,9 @@ def _main_func(description): ############################################################################### casename = parse_command_line(sys.argv, description) - compiler = parse_test_name(casename)[5] - machine = CIME.get_tests.infer_machine_name_from_tests([casename]) + machine, compiler = CIME.get_tests.infer_arch_from_tests([casename]) + expect(len(compiler) <= 1, "How did we get multiple compilers from one test case?") + compiler = compiler[0] if len(compiler) == 1 else None mach_obj = Machines(machine=machine) compiler = mach_obj.get_default_compiler() if compiler is None else compiler full_test_name = CIME.get_tests.get_full_test_names( diff --git a/CIME/get_tests.py b/CIME/get_tests.py index 21220cf6165..6ccb6ad7585 100644 --- a/CIME/get_tests.py +++ b/CIME/get_tests.py @@ -300,27 +300,37 @@ def get_build_groups(tests): ############################################################################### -def infer_machine_name_from_tests(testargs): +def infer_arch_from_tests(testargs): ############################################################################### """ - >>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu"]) - 'melvin' - >>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A"]) - >>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A", "NCK.f19_g16_rx1.A.melvin_gnu"]) - 'melvin' - >>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu", "NCK.f19_g16_rx1.A.melvin_gnu"]) - 'melvin' + Return a tuple (machine, [compilers]) that can be inferred from the test args + + >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu"]) + ('melvin', ['gnu']) + >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A"]) + (None, []) + >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A", "NCK.f19_g16_rx1.A.melvin_gnu"]) + ('melvin', ['gnu']) + >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu", "NCK.f19_g16_rx1.A.melvin_gnu"]) + ('melvin', ['gnu']) + >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu9", "NCK.f19_g16_rx1.A.melvin_gnu"]) + ('melvin', ['gnu9', 'gnu']) + >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu", "NCK.f19_g16_rx1.A.mappy_gnu"]) + Traceback (most recent call last): + ... + CIMEError: ERROR: Must have consistent machine 'melvin' != 'mappy' """ e3sm_test_suites = get_test_suites() machine = None + compilers = [] for testarg in testargs: testarg = testarg.strip() if testarg.startswith("^"): testarg = testarg[1:] if testarg not in e3sm_test_suites: - machine_for_this_test = parse_test_name(testarg)[4] + machine_for_this_test, compiler_for_this_test = parse_test_name(testarg)[4:6] if machine_for_this_test is not None: if machine is None: machine = machine_for_this_test @@ -331,7 +341,10 @@ def infer_machine_name_from_tests(testargs): % (machine, machine_for_this_test), ) - return machine + if compiler_for_this_test is not None and compiler_for_this_test not in compilers: + compilers.append(compiler_for_this_test) + + return machine, compilers ############################################################################### diff --git a/CIME/scripts/create_test.py b/CIME/scripts/create_test.py index 53ee90f170d..c2124a39cc5 100755 --- a/CIME/scripts/create_test.py +++ b/CIME/scripts/create_test.py @@ -631,13 +631,21 @@ def parse_command_line(args, description): logger.info("Testnames: %s" % test_names) else: + inf_machine, inf_compilers = get_tests.infer_arch_from_tests(args.testargs) if args.machine is None: - args.machine = get_tests.infer_machine_name_from_tests(args.testargs) + args.machine = inf_machine mach_obj = Machines(machine=args.machine) - args.compiler = ( - mach_obj.get_default_compiler() if args.compiler is None else args.compiler - ) + if args.compiler is None: + if len(inf_compilers) == 0: + args.compiler = mach_obj.get_default_compiler() + elif len(inf_compilers) == 1: + args.compiler = inf_compilers[0] + else: + # User has multiple compiler specifications in their testargs + args.compiler = inf_compilers[0] + expect(not args.compare and not args.generate, + "It is not safe to do baseline operations with heterogenous compiler set: {}".format(inf_compilers)) test_names = get_tests.get_full_test_names( args.testargs, mach_obj.get_machine_name(), args.compiler diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 2e56f96a786..796972c3f7c 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -450,6 +450,18 @@ def test_d_retry(self): self._create_test(args) + def test_e_test_inferred_compiler(self): + if Config.instance().test_mode != "e3sm": + self.skipTest("Skipping create_test test. Depends on E3SM settings") + + args = [ + "SMS.f19_g16_rx1.A.docker_gnuX", + "--no-build" + ] + + case = self._create_test(args) + result = self.run_cmd_assert_result("./xmlquery --value BASELINE_ROOT", from_dir=case) + self.assertEqual(result, "/storage/baselines/gnuX") if __name__ == "__main__": unittest.main() diff --git a/docker/config_machines.xml b/docker/config_machines.xml index 16a9a3dd460..a2842d55945 100644 --- a/docker/config_machines.xml +++ b/docker/config_machines.xml @@ -6,7 +6,7 @@ docker LINUX - gnu + gnu,gnuX openmpi CIME /storage/timings @@ -15,7 +15,7 @@ /storage/inputdata /storage/inputdata-clmforc /storage/archive/$CASE - /storage/baselines + /storage/baselines/$COMPILER /storage/tools/cprnc make 4 From d66388ed9dc1213a00e0911aa1c1b7c947cfc6ff Mon Sep 17 00:00:00 2001 From: James Foucar Date: Tue, 30 Aug 2022 17:07:24 -0600 Subject: [PATCH 02/11] Fix for E3SM mappy CIME testing Was not loading correct config for tests. --- CIME/tests/base.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CIME/tests/base.py b/CIME/tests/base.py index 8280736ea1c..c469801b75b 100644 --- a/CIME/tests/base.py +++ b/CIME/tests/base.py @@ -62,6 +62,9 @@ def setUp(self): self._do_teardown = not self.NO_TEARDOWN self._root_dir = os.getcwd() + customize_path = os.path.join(utils.get_src_root(), "cime_config", "customize") + config = Config.load(customize_path) + def tearDown(self): self.kill_subprocesses() From ac39190ccfc653bb2da65c4835ae18e6c8d4f82b Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 10:49:43 -0600 Subject: [PATCH 03/11] Only run test on docker --- CIME/tests/test_sys_test_scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 796972c3f7c..838ad9fab8c 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -451,7 +451,7 @@ def test_d_retry(self): self._create_test(args) def test_e_test_inferred_compiler(self): - if Config.instance().test_mode != "e3sm": + if Config.instance().test_mode != "e3sm" and self._machine != "docker": self.skipTest("Skipping create_test test. Depends on E3SM settings") args = [ From 98d1a3bf36c8994d69cfd4b0ea33a8dad4ea2778 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 10:50:33 -0600 Subject: [PATCH 04/11] Fix unit test --- CIME/get_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIME/get_tests.py b/CIME/get_tests.py index 6ccb6ad7585..40afcda9bac 100644 --- a/CIME/get_tests.py +++ b/CIME/get_tests.py @@ -318,7 +318,7 @@ def infer_arch_from_tests(testargs): >>> infer_arch_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu", "NCK.f19_g16_rx1.A.mappy_gnu"]) Traceback (most recent call last): ... - CIMEError: ERROR: Must have consistent machine 'melvin' != 'mappy' + CIME.utils.CIMEError: ERROR: Must have consistent machine 'melvin' != 'mappy' """ e3sm_test_suites = get_test_suites() From a4df6cc4c238afdd32074043d49bb6afe0149753 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 10:58:18 -0600 Subject: [PATCH 05/11] black --- CIME/get_tests.py | 9 +++++++-- CIME/scripts/create_test.py | 8 ++++++-- CIME/tests/test_sys_test_scheduler.py | 10 +++++----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CIME/get_tests.py b/CIME/get_tests.py index 40afcda9bac..857fa974d3e 100644 --- a/CIME/get_tests.py +++ b/CIME/get_tests.py @@ -330,7 +330,9 @@ def infer_arch_from_tests(testargs): testarg = testarg[1:] if testarg not in e3sm_test_suites: - machine_for_this_test, compiler_for_this_test = parse_test_name(testarg)[4:6] + machine_for_this_test, compiler_for_this_test = parse_test_name(testarg)[ + 4:6 + ] if machine_for_this_test is not None: if machine is None: machine = machine_for_this_test @@ -341,7 +343,10 @@ def infer_arch_from_tests(testargs): % (machine, machine_for_this_test), ) - if compiler_for_this_test is not None and compiler_for_this_test not in compilers: + if ( + compiler_for_this_test is not None + and compiler_for_this_test not in compilers + ): compilers.append(compiler_for_this_test) return machine, compilers diff --git a/CIME/scripts/create_test.py b/CIME/scripts/create_test.py index c2124a39cc5..753e627b24b 100755 --- a/CIME/scripts/create_test.py +++ b/CIME/scripts/create_test.py @@ -644,8 +644,12 @@ def parse_command_line(args, description): else: # User has multiple compiler specifications in their testargs args.compiler = inf_compilers[0] - expect(not args.compare and not args.generate, - "It is not safe to do baseline operations with heterogenous compiler set: {}".format(inf_compilers)) + expect( + not args.compare and not args.generate, + "It is not safe to do baseline operations with heterogenous compiler set: {}".format( + inf_compilers + ), + ) test_names = get_tests.get_full_test_names( args.testargs, mach_obj.get_machine_name(), args.compiler diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 838ad9fab8c..26e2849fb1c 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -454,14 +454,14 @@ def test_e_test_inferred_compiler(self): if Config.instance().test_mode != "e3sm" and self._machine != "docker": self.skipTest("Skipping create_test test. Depends on E3SM settings") - args = [ - "SMS.f19_g16_rx1.A.docker_gnuX", - "--no-build" - ] + args = ["SMS.f19_g16_rx1.A.docker_gnuX", "--no-build"] case = self._create_test(args) - result = self.run_cmd_assert_result("./xmlquery --value BASELINE_ROOT", from_dir=case) + result = self.run_cmd_assert_result( + "./xmlquery --value BASELINE_ROOT", from_dir=case + ) self.assertEqual(result, "/storage/baselines/gnuX") + if __name__ == "__main__": unittest.main() From fb2ad6df3a7536aab60719fde043508da9fafde2 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 13:05:12 -0600 Subject: [PATCH 06/11] Fix test --- CIME/tests/test_sys_test_scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 26e2849fb1c..6296a1d999e 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -460,7 +460,7 @@ def test_e_test_inferred_compiler(self): result = self.run_cmd_assert_result( "./xmlquery --value BASELINE_ROOT", from_dir=case ) - self.assertEqual(result, "/storage/baselines/gnuX") + self.assertEqual(os.path.split(result)[1], "gnuX") if __name__ == "__main__": From 409871481bac142848a6872c33b422a4eb4ade17 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 13:10:12 -0600 Subject: [PATCH 07/11] Fix test --- CIME/tests/base.py | 5 +++-- CIME/tests/test_sys_test_scheduler.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CIME/tests/base.py b/CIME/tests/base.py index c469801b75b..9d03fb8b781 100644 --- a/CIME/tests/base.py +++ b/CIME/tests/base.py @@ -195,7 +195,7 @@ def kill_subprocesses( def kill_python_subprocesses(self, sig=signal.SIGKILL, expected_num_killed=None): self.kill_subprocesses("[Pp]ython", sig, expected_num_killed) - def _create_test(self, extra_args, test_id=None, run_errors=False, env_changes=""): + def _create_test(self, extra_args, test_id=None, run_errors=False, env_changes="", default_baseline_area=False): """ Convenience wrapper around create_test. Returns list of full paths to created cases. If multiple cases, the order of the returned list is not guaranteed to match the order of the arguments. @@ -213,7 +213,8 @@ def _create_test(self, extra_args, test_id=None, run_errors=False, env_changes=" else test_id ) extra_args.append("-t {}".format(test_id)) - extra_args.append("--baseline-root {}".format(self._baseline_area)) + if not default_baseline_area: + extra_args.append("--baseline-root {}".format(self._baseline_area)) if self.NO_BATCH: extra_args.append("--no-batch") if self.TEST_COMPILER and ( diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 6296a1d999e..3623140a3d3 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -454,11 +454,11 @@ def test_e_test_inferred_compiler(self): if Config.instance().test_mode != "e3sm" and self._machine != "docker": self.skipTest("Skipping create_test test. Depends on E3SM settings") - args = ["SMS.f19_g16_rx1.A.docker_gnuX", "--no-build"] + args = ["SMS.f19_g16_rx1.A.docker_gnuX", "--no-setup"] case = self._create_test(args) result = self.run_cmd_assert_result( - "./xmlquery --value BASELINE_ROOT", from_dir=case + "./xmlquery --value BASELINE_ROOT", from_dir=case, default_baseline_area=True ) self.assertEqual(os.path.split(result)[1], "gnuX") From 9b7a32c54fb008f835af295da660a1fdd63f21ad Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 13:13:09 -0600 Subject: [PATCH 08/11] black --- CIME/tests/base.py | 9 ++++++++- CIME/tests/test_sys_test_scheduler.py | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CIME/tests/base.py b/CIME/tests/base.py index 9d03fb8b781..1b5f5094eba 100644 --- a/CIME/tests/base.py +++ b/CIME/tests/base.py @@ -195,7 +195,14 @@ def kill_subprocesses( def kill_python_subprocesses(self, sig=signal.SIGKILL, expected_num_killed=None): self.kill_subprocesses("[Pp]ython", sig, expected_num_killed) - def _create_test(self, extra_args, test_id=None, run_errors=False, env_changes="", default_baseline_area=False): + def _create_test( + self, + extra_args, + test_id=None, + run_errors=False, + env_changes="", + default_baseline_area=False, + ): """ Convenience wrapper around create_test. Returns list of full paths to created cases. If multiple cases, the order of the returned list is not guaranteed to match the order of the arguments. diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 3623140a3d3..570e7aafa93 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -458,7 +458,9 @@ def test_e_test_inferred_compiler(self): case = self._create_test(args) result = self.run_cmd_assert_result( - "./xmlquery --value BASELINE_ROOT", from_dir=case, default_baseline_area=True + "./xmlquery --value BASELINE_ROOT", + from_dir=case, + default_baseline_area=True, ) self.assertEqual(os.path.split(result)[1], "gnuX") From 3522924097d59ef2b2a27cfdd42f998acdfe2faf Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 14:46:06 -0600 Subject: [PATCH 09/11] Fix test --- CIME/tests/test_sys_test_scheduler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 570e7aafa93..4a29bfdaab2 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -456,11 +456,10 @@ def test_e_test_inferred_compiler(self): args = ["SMS.f19_g16_rx1.A.docker_gnuX", "--no-setup"] - case = self._create_test(args) + case = self._create_test(args, default_baseline_area=True) result = self.run_cmd_assert_result( "./xmlquery --value BASELINE_ROOT", - from_dir=case, - default_baseline_area=True, + from_dir=case ) self.assertEqual(os.path.split(result)[1], "gnuX") From 79337b14a0bd7b8afe2cb4f6c8c1c038377298e9 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 14:47:00 -0600 Subject: [PATCH 10/11] black --- CIME/tests/test_sys_test_scheduler.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 4a29bfdaab2..914e7bd8b78 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -458,8 +458,7 @@ def test_e_test_inferred_compiler(self): case = self._create_test(args, default_baseline_area=True) result = self.run_cmd_assert_result( - "./xmlquery --value BASELINE_ROOT", - from_dir=case + "./xmlquery --value BASELINE_ROOT", from_dir=case ) self.assertEqual(os.path.split(result)[1], "gnuX") From 34b541a3817cf80cd25d707d2afed71c317af513 Mon Sep 17 00:00:00 2001 From: James Foucar Date: Wed, 31 Aug 2022 15:32:09 -0600 Subject: [PATCH 11/11] Fix --- CIME/tests/test_sys_test_scheduler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIME/tests/test_sys_test_scheduler.py b/CIME/tests/test_sys_test_scheduler.py index 914e7bd8b78..8ab3414f4a2 100755 --- a/CIME/tests/test_sys_test_scheduler.py +++ b/CIME/tests/test_sys_test_scheduler.py @@ -451,7 +451,7 @@ def test_d_retry(self): self._create_test(args) def test_e_test_inferred_compiler(self): - if Config.instance().test_mode != "e3sm" and self._machine != "docker": + if Config.instance().test_mode != "e3sm" or self._machine != "docker": self.skipTest("Skipping create_test test. Depends on E3SM settings") args = ["SMS.f19_g16_rx1.A.docker_gnuX", "--no-setup"]