Skip to content

Commit

Permalink
Update template_run_script.py and base_run_script.py
Browse files Browse the repository at this point in the history
- Add new parameters for cfg_path and multiprocessing
  • Loading branch information
tomvothecoder committed Feb 15, 2024
1 parent 46a10ed commit db652ac
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
17 changes: 11 additions & 6 deletions auxiliary_tools/cdat_regression_testing/base_run_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# flake8: noqa E501

import os
import sys
from typing import List, Tuple, TypedDict

from mache import MachineInfo
Expand Down Expand Up @@ -44,7 +45,15 @@ class MachinePaths(TypedDict):
tc_test: str


def run_set(set_name: str, set_dir: str):
def run_set(
set_name: str,
set_dir: str,
cfg_path: str | None = None,
multiprocessing: bool = True,
):
if cfg_path is not None:
sys.argv.extend(["--diags", cfg_path])

machine_paths: MachinePaths = _get_machine_paths()

param = CoreParameter()
Expand All @@ -58,7 +67,7 @@ def run_set(set_name: str, set_dir: str):
] # Default setting: seasons = ["ANN", "DJF", "MAM", "JJA", "SON"]

param.results_dir = os.path.join(BASE_RESULTS_DIR, set_dir)
param.multiprocessing = True
param.multiprocessing = multiprocessing
param.num_workers = 5

# Make sure to save the netCDF files to compare outputs.
Expand Down Expand Up @@ -251,7 +260,3 @@ def _get_test_data_dirs(machine: str) -> Tuple[str, str]:
)

return test_data_dirs # type: ignore


if __name__ == "__main__":
run_set()
18 changes: 17 additions & 1 deletion auxiliary_tools/cdat_regression_testing/template_run_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
7. Make a copy of the CDAT regression testing notebook in the same directory
as this script and follow the instructions there to start testing.
8. <OPTIONAL> Update `CFG_PATH` to a custom cfg file to debug specific variables.
- It is useful to create a custom cfg based on the default diags to debug
specific variables that are running into problems.
- For example, copy `zonal_mean_xy_model_vs_model.cfg` into the same directory
as the copy of this script, then modify it to specific variables. Afterwards
update `CFG_PATH` to the path of that .cfg file.
- Tip: Use VS Code to step through the code with the Python debugger.
"""
from auxiliary_tools.cdat_regression_testing.base_run_script import run_set

Expand All @@ -32,4 +40,12 @@
# Example: "671-lat-lon"
SET_DIR = ""

run_set(SET_NAME, SET_DIR)
# TODO: <OPTIONAL> UPDATE CFG_PATH if using a custom cfg file for debugging.
# Example: "auxiliary_tools/cdat_regression_testing/654_zonal_mean_xy.cfg"
CFG_PATH: str | None = None

# TODO: <OPTIONAL> Update MULTIPROCESSING based on whether to run in parallel or
# serial. For debugging purposes, set to False to run serially.
MULTIPROCESSING = True

run_set(SET_NAME, SET_DIR, CFG_PATH, MULTIPROCESSING)

0 comments on commit db652ac

Please sign in to comment.