Skip to content

Commit d8f7c63

Browse files
committed
fix failout issues
1 parent 2ab9760 commit d8f7c63

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/monthly_cmor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from typing import Optional, Tuple
2323
import sys
2424
from datetime import datetime, UTC
25+
import glob
2526

2627
import xarray as xr
2728
from cmip7_prep.mapping_compat import Mapping
@@ -305,6 +306,9 @@ def main():
305306
INPUTDIR = os.path.join(inputroot, subdir, "hist")
306307
TSDIR = Path(inputroot).parent / "timeseries" / casename / subdir / "hist"
307308
native = latest_monthly_file(Path(INPUTDIR))
309+
if native is None:
310+
print(f"No output files found in {INPUTDIR}")
311+
sys.exit(0)
308312
if TSDIR.exists():
309313
timeseries = latest_monthly_file(TSDIR)
310314
if timeseries is not None:
@@ -365,6 +369,14 @@ def main():
365369
if args.skip_timeseries:
366370
print("Skipping timeseries processing as per --skip-timeseries flag.")
367371
else:
372+
cnt = 0
373+
for include_pattern in include_patterns:
374+
cnt = cnt + len(glob.glob(os.path.join(input_head_dir, include_pattern)))
375+
if cnt == 0:
376+
logger.warning(
377+
f"No input files to process in {input_head_dir} with {include_patterns}"
378+
)
379+
sys.exit(0)
368380
hf_collection = HFCollection(input_head_dir, dask_client=client)
369381
for include_pattern in include_patterns:
370382
logger.info(f"Processing files with pattern: {include_pattern}")

0 commit comments

Comments
 (0)