-
-
Notifications
You must be signed in to change notification settings - Fork 328
No such file or directory when replacing an array #2892
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
Comments
hi @csparker247, thanks for the bug report. It's possible that this was previously reported here. In any case, we definitely need to fix this. I don't have the bandwidth for it now but hopefully another member of the python dev team can look into it |
Thanks. It doesn't look exactly like the same thing, but it certainly seems to be related behavior. I wasn't aware of the |
I'll have a look at this |
@csparker247 Unfortunately I was not able to reproduce your error. I created the following array before running your script: g = zarr.create_group("foo")
g.create_group("01234").create_array("labels", shape=(512, 512, 512), chunks=(64, 64, 64), dtype=np.uint8)
g["01234"]["labels"][...] = np.ones((512, 512, 512), np.uint8) This caused no problems. Could you provide more information about the creation/size of your array. Are you running the script multiple times in parallel, so that the race condition comes from trying to delete the array multiple times? |
My dataset is a zarr group containing 3120 sub-groups representing 3D datasets, some of which are labeled. Each sub-group has a
I detected an issue with my label generation that affected the shape of the labels array, so I needed to delete the old labels array rather than just changing its value, hence the logic of the example script. I was not running this in parallel. I simply ran the script on the command line, received the error, hit the up arrow to get the previous command, ran it again, received the error, etc. |
@csparker247 Please try running your delete script once when you are sure that your filesystem has finished modified/deleting files.
path = ...
# recreate your array
g = zarr.create_group(path)
g.create_group("03119")
g["03119"].create_array("labels", shape=(57, 512, 512), chunks=(12, 64, 64), shards=(24, 512, 512), dtype=np.uint8)
g["03119"]["labels"][...] = np.full((57, 512, 512), 3, np.uint8)
g["03119"].create_array("data", shape=(57, 512, 512), chunks=(12, 64, 64), shards=(24, 512, 512), dtype=np.uint16)
g["03119"]["labels"][...] = np.full((57, 512, 512), 3, np.uint16)
# create a replacement array
labels = np.ones((47, 1, 512), np.uint8)
# open the zarr and select a sub-group
z = zarr.open(path, mode='r+')
root = z['03119']
# delete the labels array
if 'labels' in root.keys():
del root['labels']
# create and assign the new labels array
a = root.create_array('labels',
dtype=labels.dtype,
shape=labels.shape,
chunks=(12, 64, 64),
shards=(24, 512, 512),
config={'write_empty_chunks': False})
a[...] = labels |
Zarr version
3.0.4
Numcodecs version
0.15.1
Python Version
3.12.8
Operating System
Mac
Installation
using pip to a venv
Description
I'm trying to replace (or create if it doesn't exist) an array that's inside an existing, local zarr group. Since the array I want to add may or may not be the same size as the existing array, I'm trying to delete the existing entry and create a new array fresh using
del
. Yes, I know I can check the existing shape to avoid an unnecessary deletion. Similar to #2334, the call todel
raises aFileNotFoundError
:If I try to run my script multiple times after this failure, I get the following:
UserWarning: Object at labels is not recognized as a component of a Zarr hierarchy.
but succeeds.FileNotFound
error.UserWarning...
UserWarning...
This leads me to believe that there is some race condition with the OS or filesystem, and eventually something starts caching the correct operations so that the deletion succeeds every time.
Steps to reproduce
If I run the following script with my full zarr, I get the errors as described. Unfortunately, if I try to create a new, minimal dataset from scratch with only one entry, this script does not reproduce the error.
Additional output
No response
The text was updated successfully, but these errors were encountered: