Skip to content
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

fix: xarray 2024.09.0 compatility #227

Merged
merged 1 commit into from
Sep 12, 2024
Merged

fix: xarray 2024.09.0 compatility #227

merged 1 commit into from
Sep 12, 2024

Conversation

slevang
Copy link
Contributor

@slevang slevang commented Sep 12, 2024

closes #226

Lot's of changes to datatree on xarray main since the latest release. These 3 all tripped us up:

pydata/xarray#9297
pydata/xarray#9444
pydata/xarray#9476

Maybe it was a little early to enable using the migrated datatree since it's not technically public API yet but I suppose it let's us fix these issues quickly.

@@ -90,7 +90,7 @@ def serialize(self) -> DataTree:
"""Serialize a complete model with its preprocessor."""
# Create a root node for this object with its params as attrs
ds_root = xr.Dataset(attrs=dict(params=self.get_params()))
dt = DataTree(data=ds_root, name=type(self).__name__)
dt = DataTree(ds_root, name=type(self).__name__)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To maintain compatibility with prior versions I changed all cases of data= to be the first positional arg, since the kwarg is now dataset.

@@ -391,7 +391,6 @@ def serialize(self) -> DataTree:
dt_transformer = transformer_obj.serialize()
# Place the serialized transformer in the tree
dt[name] = dt_transformer
dt[name].parent = dt
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why I had this here anyways

@slevang slevang requested a review from nicrie September 12, 2024 14:53
@slevang
Copy link
Contributor Author

slevang commented Sep 12, 2024

@nicrie feel free to redirect this to develop if you want to package together with #225

Copy link
Contributor

@nicrie nicrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for the quick fix @slevang !

@nicrie nicrie changed the base branch from main to develop September 12, 2024 22:23
@nicrie nicrie merged commit 5ed9753 into develop Sep 12, 2024
11 checks passed
@nicrie nicrie deleted the fix-datatree-changes branch September 12, 2024 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError: DataTree.__init__() got an unexpected keyword argument 'data'
2 participants