Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes to full_wlm tests #283

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions tests/full_wlm/test_generic_batch_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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
Expand Down
44 changes: 28 additions & 16 deletions tests/full_wlm/test_generic_orc_launch_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, more-so just a note to myself for a potential addition to BatchSettings class:

This feels like there is probably a way to unify these set_walltime calls so that we do not need to jump based on launcher. Maybe something akin to RunSettings.set_time.

Thoughts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of a sudden, you reminded me that we can actually specify time like that in LSF, because we convert it to hh:mm format on the fly. Removing outdated lines.

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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of scope for this PR, more-so a note to myself for a potential BatchSettings feature:

Iirc, for SBatchSettings, if set_account receives a false-y value (i.e. empty str or None), a no-op is made.

Is this not the case for all BatchSettings derivatives? Should we consider unifying this behavior for script portability??

Copy link
Collaborator Author

@al-rigazzi al-rigazzi May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be, indeed. I updated LSF, which was the only one with a slightly different behavior (due to the fact that accounts are always needed on LSF).

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)

Expand Down
14 changes: 10 additions & 4 deletions tests/full_wlm/test_slurm_allocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

@MattToast MattToast May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit like an anti-pattern. Should wlmutils.get_test_account and/or CONFIG.test_account just return None if SMARTSIM_TEST_ACCOUNT is not set, instead of an empty string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come you always have such good ideas. Indeed, updated.

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)

Expand Down