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

Add a close method to the DirectoryStore and N5Store #594

Closed
hmaarrfk opened this issue Aug 31, 2020 · 6 comments
Closed

Add a close method to the DirectoryStore and N5Store #594

hmaarrfk opened this issue Aug 31, 2020 · 6 comments
Labels
help wanted Issue could use help from someone with familiarity on the topic

Comments

@hmaarrfk
Copy link

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

@hmaarrfk
Copy link
Author

Usage example: pydata/xarray#4395

@joshmoore
Copy link
Member

cc: @Carreau

@Carreau
Copy link
Contributor

Carreau commented Sep 9, 2020

Opened #600 to track other advantages of having a base store that implements boilerplate methods like close().

@joshmoore joshmoore added the help wanted Issue could use help from someone with familiarity on the topic label Sep 22, 2021
@ManMaich0
Copy link

@joshmoore @MSanKeys963 I'm an Outreach candidate and would like to work on this.

@hmaarrfk
Copy link
Author

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'

@jakirkham
Copy link
Member

Thanks Mark! 🙏

Glad to hear things are working now 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Issue could use help from someone with familiarity on the topic
Projects
None yet
Development

No branches or pull requests

5 participants