refactor: Make model features configurable via FeatureManager #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
This PR addresses a core architectural limitation by refactoring the
GraphWeatherForecaster
to support configurable input and output features, removing the previously hardcoded dimensions. This change significantly improves the repository's flexibility and makes it easier to experiment with new models and feature sets.This was done by:
FeatureManager
class (graph_weather/models/features.py
) to serve as a single source of truth for feature definitions.graph_weather/configs/
directory.GraphWeatherForecaster
and itsConfig
to accept dynamicinput_features
andoutput_features
arguments, decoupling the model architecture from the data schema.This work provides a crucial foundation for implementing new models (like CaFA in #105) that may use different input variables. It also aligns with the goals of issue #126 by introducing a more structured configuration approach.
To ensure full backward compatibility, a
features_default.yaml
file is included that perfectly replicates the original hardcoded 78+24 feature set.Fixes #
How Has This Been Tested?
The refactored
GraphWeatherForecaster
andFeatureManager
were tested using test scripts and interactively in a Jupyter notebook to validate:Correct parsing of the default 102-feature configuration.
Correct parsing of a minimal, custom 1-feature configuration.
Successful model instantiation and forward passes with both fake data and a real single-level ERA5 dataset, proving the end-to-end flexibility of the new system.
Yes
If your changes affect data processing, have you plotted any changes? i.e. have you done a quick sanity check?
(N/A - This change refactors the model's interface but does not alter the data processing logic itself.)
Checklist: