Description
MDPDatastore.get_dataarray's own docstring says: "'state' is the only required category, for other categories, the method will return None if the category is not found in the datastore." This matches the abstract base class contract (BaseDatastore.get_dataarray, base.py:234-238): "'forcing' and 'static' are optional (in which case the method should return None)."
But the implementation only special-cases "forcing":
if category not in self._ds and category == "forcing":
warnings.warn("no forcing data found in datastore")
return None
The identical pattern (only guarding "forcing", never "static") is copy-pasted across four methods in neural_lam/datastore/mdp.py: get_vars_units, get_vars_names, get_vars_long_names, and get_dataarray.
Failure scenario
An mllam-data-prep config that defines state and forcing inputs but no static output category (a legitimate configuration per the documented interface) raises an unhandled KeyError: "No variable named 'static'" from any of these four methods, instead of gracefully returning None/[] as the interface promises and as every caller (WeatherDataset, StepPredictor, etc.) expects.
Not covered by existing tests - tests/test_datastores.py only exercises example configs that always include all three categories.
Fix
Extend the guard in all four methods from category == "forcing" to category != "state", matching the documented "only state is required" contract, with a category-aware warning message.
Description
MDPDatastore.get_dataarray's own docstring says: "'state' is the only required category, for other categories, the method will returnNoneif the category is not found in the datastore." This matches the abstract base class contract (BaseDatastore.get_dataarray, base.py:234-238): "'forcing' and 'static' are optional (in which case the method should returnNone)."But the implementation only special-cases
"forcing":The identical pattern (only guarding
"forcing", never"static") is copy-pasted across four methods inneural_lam/datastore/mdp.py:get_vars_units,get_vars_names,get_vars_long_names, andget_dataarray.Failure scenario
An
mllam-data-prepconfig that definesstateandforcinginputs but nostaticoutput category (a legitimate configuration per the documented interface) raises an unhandledKeyError: "No variable named 'static'"from any of these four methods, instead of gracefully returningNone/[]as the interface promises and as every caller (WeatherDataset,StepPredictor, etc.) expects.Not covered by existing tests -
tests/test_datastores.pyonly exercises example configs that always include all three categories.Fix
Extend the guard in all four methods from
category == "forcing"tocategory != "state", matching the documented "only state is required" contract, with a category-aware warning message.