Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate verbose flag into PBS job script #293

Merged
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
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
Loading