z5 icon indicating copy to clipboard operation
z5 copied to clipboard

Strange error message when trying to r+ open a file that does not exist

Open pgunn opened this issue 2 years ago • 1 comments

paradox:~/src/caiman_dev-clean$ python
Python 3.9.12 | packaged by conda-forge | (main, Mar 24 2022, 23:25:59) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import z5py
>>> fh = z5py.File('/tmp/experiment.zarr', 'r+')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pgunn/miniconda3/envs/caiman/lib/python3.9/site-packages/z5py/file.py", line 84, in __init__
    raise OSError(errno.EROFS, os.strerror(errno.EROFS), handle.path())
OSError: [Errno 30] Read-only file system: '/tmp/experiment.zarr'
>>> fh = z5py.File('/tmp/experiment.zarr', 'w')

That "read-only filesystem" message is bizarre.

pgunn avatar Apr 04 '22 17:04 pgunn

This error is thrown here: https://github.com/constantinpape/z5/blob/master/src/python/module/z5py/file.py#L84 When trying to open a file in r or r+ that doesn't exist.

I agree that the error could be improved, PRs are welcome.

For reference, here's what h5py throws in this situation:

h5py.File("x.h5", "r+")
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = 'x.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)

constantinpape avatar Apr 05 '22 08:04 constantinpape