From 310e0ff24b97e31f377165ffe36231524cb7c12b Mon Sep 17 00:00:00 2001 From: thorbjoernl <51087536+thorbjoernl@users.noreply.github.com> Date: Thu, 19 Dec 2024 11:17:26 +0100 Subject: [PATCH] Warn user if var_order_menu does not match used variables --- pyaerocom/aeroval/setup_classes.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pyaerocom/aeroval/setup_classes.py b/pyaerocom/aeroval/setup_classes.py index b266dd2ad..029b7ac03 100644 --- a/pyaerocom/aeroval/setup_classes.py +++ b/pyaerocom/aeroval/setup_classes.py @@ -27,6 +27,7 @@ computed_field, field_serializer, field_validator, + model_validator, ) from pyaerocom import __version__, const @@ -356,6 +357,24 @@ class EvalSetup(BaseModel): _aux_funs: dict = {} + @model_validator(mode="after") + def model_validator(self) -> Self: + # Warn user if var_order_menu does not match used variables. + var_order_menu = set(self.webdisp_opts.var_order_menu) + obs_cfg = self.obs_cfg + + variables = set() + for entry in obs_cfg: + for var in entry.obs_vars: + variables.add(var) + + if not var_order_menu.issuperset(variables): + logger.warning( + f"Some variables are configured as obsvars but not included in var_order_menu. They may not show up on aerovalweb. Missing variables: {list(variables - var_order_menu)}" + ) + + return self + @computed_field @cached_property def proj_info(self) -> ProjectInfo: