Package: simple-zarr-server
simple-zarr-serverA minimal server for sharing zarr over HTTP.InstallationYou can installsimple-zarr-serverviapip:pip install simple-zarr-serverUsageCLI:$simple-zarr-server--help# Usage: simple-zarr-server [OPTIONS] PATH## Options:#  --cors TEXT                     Origin to allow CORS. Use wildcard '*' to allow all.#  -w, --allow-write#  --host TEXT                     Bind socket to this host.  [default: 127.0.0.1]##  --port INTEGER                  Bind socket to this port.  [default: 8000]#  --reload                        Enable auto-reload.#  --loop [auto|asyncio|uvloop]    Event loop implementation.  [default: auto]#  --http [auto|h11|httptools]     HTTP protocol implementation.  [default: auto]##  --ws [auto|none|websockets|wsproto]#                                  WebSocket protocol implementation. [default: auto]##  --use-colors / --no-use-colors  Enable/Disable colorized logging.#  --proxy-headers / --no-proxy-headers#                                  Enable/Disable X-Forwarded-Proto,#                                  X-Forwarded-For, X-Forwarded-Port to#                                  populate remote address info.##  --forwarded-allow-ips TEXT      Comma seperated list of IPs to trust with#                                  proxy headers. Defaults to the#                                  $FORWARDED_ALLOW_IPS environment variable if#                                  available, or '127.0.0.1'.$simple-zarr-server/dataset.zarr# or /dataset.n5, or /dataset.zip# INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)Python API:The python API is more flexible than the CLI, and can serve anyzarr.Array,zarr.Groupornp.ndarray.Serverfromsimple_zarr_serverimportserveimportnumpyasnparr=np.random.rand(1024,1024)serve(arr)# creates an in-memory store if not zarr.Array or zarr.GroupClientzarr-pythonimportzarrfromfsspecimportget_mapperstore=get_mapper("http://localhost:8000")arr=zarr.open(store,mode='r')# orimportdask.arrayasdaarr=da.from_zarr("http://localhost:8000")zarr.jsimport{openArray}from'zarr';arr=awaitopenArray({store:'http://localhost:8000'});Advanced: Serving a remote pyramidal tiff as ZarrServerfromnapari_lazy_openslideimportOpenSlideStorefromsimple_zarr_serverimportserveimportzarrstore=OpenSlideStore('tumor_004.tif')# custom zarr storegrp=zarr.open(store)serve(grp)Clientimportnapariimportdask.arrayasdaimportzarrfromfsspecimportget_mapperstore=get_mapper("http://localhost:8000")z_grp=zarr.open(store)datasets=z_grp.attrs["multiscales"][0]["datasets"]pyramid=[da.from_zarr(store,component=d["path"])fordindatasets]withnapari.gui_qt():napari.view_image(pyramid)NoteThis package is experimental. It wrapsanyzarr-pythonstore as a REST API, enabling remote access over HTTP.
It is similar toxpublish, but is more minimal and
does not provide special endpoints that are specific to Xarray datasets. If your data are Xarray dataset,pleaseusexpublish!simple-zarr-serverwas designed with imaging data in mind, and when combined with a tool
likengrokprovides an interesting way to share local images with collaborators.Some non-standard zarr stores that might be of interest include:napari_lazy_openslide.OpenSlideStore- read multiscale RGB TIFFs as zarrHDF5Zarr- read HDF5 with zarrContributingContributions are very welcome. Tests can be run withhatch run cov.LicenseDistributed under the terms of theBSD-3license,
"simple-zarr-server" is free and open source softwareIssuesIf you encounter any problems, pleasefile an issuealong with a detailed description.