Skip to content

Move MemoryStore to a persistent store (e.g. LocalStore) #2985

Answered by d-v-b
kevinli1993 asked this question in Q&A
Discussion options

You must be logged in to vote

hi @kevinli1993 this is a great question and we should absolutely support this with a stand-alone convenience function. Until we get around to writing such a convenience function ,here's a script that illustrates how you can do this today:

# /// script
# requires-python = ">=3.11"
# dependencies = [
#     "zarr>3",
# ]
# ///

import zarr
from zarr.storage import MemoryStore
from zarr.core.buffer import default_buffer_prototype
import asyncio

mem_a = {}
mem_b = {}

store_a = MemoryStore(mem_a)
store_b = MemoryStore(mem_b)

# create an array and fill it with values
array = zarr.create_array(store_a, name='foo', shape=(10,), dtype='float32')
array[:] = 1

# define an async function that lis…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@jhamman
Comment options

@kevinli1993
Comment options

Answer selected by kevinli1993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants