-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework calliope model attributes #625
Conversation
@brynpickering first step towards the new attribute setup. This one fixes how math dictionaries are handled. I'll try to debug that before continuing. |
|
src/calliope/model.py
Outdated
self._is_built: bool = False | ||
self._is_solved: bool = False | ||
|
||
# new | ||
self.math: AttrDict = AttrDict() | ||
self._math_dir: Path = Path(calliope.__file__).parent / "math" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer importlib.resources.files("calliope")
src/calliope/model.py
Outdated
@@ -504,7 +509,9 @@ def run(self, force_rerun=False, **kwargs): | |||
|
|||
def to_netcdf(self, path): | |||
"""Save complete model data (inputs and, if available, results) to a NetCDF file at the given `path`.""" | |||
io.save_netcdf(self._model_data, path, model=self) | |||
self._model_data.attrs["math"] = self.math |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this step to be in IO, i.e. pass math to IO
@brynpickering this fix is causing some VERY weird behavior on the backend (actually reintroducing #623) and around operate mode. |
In that case, shouldn't we re-activate the tests that check it / remove the unnecessary ones? |
e0336a4
to
b087580
Compare
My approach was incorrect. Retrying! |
Fixes #619
Summary of changes in this pull request
See this table: #619 (comment)
Reviewer checklist