I'm trying to understand how to use this for synchronous access.
With the following script
importnumpyasnpimportzarrfromzarr_sqliteimportSQLiteStoreimportmatplotlib.pyplotasplttry:
fromwxmplot.interactiveimportimshowexcept:
imshow=Nonedefcreate_zarr_example(store_name, constructor, win=1):
print(f"{store_name=}{constructor=}")
opts= {'read_only': False}
ifconstructor==zarr.storage.ZipStore:
opts['mode'] ='a'store=constructor(store_name, **opts)
print("constructor worked: ", store)
root=zarr.open_group(store=store)
group1=root.create_group('group1')
x=np.arange(2000)/20.0y=x*x*1.e-3+np.random.normal(size=2000, scale=0.5)
x.shape= (50,40)
y.shape= (50,40)
group1.create_array(data=x, name='xdat')
group1.create_array(data=y, name='ydat')
print(group1, list(group1.keys()))
store.close()
##read_store=constructor(store_name, **opts)
nroot=zarr.open_group(read_store)
ytest=nroot['group1/ydat'][()]
print(f"## DONE {store_name=}{constructor=}")
ifimshow:
imshow(ytest, win=win)
else:
plt.imshow(ytest)
plt.show()
##############storages= {'zarr1': zarr.storage.LocalStore,
'zarr1.zip': zarr.storage.ZipStore,
# 'zarr1.db': SQLiteStore,
}
win=0forsname, constructorinstorages.items():
win+=1create_zarr_example(sname, constructor, win=win)The LocalStore and ZipStore act almost identically -- a new store is created, data added, and can be retrieved. But trying this with SQLiteStore gives error messages that the database is not open.
I have not investigated thoroughly, but I suspect this is related to the async definition for open and maybe the use of asyncio for most of the interface. I think it is reasonable to except that synchronous access will be somewhat common. Any suggestions on where to loook for fixes to this? I'll admit to having only passing (are rarely "enjoyable") experience with asyncio - I completely get the desire for it here, but I also think that the maybe "obvious" use-case should also work.
Thanks
I'm trying to understand how to use this for synchronous access.
With the following script
The LocalStore and ZipStore act almost identically -- a new store is created, data added, and can be retrieved. But trying this with
SQLiteStoregives error messages that the database is not open.I have not investigated thoroughly, but I suspect this is related to the async definition for open and maybe the use of asyncio for most of the interface. I think it is reasonable to except that synchronous access will be somewhat common. Any suggestions on where to loook for fixes to this? I'll admit to having only passing (are rarely "enjoyable") experience with asyncio - I completely get the desire for it here, but I also think that the maybe "obvious" use-case should also work.
Thanks