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

parse_url in write mode does not truncate #97

Open
constantinpape opened this issue Jul 8, 2021 · 2 comments
Open

parse_url in write mode does not truncate #97

constantinpape opened this issue Jul 8, 2021 · 2 comments

Comments

@constantinpape
Copy link
Contributor

Passing mode=w to parse_url does not truncate existing files as it should.
Minimal example:

import numpy as np
import ome_zarr.writer
import zarr
file_path = "my.ome.zarr"
loc = ome_zarr.io.parse_url(file_path, mode="w")
group = zarr.group(loc.store)
shape = (1, 1, 1, 256, 256)
ome_zarr.writer.write_image(np.random.rand(*shape), group)

Fails with ContainsArrayError: path '0' contains an array when run the second time.

@joshmoore
Copy link
Member

I've definitely run into this before, but I would think this is coming directly from zarr-python (unless you think the mode isn't being passed somewhere)

@dstansby
Copy link
Contributor

Having a look at this, I agree it's coming from zarr-python. The issue is init_array takes an overwrite argument, which defaults to False and doesn't take into account the file mode of the store (which is what's being passed in the example above). I haven't time now, but should be possible to cook up a zarr-python-only reproducible example.

This is probably also the same issue as #376

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

No branches or pull requests

3 participants