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

Basic Zarr-python 2.x compatibility changes #2098

Open
wants to merge 25 commits into
base: v3
Choose a base branch
from

Conversation

TomAugspurger
Copy link
Contributor

Demonstration of some changes for backwards compatibility being discussed at #2097

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • GitHub Actions have all passed
  • Test coverage is 100% (Codecov passes)

@classmethod
async def create(
async def from_store(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In 2.x, Group.create was used to create an array in the Group.

I slightly prefer from_* for alternative constructors anyway, so maybe this is a strict improvement and not just a compatibility shim?

Copy link
Member

Choose a reason for hiding this comment

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

I agree that this needs to change in order to avoid confusion.

Copy link
Contributor

Choose a reason for hiding this comment

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

i'm also a fan of from_X, and from_store seems good

store: StoreLike | None = None,
*,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can vendor and use https://github.com/scikit-learn/scikit-learn/blob/e87b32a81c70abed8f2e97483758eb64df8255e9/sklearn/utils/validation.py#L32 to deprecate positional arguments. At least of xarray, it passed just store as a positional argument, but deprecating these doesn't feel like too much work.

Copy link
Member

Choose a reason for hiding this comment

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

I like this suggestion. Should we do it in 2.18.3 or 3.0 though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a strong preference here.

IMO, calendar time is more meaningful than version numbers for giving projects time to adapt to changes. So I'd say deprecate it in 3.0, as long as we don't have a hard stance on requiring keyword only for these APIs in 3.0

src/zarr/core/attributes.py Outdated Show resolved Hide resolved
@@ -122,8 +122,12 @@ class AsyncGroup:
metadata: GroupMetadata
store_path: StorePath

@property
def store(self) -> Store:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we deprecate this, and encourage users to do group.store_path.store?

Copy link
Contributor

Choose a reason for hiding this comment

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

github is flagging this conversation as outdated, but regardless: I agree that we should just have either group.store or group.store_path.store. But I'm not a huge fan of store_path actually, so I'd actually favor deprecating that, and going back to v2 behavior where arrays / groups have a store attribute, and the store has a path attribute. But this is just my personal opinion, built from finding group.store_path.store a little weird.

return self._async_group.store

@property
def read_only(self) -> bool:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same question as store.

Should probably add this to AsyncGroup too and update this implementation.

@jhamman
Copy link
Member

jhamman commented Aug 28, 2024

@TomAugspurger - this generally looks like a solid set of fixes. Do you have more here or should try to wrap these up?

@TomAugspurger TomAugspurger marked this pull request as ready for review August 28, 2024 19:24
@TomAugspurger TomAugspurger changed the title [WIP]: Draft of zarr-python 2.x compatibility changes Basic Zarr-python 2.x compatibility changes Sep 3, 2024
import zarr.store


def test_put():
Copy link
Contributor

Choose a reason for hiding this comment

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

in principle we could test this functionality for other stores. but I also think testing the full product of [array / group features * stores] is excessive. I guess as long as we are confident that we are densely testing the core store APIs across store types, then it's fine to just test something derived from the store APIs on a single store.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that in this case it's probably OK, since the test here is focused on the behavior of Attributes. This happens to require a reference to a Group (which requires a Store) but hopefully that interface is sufficiently covered by other tests.

@jhamman jhamman added the V3 Related to compatibility with V3 spec label Sep 13, 2024
@TomAugspurger
Copy link
Contributor Author

I've confirmed that #2157 fixes the CI failure here.

Copy link
Member

@jhamman jhamman left a comment

Choose a reason for hiding this comment

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

Thanks @TomAugspurger for pulling these together. Much improved compatibility with v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
V3 Related to compatibility with V3 spec
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants