-
-
Notifications
You must be signed in to change notification settings - Fork 330
Make create_array
signatures consistent
#2819
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
base: main
Are you sure you want to change the base?
Make create_array
signatures consistent
#2819
Conversation
worth noting that this changes some defaults (we were using a default fill_value of |
|
That works for me. In |
…x/consistent-create-array-signature
with 642272d the default fill value is |
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.
👍 for this in general - I left one request for a more verbose changelog entry, and one question.
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.
Thanks for the changelog update, looks great to me. I left one more suggestion - I did a bit of testing and this doesn't seem to change the fill value that's set on the arrays (which is good, but I think worth reassuring users)
how did you check this? because for zarr v2 data, it should make a difference -- |
I didn't check for v2 🙈 . If it does make a difference, that should be made very clear in the changelog (and we should think about putting this PR in a non-bugfix release since it's a breaking change?) |
I'd hope that since the below PRs, the metadata of the Zarr V2 data with |
@LDeakin that was my impression as well. I think for v2 data the contents of the array metadata will be sensitive to the |
Indeed! To be honest, I think |
The nullable fill value is also clunky because zarr v2 supports the python We would have to get a measure of the impact on users, but if it doesn't inconvenience a lot of people then I would definitely support dropping the creation of arrays with a |
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.
Sorry to be a bit of a pain, but I'm going to put a request changes on this until we've resolved how we're going to bump the version number (and/or update our versioning policy) for this change. See #2819 (comment) for more context.
that works for me! would you like to open an issue about the versioning policy, or should I? |
I can 👍 |
…x/consistent-create-array-signature
Is changing the default value of the |
ultimately I think whether these changes are breaking depends on whether you believe it's a bug that different definitions of the same function have different default values. |
Does changing the values affect any behaviour, or any metadata that gets written to zarr arrays or groups? If not, then I'd say this isn't breaking. If it does, then I'd say it is breaking. |
I think there are two questions:
Because this library produces data, we will inevitably have bugs that affect how data is produced. Therefore, fixing those bugs will change how data is produced. If the bug fix takes us from "writes invalid data" to "writes valid data", that's a clear win. But if the bug fix takes us from "writes valid data" to "writes slightly different valid data", then things are less clear cut. I think we are in this second scenario. For simplicity lets say that these changes are breaking, and thus a good fit for a 3.1 release. it might be time to think about a 3.1 branch! |
I think my confusion/questions are stemming from the short explanation of what's changed in the changelog entry. I think the default argument would benefit from being being added to it's own |
there is no change here, zarr-python uses an array of zeros (or the zeros-equivalent, per data type) in either case. |
I still need to wrap my head around the fill value changes a bit - in the meantime, perhaps adding the new arguments could be done in a separate PR, since that's definitely backwards compatible and probably something we could put in a 3.0.x release? |
i would rather not split this PR into pieces. |
Ah, because that would ruin the automatic testing you added - gotcha. Will try and give this a proper re-review soon. |
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.
👍 had another think about this, and I think it's good as long as the changelog is fixed so it's visible. I would like someone else to review this though, just to check the default changes to the fill value are okay.
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.
Since "chore type" changelong entries don't get rendered (e.g., see https://zarr.readthedocs.io/en/stable/release-notes.html#misc), I'd recommend splitting this up into a "feature" entry for the updated signatures, and a separate "feature" for the change in default fill_value arguments.
This PR ensures that the various invocations of
create_array
are consistent. For reference, we have 4 ways to callcreate_array
:zarr.core.array.create_array
(the actual function that does stuff)zarr.api.synchronous.create_array
(synchronous wrapper around the async function)zarr.core.group.AsyncGroup.create_array
(method onAsyncGroup
class that invokescreate_array
)zarr.core.group.Group.create_array
(synchronous wrapper around the AsyncGroup method)All of these functions should have consistent signatures, but in main they don't, and a big part of this is missing tests. So this PR adds some tests that check that certain pairs of functions have identical parameters (we can't force the return types to match, because the async functions will return coroutines). To make the tests pass, this PR also ensures that all of the invocations of
create_array
have parameters that are consistent.I say "consistent" because, when invoking
Group.create_array
, that method does not take astore
argument, because we have one already from the group instance. Also,Group.create_array
was recently given an extra keyword argument (compressor
) that we need to deprecate. So the test that compareszarr.core.array.create_array
withzarr.core.group.AsyncGroup.create_array
only checks that all ofcreate_array
parameters are present in the group method.closes #2810