From 9eb770900fb428c3e37d5f53c573c057b2cd5ad2 Mon Sep 17 00:00:00 2001 From: Bob Bird Date: Tue, 12 Nov 2024 11:59:51 -0700 Subject: [PATCH] Defend against -1 values for n_nodes (and update examples) --- examples/basic_hostname_config.yaml | 2 +- lib/ramble/docs/tutorials/mirrors.rst | 4 ++-- lib/ramble/ramble/experiment_set.py | 6 ++++++ lib/ramble/ramble/test/cmd/config.py | 2 +- lib/ramble/ramble/test/end_to_end/passthrough_variables.py | 2 +- .../applications/iperf2/examples/manual_run/ramble.yaml | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/basic_hostname_config.yaml b/examples/basic_hostname_config.yaml index f069699c5..8c19ca283 100644 --- a/examples/basic_hostname_config.yaml +++ b/examples/basic_hostname_config.yaml @@ -13,7 +13,7 @@ ramble: variables: mpi_command: mpirun batch_submit: '{execute_experiment}' - processes_per_node: -1 + processes_per_node: 1 applications: hostname: workloads: diff --git a/lib/ramble/docs/tutorials/mirrors.rst b/lib/ramble/docs/tutorials/mirrors.rst index a15b8a7a0..fb694d513 100644 --- a/lib/ramble/docs/tutorials/mirrors.rst +++ b/lib/ramble/docs/tutorials/mirrors.rst @@ -54,7 +54,7 @@ Write the following configuration into the file, save, and exit: variables: mpi_command: mpirun -n {n_ranks} batch_submit: '{execute_experiment}' - processes_per_node: -1 + processes_per_node: 1 applications: wrfv4: variables: @@ -84,7 +84,7 @@ will look something like this: variables: mpi_command: mpirun -n {n_ranks} batch_submit: '{execute_experiment}' - processes_per_node: -1 + processes_per_node: 1 applications: wrfv4: variables: diff --git a/lib/ramble/ramble/experiment_set.py b/lib/ramble/ramble/experiment_set.py index 9e2241f03..a29c88d52 100644 --- a/lib/ramble/ramble/experiment_set.py +++ b/lib/ramble/ramble/experiment_set.py @@ -214,12 +214,18 @@ def _compute_mpi_vars(self, expander, variables): if n_ranks: n_ranks = int(expander.expand_var(n_ranks)) + if n_ranks <= 0: + logger.error("n_ranks must be positive") if ppn: ppn = int(expander.expand_var(ppn)) + if ppn <= 0: + logger.error("processes_per_node must be positive") if n_nodes: n_nodes = int(expander.expand_var(n_nodes)) + if n_nodes <= 0: + logger.error("n_nodes must be positive") if n_threads: n_threads = int(expander.expand_var(n_threads)) diff --git a/lib/ramble/ramble/test/cmd/config.py b/lib/ramble/ramble/test/cmd/config.py index ae3fe85cc..fdb333c3b 100644 --- a/lib/ramble/ramble/test/cmd/config.py +++ b/lib/ramble/ramble/test/cmd/config.py @@ -685,7 +685,7 @@ def test_config_add_to_workspace_preserve_comments( variables: n_ranks: '1' n_nodes: '1' - processors_per_node: '1' + processes_per_node: '1' """ with open(filepath, "w") as f: f.write(contents) diff --git a/lib/ramble/ramble/test/end_to_end/passthrough_variables.py b/lib/ramble/ramble/test/end_to_end/passthrough_variables.py index 1abf74408..d21966ba5 100644 --- a/lib/ramble/ramble/test/end_to_end/passthrough_variables.py +++ b/lib/ramble/ramble/test/end_to_end/passthrough_variables.py @@ -82,7 +82,7 @@ def test_disable_passthrough(mutable_config, mutable_mock_workspace_path): ramble: variables: batch_submit: '{execute_experiment}' - processes_per_node: -1 + processes_per_node: 1 applications: hostname: workloads: diff --git a/var/ramble/repos/builtin/applications/iperf2/examples/manual_run/ramble.yaml b/var/ramble/repos/builtin/applications/iperf2/examples/manual_run/ramble.yaml index 9e6e8d7be..dd8d5b135 100644 --- a/var/ramble/repos/builtin/applications/iperf2/examples/manual_run/ramble.yaml +++ b/var/ramble/repos/builtin/applications/iperf2/examples/manual_run/ramble.yaml @@ -23,7 +23,7 @@ ramble: variables: mpi_command: '' batch_submit: '{execute_experiment}' - processes_per_node: -1 + processes_per_node: 1 applications: iperf2: workloads: