Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
37 changes: 37 additions & 0 deletions lib/ramble/ramble/test/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,40 @@ def test_non_reserved_variables(self):
self.assertNotIn("application::name::version", non_reserved)
self.assertNotIn("modifier_version", non_reserved)
self.assertEqual(len(non_reserved), 1)


@pytest.mark.parametrize(
"n_nodes,mpi_cmd,expect_warning",
[
("2", "", True),
("1", "", False),
("2", "mpirun -n {n_ranks}", False),
],
)
def test_multi_node_mpi_command_warning(
make_workspace_from_config, mutable_mock_apps_repo, n_nodes, mpi_cmd, expect_warning
):
workspace = ramble.main.RambleCommand("workspace")

test_config = f"""
ramble:
variables:
mpi_command: '{mpi_cmd}'
batch_submit: '{{execute_experiment}}'
processes_per_node: 1
n_nodes: {n_nodes}
applications:
basic:
workloads:
test_wl2:
experiments:
test_exp: {{}}
"""
ws, _ = make_workspace_from_config(test_config)
out = workspace("setup", "--dry-run", global_args=["-D", ws.root])

expected_msg = (
"Command bar requires a non-empty `mpi_command` variable in a multi-node experiment"
)
warning_present = expected_msg in out
assert warning_present == expect_warning
Original file line number Diff line number Diff line change
Expand Up @@ -2224,8 +2224,11 @@ def _define_commands(self, exec_graph=None, success_list=None):
n_nodes = self.expander.expand_var_name(
self.keywords.n_nodes
)
n_nodes = 1 if "{n_nodes}" else n_nodes
n_nodes = 1 if not n_nodes else int(n_nodes)
n_nodes = (
Comment thread
linsword13 marked this conversation as resolved.
1
if n_nodes in ("{n_nodes}", None, "")
else int(n_nodes)
)
Comment thread
linsword13 marked this conversation as resolved.
if not raw_mpi_cmd and n_nodes > 1:
logger.warn(
f"Command {cmd_conf.name} requires a non-empty `mpi_command` "
Expand Down
Loading