From 53fd0cd032edb35949e8b1f892f0f768c26c9c78 Mon Sep 17 00:00:00 2001 From: Al Rigazzi Date: Thu, 4 May 2023 14:25:57 -0400 Subject: [PATCH 1/3] Minor fixes to full_wlm tests --- tests/full_wlm/test_generic_batch_launch.py | 18 ++++---- .../full_wlm/test_generic_orc_launch_batch.py | 44 ++++++++++++------- tests/full_wlm/test_slurm_allocation.py | 14 ++++-- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/tests/full_wlm/test_generic_batch_launch.py b/tests/full_wlm/test_generic_batch_launch.py index 4fa2760e5..69632f80a 100644 --- a/tests/full_wlm/test_generic_batch_launch.py +++ b/tests/full_wlm/test_generic_batch_launch.py @@ -44,10 +44,10 @@ def test_batch_model(fileutils, wlmutils): script = fileutils.get_test_conf_path("sleep.py") batch_settings = exp.create_batch_settings(nodes=1, time="00:01:00") - if wlmutils.get_test_launcher() == "lsf": - batch_settings.set_account(wlmutils.get_test_account()) + test_account = wlmutils.get_test_account() + if test_account: + batch_settings.set_account(test_account) if wlmutils.get_test_launcher() == "cobalt": - batch_settings.set_account(wlmutils.get_test_account()) batch_settings.set_queue("debug-flat-quad") run_settings = wlmutils.get_run_settings("python", f"{script} --time=5") model = exp.create_model( @@ -74,10 +74,10 @@ def test_batch_ensemble(fileutils, wlmutils): M2 = exp.create_model("m2", path=test_dir, run_settings=settings) batch = exp.create_batch_settings(nodes=1, time="00:01:00") - if wlmutils.get_test_launcher() == "lsf": - batch.set_account(wlmutils.get_test_account()) + test_account = wlmutils.get_test_account() + if test_account: + batch.set_account(test_account) if wlmutils.get_test_launcher() == "cobalt": - batch.set_account(wlmutils.get_test_account()) batch.set_queue("debug-flat-quad") ensemble = exp.create_ensemble("batch-ens", batch_settings=batch) ensemble.add_model(M1) @@ -98,14 +98,14 @@ def test_batch_ensemble_replicas(fileutils, wlmutils): settings = wlmutils.get_run_settings("python", f"{script} --time=5") batch = exp.create_batch_settings(nodes=1, time="00:01:00") - if wlmutils.get_test_launcher() == "lsf": - batch.set_account(wlmutils.get_test_account()) + test_account = wlmutils.get_test_account() + if test_account: + batch.set_account(test_account) if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need # to make sure the previous test's one is over sleep(30) - batch.set_account(wlmutils.get_test_account()) batch.set_queue("debug-flat-quad") ensemble = exp.create_ensemble( "batch-ens-replicas", batch_settings=batch, run_settings=settings, replicas=2 diff --git a/tests/full_wlm/test_generic_orc_launch_batch.py b/tests/full_wlm/test_generic_orc_launch_batch.py index 6fce2006e..c5e22d354 100644 --- a/tests/full_wlm/test_generic_orc_launch_batch.py +++ b/tests/full_wlm/test_generic_orc_launch_batch.py @@ -47,15 +47,19 @@ def test_launch_orc_auto_batch(fileutils, wlmutils): # batch = False to launch on existing allocation network_interface = wlmutils.get_test_interface() orc = exp.create_database( - 6780, batch=True, interface=network_interface, single_cmd=False + wlmutils.get_test_port(), batch=True, interface=network_interface, single_cmd=False ) + + test_account = wlmutils.get_test_account() + if test_account: + orc.batch_settings.set_account(test_account) if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_walltime("00:02") + else: + orc.batch_settings.set_walltime("00:02:00") if wlmutils.get_test_launcher() == "cobalt": - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_queue("debug-flat-quad") - orc.batch_settings.set_walltime("00:02:00") + orc.set_path(test_dir) exp.start(orc, block=True) @@ -83,19 +87,22 @@ def test_launch_cluster_orc_batch_single(fileutils, wlmutils): # batch = False to launch on existing allocation network_interface = wlmutils.get_test_interface() orc = exp.create_database( - 6780, db_nodes=3, batch=True, interface=network_interface, single_cmd=True + wlmutils.get_test_port(), db_nodes=3, batch=True, interface=network_interface, single_cmd=True ) + + test_account = wlmutils.get_test_account() + if test_account: + orc.batch_settings.set_account(test_account) if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_walltime("00:02") + else: + orc.batch_settings.set_walltime("00:02:00") if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need # to make sure the previous test's one is over time.sleep(120) - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_queue("debug-flat-quad") - orc.batch_settings.set_walltime("00:02:00") orc.set_path(test_dir) exp.start(orc, block=True) @@ -123,19 +130,21 @@ def test_launch_cluster_orc_batch_multi(fileutils, wlmutils): # batch = False to launch on existing allocation network_interface = wlmutils.get_test_interface() orc = exp.create_database( - 6780, db_nodes=3, batch=True, interface=network_interface, single_cmd=False + wlmutils.get_test_port(), db_nodes=3, batch=True, interface=network_interface, single_cmd=False ) + test_account = wlmutils.get_test_account() + if test_account: + orc.batch_settings.set_account(test_account) if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_walltime("00:03") + else: + orc.batch_settings.set_walltime("00:03:00") if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need # to make sure the previous test's one is over time.sleep(120) - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_queue("debug-flat-quad") - orc.batch_settings.set_walltime("00:03:00") orc.set_path(test_dir) exp.start(orc, block=True) @@ -160,19 +169,22 @@ def test_launch_cluster_orc_reconnect(fileutils, wlmutils): # batch = False to launch on existing allocation network_interface = wlmutils.get_test_interface() - orc = exp.create_database(6780, db_nodes=3, batch=True, interface=network_interface) + orc = exp.create_database(wlmutils.get_test_port(), db_nodes=3, batch=True, interface=network_interface) orc.set_path(test_dir) + + test_account = wlmutils.get_test_account() + if test_account: + orc.batch_settings.set_account(test_account) if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_walltime("00:03") + else: + orc.batch_settings.set_walltime("00:03:00") if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need # to make sure the previous test's one is over time.sleep(120) - orc.batch_settings.set_account(wlmutils.get_test_account()) orc.batch_settings.set_queue("debug-flat-quad") - orc.batch_settings.set_walltime("00:03:00") exp.start(orc, block=True) diff --git a/tests/full_wlm/test_slurm_allocation.py b/tests/full_wlm/test_slurm_allocation.py index 202da5367..c011f557d 100644 --- a/tests/full_wlm/test_slurm_allocation.py +++ b/tests/full_wlm/test_slurm_allocation.py @@ -36,17 +36,23 @@ pytestmark = pytest.mark.skip(reason="Test is only for Slurm WLM systems") -def test_get_release_allocation(): +def test_get_release_allocation(wlmutils): """test slurm interface for obtaining allocations""" - alloc = slurm.get_allocation(nodes=1, time="00:05:00") + account = wlmutils.get_test_account() + if not account: + account = None + alloc = slurm.get_allocation(nodes=1, time="00:05:00", account=account) time.sleep(5) # give slurm a rest slurm.release_allocation(alloc) -def test_get_release_allocation_w_options(): +def test_get_release_allocation_w_options(wlmutils): """test slurm interface for obtaining allocations""" options = {"ntasks-per-node": 1} - alloc = slurm.get_allocation(nodes=1, time="00:05:00", options=options) + account = wlmutils.get_test_account() + if not account: + account = None + alloc = slurm.get_allocation(nodes=1, time="00:05:00", options=options, account=account) time.sleep(5) # give slurm a rest slurm.release_allocation(alloc) From 5e242bede74ef496253db9f23d71e2e6bae5cf5a Mon Sep 17 00:00:00 2001 From: Al Rigazzi Date: Fri, 5 May 2023 06:34:49 -0400 Subject: [PATCH 2/3] Address reviewer's comments --- smartsim/_core/config/config.py | 2 +- smartsim/settings/lsfSettings.py | 3 +- .../full_wlm/test_generic_orc_launch_batch.py | 41 ++++++------------- tests/full_wlm/test_slurm_allocation.py | 4 -- 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/smartsim/_core/config/config.py b/smartsim/_core/config/config.py index 06c64d5ce..4227afee6 100644 --- a/smartsim/_core/config/config.py +++ b/smartsim/_core/config/config.py @@ -189,7 +189,7 @@ def test_interface(self) -> List[str]: # pragma: no cover @property def test_account(self) -> str: # pragma: no cover # no account by default - return os.environ.get("SMARTSIM_TEST_ACCOUNT", "") + return os.environ.get("SMARTSIM_TEST_ACCOUNT", None) @lru_cache(maxsize=128, typed=False) diff --git a/smartsim/settings/lsfSettings.py b/smartsim/settings/lsfSettings.py index 9e6943191..49373c2b5 100644 --- a/smartsim/settings/lsfSettings.py +++ b/smartsim/settings/lsfSettings.py @@ -457,7 +457,8 @@ def set_project(self, project): :param time: project name :type time: str """ - self.project = project + if project: + self.project = project def set_account(self, account): """Set the project diff --git a/tests/full_wlm/test_generic_orc_launch_batch.py b/tests/full_wlm/test_generic_orc_launch_batch.py index c5e22d354..7e5591a30 100644 --- a/tests/full_wlm/test_generic_orc_launch_batch.py +++ b/tests/full_wlm/test_generic_orc_launch_batch.py @@ -50,13 +50,9 @@ def test_launch_orc_auto_batch(fileutils, wlmutils): wlmutils.get_test_port(), batch=True, interface=network_interface, single_cmd=False ) - test_account = wlmutils.get_test_account() - if test_account: - orc.batch_settings.set_account(test_account) - if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_walltime("00:02") - else: - orc.batch_settings.set_walltime("00:02:00") + orc.batch_settings.set_account(wlmutils.get_test_account()) + + orc.batch_settings.set_walltime("00:02:00") if wlmutils.get_test_launcher() == "cobalt": orc.batch_settings.set_queue("debug-flat-quad") @@ -90,13 +86,9 @@ def test_launch_cluster_orc_batch_single(fileutils, wlmutils): wlmutils.get_test_port(), db_nodes=3, batch=True, interface=network_interface, single_cmd=True ) - test_account = wlmutils.get_test_account() - if test_account: - orc.batch_settings.set_account(test_account) - if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_walltime("00:02") - else: - orc.batch_settings.set_walltime("00:02:00") + orc.batch_settings.set_account(wlmutils.get_test_account()) + + orc.batch_settings.set_walltime("00:02:00") if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need @@ -132,13 +124,10 @@ def test_launch_cluster_orc_batch_multi(fileutils, wlmutils): orc = exp.create_database( wlmutils.get_test_port(), db_nodes=3, batch=True, interface=network_interface, single_cmd=False ) - test_account = wlmutils.get_test_account() - if test_account: - orc.batch_settings.set_account(test_account) - if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_walltime("00:03") - else: - orc.batch_settings.set_walltime("00:03:00") + + orc.batch_settings.set_account(wlmutils.get_test_account()) + + orc.batch_settings.set_walltime("00:03:00") if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need @@ -172,13 +161,9 @@ def test_launch_cluster_orc_reconnect(fileutils, wlmutils): orc = exp.create_database(wlmutils.get_test_port(), db_nodes=3, batch=True, interface=network_interface) orc.set_path(test_dir) - test_account = wlmutils.get_test_account() - if test_account: - orc.batch_settings.set_account(test_account) - if wlmutils.get_test_launcher() == "lsf": - orc.batch_settings.set_walltime("00:03") - else: - orc.batch_settings.set_walltime("00:03:00") + orc.batch_settings.set_account(wlmutils.get_test_account()) + + orc.batch_settings.set_walltime("00:03:00") if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need diff --git a/tests/full_wlm/test_slurm_allocation.py b/tests/full_wlm/test_slurm_allocation.py index c011f557d..69554c1e4 100644 --- a/tests/full_wlm/test_slurm_allocation.py +++ b/tests/full_wlm/test_slurm_allocation.py @@ -39,8 +39,6 @@ def test_get_release_allocation(wlmutils): """test slurm interface for obtaining allocations""" account = wlmutils.get_test_account() - if not account: - account = None alloc = slurm.get_allocation(nodes=1, time="00:05:00", account=account) time.sleep(5) # give slurm a rest slurm.release_allocation(alloc) @@ -50,8 +48,6 @@ def test_get_release_allocation_w_options(wlmutils): """test slurm interface for obtaining allocations""" options = {"ntasks-per-node": 1} account = wlmutils.get_test_account() - if not account: - account = None alloc = slurm.get_allocation(nodes=1, time="00:05:00", options=options, account=account) time.sleep(5) # give slurm a rest slurm.release_allocation(alloc) From a558a644803d2503eec4a5b5195b59e6c0bf0e19 Mon Sep 17 00:00:00 2001 From: Al Rigazzi Date: Mon, 8 May 2023 14:06:57 -0400 Subject: [PATCH 3/3] Make test_account used by default --- tests/full_wlm/test_generic_batch_launch.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/full_wlm/test_generic_batch_launch.py b/tests/full_wlm/test_generic_batch_launch.py index 69632f80a..4beccd41b 100644 --- a/tests/full_wlm/test_generic_batch_launch.py +++ b/tests/full_wlm/test_generic_batch_launch.py @@ -44,9 +44,8 @@ def test_batch_model(fileutils, wlmutils): script = fileutils.get_test_conf_path("sleep.py") batch_settings = exp.create_batch_settings(nodes=1, time="00:01:00") - test_account = wlmutils.get_test_account() - if test_account: - batch_settings.set_account(test_account) + + batch_settings.set_account(wlmutils.get_test_account()) if wlmutils.get_test_launcher() == "cobalt": batch_settings.set_queue("debug-flat-quad") run_settings = wlmutils.get_run_settings("python", f"{script} --time=5") @@ -74,9 +73,8 @@ def test_batch_ensemble(fileutils, wlmutils): M2 = exp.create_model("m2", path=test_dir, run_settings=settings) batch = exp.create_batch_settings(nodes=1, time="00:01:00") - test_account = wlmutils.get_test_account() - if test_account: - batch.set_account(test_account) + + batch.set_account(wlmutils.get_test_account()) if wlmutils.get_test_launcher() == "cobalt": batch.set_queue("debug-flat-quad") ensemble = exp.create_ensemble("batch-ens", batch_settings=batch) @@ -98,9 +96,8 @@ def test_batch_ensemble_replicas(fileutils, wlmutils): settings = wlmutils.get_run_settings("python", f"{script} --time=5") batch = exp.create_batch_settings(nodes=1, time="00:01:00") - test_account = wlmutils.get_test_account() - if test_account: - batch.set_account(test_account) + + batch.set_account(wlmutils.get_test_account()) if wlmutils.get_test_launcher() == "cobalt": # As Cobalt won't allow us to run two # jobs in the same debug queue, we need