Transform Directory storage to Zip storage.
See original GitHub issuestore = zarr.ZipStore("/mnt/test.zip", "r")
Problem description
Hi, sry for bothering, I found this statement inside Zarr official documentation about ZipStorage:
Alternatively, use a DirectoryStore when writing the data, then manually Zip the directory and use the Zip file for subsequent reads.
I am trying to transform a DirectoryStorage format Zarr dataset to a ZipStorage. I use zip operation provided in Linux.
zip -r test.zip test.zarr
here test.zarr is a directory storage dataset including three groups. However, when I try to use the codes above to open it, get the error as below:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/eddie/miniconda3/envs/train/lib/python3.8/site-packages/zarr/storage.py", line 1445, in __init__
self.zf = zipfile.ZipFile(path, mode=mode, compression=compression,
File "/home/eddie/miniconda3/envs/train/lib/python3.8/zipfile.py", line 1190, in __init__
_check_compression(compression)
File "/home/eddie/miniconda3/envs/train/lib/python3.8/zipfile.py", line 686, in _check_compression
raise NotImplementedError("That compression method is not supported")
NotImplementedError: That compression method is not supported
I wonder if my compression method is wrong, and if there some workarounds to transform directory storage to zip storage or some other DB format, cause when the groups rise, the previous storage has so many nodes and not so convenient to transport. Thanks in advance.
Version and installation information
- Value of
zarr.__version__
: 2.8.1 - Value of
numcodecs.__version__
: 0.7.3 - Version of Python interpreter: 3.8.0
- Operating system (Linux/Windows/Mac): linux ubuntu 18.04
- How Zarr was installed: pip
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
@pmav99 Thanks for the summary. Finally, we decide to use the LMDB storage format, which supports both reads and writes in multiprocessing, by doing so, we did not have to run the additional cmd to zip the directory.
@joshmoore thank you. I confirm that your proposal does indeed work.
To make this more clear. If the zip archive contains the outer directory, then the
ZipStore
throws an exception. If the outer directory is omitted then it works just fine.So this fails:
while this works:
AFAIK there is no way to create a suitable zip archive using
zip
unless you do this trick with the change of the CWD. Nevertheless, according to this SO answer it is possible to avoidcd
-ing into the zarr archive by using7z
instead ofzip
: