Skip to content

Commit

Permalink
Propagate verbose flag into PBS job script
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanBryan51 committed May 9, 2024
1 parent 75cfa3d commit 61af6cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/benchcab/benchcab.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from benchcab.environment_modules import EnvironmentModules, EnvironmentModulesInterface
from benchcab.internal import get_met_forcing_file_names
from benchcab.model import Model
from benchcab.utils import is_verbose
from benchcab.utils.fs import mkdir, next_path
from benchcab.utils.pbs import render_job_script
from benchcab.utils.repo import create_repo
Expand Down Expand Up @@ -202,6 +203,7 @@ def fluxsite_submit_job(self, config_path: str, skip: list[str]) -> None:
modules=config["modules"],
pbs_config=config["fluxsite"]["pbs"],
skip_bitwise_cmp="fluxsite-bitwise-cmp" in skip,
verbose=is_verbose(),
benchcab_path=str(self.benchcab_exe_path),
)
file.write(contents)
Expand Down
5 changes: 5 additions & 0 deletions src/benchcab/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,8 @@ def get_logger(name="benchcab", level="debug"):
logger.addHandler(handler)

return logger


def is_verbose():
"""Return True if verbose output is enabled, False otherwise."""
return get_logger().getEffectiveLevel() == logging.DEBUG
4 changes: 2 additions & 2 deletions src/benchcab/utils/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from abc import abstractmethod
from typing import Any, Optional

from benchcab.utils import get_logger
from benchcab.utils import is_verbose

DEBUG_LEVEL = 10

Expand Down Expand Up @@ -63,7 +63,7 @@ def run_cmd(
"""
# Use the logging level (10 = Debug) to determine verbosity.
verbose = get_logger().getEffectiveLevel() == DEBUG_LEVEL
verbose = is_verbose()
kwargs: Any = {}
with contextlib.ExitStack() as stack:
if capture_output:
Expand Down

0 comments on commit 61af6cb

Please sign in to comment.