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

Refactor 654 zonal mean xy #752

Merged
merged 12 commits into from
Feb 15, 2024
Prev Previous commit
Next Next commit
Update template_run_script.py and base_run_script.py
- Add new parameters for cfg_path and multiprocessing
  • Loading branch information
tomvothecoder committed Feb 15, 2024
commit db652ac808943d5c0fa807bf0c66cc6ada328655
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)
Loading