Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork366
Move MemoryStore to a persistent store (e.g. LocalStore)#2985
-
Hi, once I put data inside a group on a MemoryStore, how do I copy the group over to a persistent store? I see there is zarr.copy() and zarr.copy_group(), but they are not implemented; reading the linked issue, it is also unclear whether they would be removed. Curious if the use-case above would be supported? Thanks. |
BetaWas this translation helpful?Give feedback.
All reactions
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",# ]# ///importzarrfromzarr.storageimportMemoryStorefromzarr.core.bufferimportdefault_buffer_prototypeimportasynciomem_a= {}mem_b= {}store_a=MemoryStore(mem_a)store_b=MemoryStore(mem_b)# create an array and fill it with valuesarray=zarr.create_array(store_a,name='foo',shape=(10,),dtype='float32')array[:]=1# define an async function that lis…
Replies: 1 comment 2 replies
-
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",# ]# ///importzarrfromzarr.storageimportMemoryStorefromzarr.core.bufferimportdefault_buffer_prototypeimportasynciomem_a= {}mem_b= {}store_a=MemoryStore(mem_a)store_b=MemoryStore(mem_b)# create an array and fill it with valuesarray=zarr.create_array(store_a,name='foo',shape=(10,),dtype='float32')array[:]=1# define an async function that lists the contents of the source store and copies each key, value pair to the dest storeasyncdefcopy_store(store_a,store_b):asyncforxinstore_a.list():awaitstore_b.set(x,awaitstore_a.get(x,prototype=default_buffer_prototype()))print(f'setting{x} ')returnNone# run that async functionasyncio.run(copy_store(store_a,store_b))# check that the two dictionaries are identical, i.e. everything from mem_a is in mem_bassertmem_a==mem_b |
BetaWas this translation helpful?Give feedback.
All reactions
-
Noting that we have an open issue for |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thanks@d-v-b for the example snippet -- it works well and also taught me a bit about |
BetaWas this translation helpful?Give feedback.