Skip to content

Commit

Permalink
Make pbs_config as default argument in render_job_script
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaasgoyal committed Jan 21, 2024
1 parent 9d7208a commit 3f59fe3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 2 additions & 6 deletions benchcab/utils/pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,23 @@

"""Contains helper functions for manipulating PBS job scripts."""

from typing import Optional

from benchcab import internal


def render_job_script(
project: str,
config_path: str,
modules: list,
benchcab_path: str,
pbs_config: dict,
verbose=False,
skip_bitwise_cmp=False,
pbs_config: Optional[dict] = None,
) -> str:
"""Returns the text for a PBS job script that executes all computationally expensive commands.
This includes things such as running CABLE and running bitwise comparison jobs
between model output files.
"""
if pbs_config is None:
pbs_config = internal.FLUXSITE_DEFAULT_PBS
pbs_config = internal.FLUXSITE_DEFAULT_PBS | pbs_config

module_load_lines = "\n".join(
f"module load {module_name}" for module_name in modules
Expand Down
5 changes: 4 additions & 1 deletion tests/test_pbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def test_default_job_script(self):
project="tm70",
config_path="/path/to/config.yaml",
modules=["foo", "bar", "baz"],
pbs_config=internal.FLUXSITE_DEFAULT_PBS,
benchcab_path="/absolute/path/to/benchcab",
) == (
f"""#!/bin/bash
Expand Down Expand Up @@ -46,6 +47,7 @@ def test_verbose_flag_added_to_command_line_arguments(self):
project="tm70",
config_path="/path/to/config.yaml",
modules=["foo", "bar", "baz"],
pbs_config=internal.FLUXSITE_DEFAULT_PBS,
verbose=True,
benchcab_path="/absolute/path/to/benchcab",
) == (
Expand Down Expand Up @@ -80,6 +82,7 @@ def test_skip_bitwise_comparison_step(self):
project="tm70",
config_path="/path/to/config.yaml",
modules=["foo", "bar", "baz"],
pbs_config=internal.FLUXSITE_DEFAULT_PBS,
skip_bitwise_cmp=True,
benchcab_path="/absolute/path/to/benchcab",
) == (
Expand Down Expand Up @@ -145,7 +148,7 @@ def test_pbs_config_parameters(self):
)

def test_default_pbs_config(self):
"""Success case: if the pbs_config is empty, use the default values."""
"""Success case: if any key(s) of pbs_config is/are empty, use the default values."""
assert render_job_script(
project="tm70",
config_path="/path/to/config.yaml",
Expand Down

0 comments on commit 3f59fe3

Please sign in to comment.