Skip to content

Commit

Permalink
Defend against -1 values for n_nodes (and update examples)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfbgo committed Nov 14, 2024
1 parent 748c227 commit 9eb7709
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/basic_hostname_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ramble:
variables:
mpi_command: mpirun
batch_submit: '{execute_experiment}'
processes_per_node: -1
processes_per_node: 1
applications:
hostname:
workloads:
Expand Down
4 changes: 2 additions & 2 deletions lib/ramble/docs/tutorials/mirrors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions lib/ramble/ramble/experiment_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/test/cmd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/ramble/ramble/test/end_to_end/passthrough_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ramble:
variables:
mpi_command: ''
batch_submit: '{execute_experiment}'
processes_per_node: -1
processes_per_node: 1
applications:
iperf2:
workloads:
Expand Down

0 comments on commit 9eb7709

Please sign in to comment.