Skip to content

Commit d65ef17

Browse files
committed
Improve error handling in pcmdi_setup
1 parent 9396546 commit d65ef17

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

zppy_interfaces/pcmdi_diags/pcmdi_setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,15 @@ def derive_missing_variable(varin, path, model_id):
377377
base_ds = None
378378
output_file = None
379379

380+
vars_without_files: List[str] = []
381+
380382
for i, (src_var, scale) in enumerate(var_dic.items()):
381383
fpaths = sorted(glob.glob(os.path.join(path, f"*.{src_var}.*.nc")))
382384
if not fpaths:
383-
raise FileNotFoundError(
385+
vars_without_files.append(
384386
f"No file found for source variable '{src_var}' in {path}"
385387
)
388+
continue
386389
fpath = fpaths[0]
387390
ds = xcdat_open(fpath)
388391
data = ds[src_var] * scale
@@ -397,6 +400,9 @@ def derive_missing_variable(varin, path, model_id):
397400
else:
398401
derived_data = derived_data + data
399402

403+
if vars_without_files:
404+
raise FileNotFoundError(" ; ".join(vars_without_files))
405+
400406
if base_ds is not None and derived_data is not None:
401407
derived_da = xr.DataArray(
402408
data=derived_data.data,

0 commit comments

Comments
 (0)