Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork366
Prevent creation of arrays/groups under a parent array#3407
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codecovbot commentedAug 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@## main #3407 +/- ##==========================================- Coverage 61.24% 61.21% -0.04%========================================== Files 83 84 +1 Lines 9907 9923 +16 ==========================================+ Hits 6068 6074 +6- Misses 3839 3849 +10
🚀 New features to boost your workflow:
|
conceptually I don't think we want a right now I think a better location would be |
Thanks@d-v-b - I think the only issue with this is it may introduce a circular import? I could move those functions into |
d-v-b commentedAug 26, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
very good points@K-Meech. Now I do think we should have In fact, we might not need the metadata-saving logic in I suspect all of this could be handled by edit: I mistakenly linked to the zarr-python/src/zarr/core/group.py Line 2985 inc9509ee
|
Thanks@d-v-b - sounds like a good plan. I'll look into removing the dependency on |
@d-v-b I've updated the code now to match your suggestion above. The dependency on I agree that |
That works for me! |
| @pytest.mark.asyncio | ||
| asyncdeftest_async_oindex_with_zarr_array(self,store): | ||
| z1=zarr.create_array(store=store,shape=(2,2),chunks=(1,1),zarr_format=3,dtype="i8") |
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.
why did we need to change this test?
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.
This test creates an array as a child of another array, so would throw an error (I changed it to create a group then put both arrays inside instead).
E.g. running the equivalent for a local store, shows an array inside an array:
store = LocalStore("data/images/arr")z1 = zarr.create_array(store=store, shape=(2, 2), chunks=(1, 1), zarr_format=3, dtype="i8")z1[...] = np.array([[1, 2], [3, 4]])async_zarr = z1._async_array# create boolean zarr array to index withz2 = zarr.create_array( store=store, name="z2", shape=(2,), chunks=(1,), zarr_format=3, dtype="?")z2[...] = np.array([True, False])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.
thank you!
de94764 intozarr-developers:mainUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Closes#2582
Prevents creation of arrays / groups under a parent array with
.create_arrayand.create_groupe.g.root.create_array(name='foo/bar')(wherefoois an existing array)This required changes to the
_save_metadatafunction of bothzarr/core/array.pyandzarr/core/group.py. As both used pretty much identical code, I refactored this into a common function inzarr/core/metadata/io.py(along with the_build_parentsfunction both relied upon). Happy to move this elsewhere - if there is a more suitable location for it!I tried to avoid looping over the parents multiple times in
_save_metadatafor the sake of performance (potentially this path could be deeply nested). Hence looping once, and creating two sets of awaitables: one for checking if an array exists at the location + one to actually modify the metadata there. Again, happy to update this if there's a simpler solution.TODO:
docs/user-guide/*.rstchanges/