Skip to content

Commit

Permalink
fix logic in ModelDataPaths where MODEL_DATA_ROOT and related diction…
Browse files Browse the repository at this point in the history
…aries are initialized

initialize user_pp_scripts attribute in DaskMultiFilePreprocessor, set user_pp_scripts to None if no scripts are defined in the config,
and add check for non-zero-length user_pp_scripts to preprocessor
fix date string def in runtime_config.yml
  • Loading branch information
wrongkindofdoctor committed Apr 4, 2024
1 parent 1cacdb2 commit 6d4bb90
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
5 changes: 4 additions & 1 deletion src/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def execute_pp_functions(self, v: varlist_util.VarlistEntry,
xarray_ds = func.execute(func, v, xarray_ds, **kwargs)
# append custom preprocessing scripts

if any([s for s in self.user_pp_scripts]):
if self.user_pp_scripts and len(self.user_pp_scripts) > 0:
for s in self.user_pp_scripts:
script_name, script_ext = os.path.splitext(s)
full_module_name = "user_scripts." + script_name
Expand Down Expand Up @@ -1262,6 +1262,7 @@ class DaskMultiFilePreprocessor(MDTFPreprocessorBase):
<https://xarray.pydata.org/en/stable/generated/xarray.open_mfdataset.html>`__.
"""
module_root: str = ""
user_pp_scripts: list

def __init__(self,
model_paths: util.ModelDataPathManager,
Expand All @@ -1272,6 +1273,8 @@ def __init__(self,
if any([s for s in config.user_pp_scripts]):
self.add_user_pp_scripts(config)
self.module_root = os.path.join(config.CODE_ROOT, "user_scripts")
else:
self.user_pp_scripts = None

def add_user_pp_scripts(self, runtime_config: util.NameSpace):
self.user_pp_scripts = [s for s in runtime_config.user_pp_scripts]
Expand Down
6 changes: 3 additions & 3 deletions src/util/path_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ def __init__(self, config: NameSpace,

if hasattr(config, "MODEL_DATA_ROOT"):
self.MODEL_DATA_ROOT = self._init_path('MODEL_DATA_ROOT', config, env=env)
self.MODEL_DATA_DIR = dict()
self.MODEL_OUTPUT_DIR = dict()
self.MODEL_WORK_DIR = dict()
else:
self.MODEL_DATA_ROOT = ""
self.MODEL_DATA_DIR = dict()
self.MODEL_OUTPUT_DIR = dict()
self.MODEL_WORK_DIR = dict()

def setup_data_paths(self, case_list: NameSpace):
# define directory paths for multirun mode
Expand Down
17 changes: 8 additions & 9 deletions templates/runtime_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@
# List of POD(s) to run
pod_list:
- "example_multicase"
- "MJO_suite"

# Case list entries (must be unique IDs for each simulation)
case_list:
"CMIP_Synthetic_r1i1p1f1_gr1_19800101-19841231" :
model: "test"
convention: "CMIP"
startdate: "19800101:000000"
enddate: "19841231:000000"
startdate: "19800101120000"
enddate: "19841231000000"

"CMIP_Synthetic_r1i1p1f1_gr1_19850101-19891231" :
model: "test"
convention: "CMIP"
startdate: "19850101:000000"
enddate: "19891231:000000"
startdate: "19850101000000"
enddate: "19891231000000"

### Data location settings ###
# Required: full or relative path to ESM-intake catalog header file
Expand All @@ -31,17 +30,17 @@ OBS_DATA_ROOT: "../inputdata/obs_data"
# Final output is also written here if the OUTPUT_DIR is not defined.
WORK_DIR: "../wkdir"
# Optional: Location to write final output if you don't want it in the wkdir
OUTPUT_DIR: ""
OUTPUT_DIR: "../wkdir"
### Environment Settings ###
# Required: Location of the Anaconda/miniconda installation to use for managing
# dependencies (path returned by running `conda info --base`.)
conda_root": ""
conda_root: "/Users/jess/micromamba"
# Optional: Directory containing the framework-specific conda environments. This should
# be equal to the "--env_dir" flag passed to conda_env_setup.sh. If left
# blank, the framework will look for its environments in conda_root/envs
conda_env_root": ""
conda_env_root: "/Users/jess/micromamba/envs"
# Location of micromamba executable; REQUIRED if using micromamba
micromamba_exe: ""
micromamba_exe: "/Users/jess/.local/bin/micromamba"
### Data type settings ###
# set to true to handle data files > 4 GB
large_file: False
Expand Down

0 comments on commit 6d4bb90

Please sign in to comment.