question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add a close method to the DirectoryStore and N5Store

See original GitHub issue

The ZipStore contains a close method that ensures that the file is flushed on the OS, and ready for the next line of code to use.

It wouild be nice to have noop methods for the DirectoryStore (and N5Store) to ensure that we don’t have to use the following code downstream

if hasattr(store, 'close'): 
    store.close()

Minimal, reproducible code sample, a copy-pastable example if possible

import zarr
dstore = zarr.DirectoryStore('test.dir')
dstore.close()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-a0f668fd8b50> in <module>
----> 1 dstore.close()

AttributeError: 'DirectoryStore' object has no attribute 'close'

import zarr
zstore = zarr.ZipStore('test.zip')
zstore.close()
# All good

Version and installation information

Please provide the following:

  • Value of zarr.__version__: 2.4.1.dev15+dirty

  • Value of numcodecs.__version__: 0.6.4

  • Version of Python interpreter: 3.8.5

  • Operating system (Linux/Windows/Mac) Linux

  • How Zarr was installed (e.g., “using pip into virtual environment”, or “using conda”): conda-forge

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hmaarrfkcommented, Oct 26, 2022

I think this issue can be closed. It seems that since #600 was closed, this is no longer an issue with at least the latest version of zarr.

In [1]: import zarr
   ...: dstore = zarr.DirectoryStore('test.dir')
   ...: dstore.close()

In [2]: zarr.__version__
'2.13.3'
0reactions
jakirkhamcommented, Oct 26, 2022

Thanks Mark! 🙏

Glad to hear things are working now 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Have a BaseStore class ? · Issue #600 · zarr-developers/zarr-python ...
Would provide a default methods, like close() method that is no-op, and would avoid the need ... Add a close method to the...
Read more >
Release notes — zarr 2.9.3 documentation
Clarify how to manually convert a DirectoryStore to a ZipStore. By pmav99; #763. ... Add recurse keyword to Group.array_keys and Group.arrays methods.
Read more >
zarr - Bountysource
I'm looking for a solution that uses existing image files in a more structured manner. I am exploring a couple options and would...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found