simple-zarr-server


Namesimple-zarr-server JSON
Version 0.2.0 PyPI version JSON
download
home_page
SummaryA simple server for sharing zarr over HTTP.
upload_time2023-06-12 15:51:10
maintainer
docs_urlNone
author
requires_python>=3.8
licenseBSD-3
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # simple-zarr-server

[![License](https://img.shields.io/pypi/l/simple-zarr-server.svg)](https://github.com/manzt/simple-zarr-server/raw/main/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/simple-zarr-server.svg?color=green)](https://pypi.org/project/simple-zarr-server)
[![Python Version](https://img.shields.io/pypi/pyversions/simple-zarr-server.svg?color=green)](https://python.org)
[![tests](https://github.com/manzt/simple-zarr-server/workflows/tests/badge.svg)](https://github.com/manzt/simple-zarr-server/actions)

A minimal server for sharing zarr over HTTP.

----------------------------------

## Installation

You can install `simple-zarr-server` via [pip]:

    pip install simple-zarr-server

## Usage

#### CLI:

```bash
$ 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 any [`zarr.Array`](https://zarr.readthedocs.io/en/stable/api/core.html#zarr.core.Array), 
[`zarr.Group`](https://zarr.readthedocs.io/en/stable/api/hierarchy.html#zarr.hierarchy.Group) or `np.ndarray`. 

##### Server

```python
from simple_zarr_server import serve
import numpy as np
arr = np.random.rand(1024, 1024)
serve(arr) # creates an in-memory store if not zarr.Array or zarr.Group
```

##### Client

##### `zarr-python`

```python
import zarr
from fsspec import get_mapper
store = get_mapper("http://localhost:8000")
arr = zarr.open(store, mode='r')
# or 
import dask.array as da
arr = da.from_zarr("http://localhost:8000")
```

##### `zarr.js`

```javascript
import { openArray } from 'zarr';
arr = await openArray({ store: 'http://localhost:8000' });
```

#### Advanced: Serving a remote pyramidal tiff as Zarr

##### Server

```python
from napari_lazy_openslide import OpenSlideStore
from simple_zarr_server import serve
import zarr

store = OpenSlideStore('tumor_004.tif') # custom zarr store
grp = zarr.open(store)
serve(grp)
```

##### Client

```python
import napari
import dask.array as da
import zarr
from fsspec import get_mapper

store = 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"]) for d in datasets
]
with napari.gui_qt():
    napari.view_image(pyramid)
```

## Note

This package is experimental. It wraps *any* `zarr-python` store as a REST API, enabling remote access over HTTP.
It is similar to [`xpublish`](https://github.com/xarray-contrib/xpublish), but is more minimal and 
does not provide special endpoints that are specific to Xarray datasets. If your data are Xarray dataset, 
_please_ use `xpublish`! `simple-zarr-server` was designed with imaging data in mind, and when combined with a tool
like `ngrok` provides an interesting way to share local images with collaborators. 

Some non-standard zarr stores that might be of interest include:

- [`napari_lazy_openslide.OpenSlideStore`](https://github.com/manzt/napari-lazy-openslide) - read multiscale RGB TIFFs as zarr
- [`HDF5Zarr`](https://github.com/catalystneuro/HDF5Zarr) - read HDF5 with zarr

## Contributing

Contributions are very welcome. Tests can be run with `hatch run cov`.

## License

Distributed under the terms of the [BSD-3] license,
"simple-zarr-server" is free and open source software

## Issues

If you encounter any problems, please [file an issue] along with a detailed description.

[BSD-3]: http://opensource.org/licenses/BSD-3-Clause
[file an issue]: https://github.com/manzt/simple-zarr-server/issues
[hatch]: https://hatch.pypa.io/latest/
[pip]: https://pypi.org/project/pip/
[PyPI]: https://pypi.org/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "simple-zarr-server",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Trevor Manz <trevor.j.manz@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f3/19/abe4d8529a677bd49f0f0a0ba9885ac40e5371108e5e72b1e58493c551a0/simple_zarr_server-0.2.0.tar.gz",
    "platform": null,
    "description": "# simple-zarr-server\n\n[![License](https://img.shields.io/pypi/l/simple-zarr-server.svg)](https://github.com/manzt/simple-zarr-server/raw/main/LICENSE)\n[![PyPI](https://img.shields.io/pypi/v/simple-zarr-server.svg?color=green)](https://pypi.org/project/simple-zarr-server)\n[![Python Version](https://img.shields.io/pypi/pyversions/simple-zarr-server.svg?color=green)](https://python.org)\n[![tests](https://github.com/manzt/simple-zarr-server/workflows/tests/badge.svg)](https://github.com/manzt/simple-zarr-server/actions)\n\nA minimal server for sharing zarr over HTTP.\n\n----------------------------------\n\n## Installation\n\nYou can install `simple-zarr-server` via [pip]:\n\n    pip install simple-zarr-server\n\n## Usage\n\n#### CLI:\n\n```bash\n$ simple-zarr-server --help\n\n# Usage: simple-zarr-server [OPTIONS] PATH\n#\n# Options:\n#  --cors TEXT                     Origin to allow CORS. Use wildcard '*' to allow all.\n#  -w, --allow-write\n#  --host TEXT                     Bind socket to this host.  [default: 127.0.0.1]\n#\n#  --port INTEGER                  Bind socket to this port.  [default: 8000]\n#  --reload                        Enable auto-reload.\n#  --loop [auto|asyncio|uvloop]    Event loop implementation.  [default: auto]\n#  --http [auto|h11|httptools]     HTTP protocol implementation.  [default: auto]\n#\n#  --ws [auto|none|websockets|wsproto]\n#                                  WebSocket protocol implementation. [default: auto]\n#\n#  --use-colors / --no-use-colors  Enable/Disable colorized logging.\n#  --proxy-headers / --no-proxy-headers\n#                                  Enable/Disable X-Forwarded-Proto,\n#                                  X-Forwarded-For, X-Forwarded-Port to\n#                                  populate remote address info.\n#\n#  --forwarded-allow-ips TEXT      Comma seperated list of IPs to trust with\n#                                  proxy headers. Defaults to the\n#                                  $FORWARDED_ALLOW_IPS environment variable if\n#                                  available, or '127.0.0.1'.\n\n$ simple-zarr-server /dataset.zarr # or /dataset.n5, or /dataset.zip\n# INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\n```\n\n#### Python API:\n\nThe python API is more flexible than the CLI, and can serve any [`zarr.Array`](https://zarr.readthedocs.io/en/stable/api/core.html#zarr.core.Array), \n[`zarr.Group`](https://zarr.readthedocs.io/en/stable/api/hierarchy.html#zarr.hierarchy.Group) or `np.ndarray`. \n\n##### Server\n\n```python\nfrom simple_zarr_server import serve\nimport numpy as np\narr = np.random.rand(1024, 1024)\nserve(arr) # creates an in-memory store if not zarr.Array or zarr.Group\n```\n\n##### Client\n\n##### `zarr-python`\n\n```python\nimport zarr\nfrom fsspec import get_mapper\nstore = get_mapper(\"http://localhost:8000\")\narr = zarr.open(store, mode='r')\n# or \nimport dask.array as da\narr = da.from_zarr(\"http://localhost:8000\")\n```\n\n##### `zarr.js`\n\n```javascript\nimport { openArray } from 'zarr';\narr = await openArray({ store: 'http://localhost:8000' });\n```\n\n#### Advanced: Serving a remote pyramidal tiff as Zarr\n\n##### Server\n\n```python\nfrom napari_lazy_openslide import OpenSlideStore\nfrom simple_zarr_server import serve\nimport zarr\n\nstore = OpenSlideStore('tumor_004.tif') # custom zarr store\ngrp = zarr.open(store)\nserve(grp)\n```\n\n##### Client\n\n```python\nimport napari\nimport dask.array as da\nimport zarr\nfrom fsspec import get_mapper\n\nstore = get_mapper(\"http://localhost:8000\")\nz_grp = zarr.open(store)\ndatasets = z_grp.attrs[\"multiscales\"][0][\"datasets\"]\npyramid = [\n    da.from_zarr(store, component=d[\"path\"]) for d in datasets\n]\nwith napari.gui_qt():\n    napari.view_image(pyramid)\n```\n\n## Note\n\nThis package is experimental. It wraps *any* `zarr-python` store as a REST API, enabling remote access over HTTP.\nIt is similar to [`xpublish`](https://github.com/xarray-contrib/xpublish), but is more minimal and \ndoes not provide special endpoints that are specific to Xarray datasets. If your data are Xarray dataset, \n_please_ use `xpublish`! `simple-zarr-server` was designed with imaging data in mind, and when combined with a tool\nlike `ngrok` provides an interesting way to share local images with collaborators. \n\nSome non-standard zarr stores that might be of interest include:\n\n- [`napari_lazy_openslide.OpenSlideStore`](https://github.com/manzt/napari-lazy-openslide) - read multiscale RGB TIFFs as zarr\n- [`HDF5Zarr`](https://github.com/catalystneuro/HDF5Zarr) - read HDF5 with zarr\n\n## Contributing\n\nContributions are very welcome. Tests can be run with `hatch run cov`.\n\n## License\n\nDistributed under the terms of the [BSD-3] license,\n\"simple-zarr-server\" is free and open source software\n\n## Issues\n\nIf you encounter any problems, please [file an issue] along with a detailed description.\n\n[BSD-3]: http://opensource.org/licenses/BSD-3-Clause\n[file an issue]: https://github.com/manzt/simple-zarr-server/issues\n[hatch]: https://hatch.pypa.io/latest/\n[pip]: https://pypi.org/project/pip/\n[PyPI]: https://pypi.org/\n",
    "bugtrack_url": null,
    "license": "BSD-3",
    "summary": "A simple server for sharing zarr over HTTP.",
    "version": "0.2.0",
    "project_urls": {
        "Documentation": "https://github.com/manzt/simple-zarr-server#readme",
        "Issues": "https://github.com/manzt/simple-zarr-server/issues",
        "Source": "https://github.com/manzt/simple-zarr-server"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "77d37562a8a62e5fcd6e81d5f5fffd4f4abbbf858877b9390d64c99d2ed1f11b",
                "md5": "6f3c97f71db5f4015521477ba0b3f3f3",
                "sha256": "56c668936bae5ff090794127d28385c5c4726bacfa47d415d19b2eab76d01f0d"
            },
            "downloads": -1,
            "filename": "simple_zarr_server-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6f3c97f71db5f4015521477ba0b3f3f3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7485,
            "upload_time": "2023-06-12T15:51:08",
            "upload_time_iso_8601": "2023-06-12T15:51:08.956011Z",
            "url": "https://files.pythonhosted.org/packages/77/d3/7562a8a62e5fcd6e81d5f5fffd4f4abbbf858877b9390d64c99d2ed1f11b/simple_zarr_server-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f319abe4d8529a677bd49f0f0a0ba9885ac40e5371108e5e72b1e58493c551a0",
                "md5": "2af592a2532b7618c8461d74b5115b7d",
                "sha256": "eef475bb342bb606a0fddf6969f84b3d15a96b4555bf2d8fd709042f8338b93e"
            },
            "downloads": -1,
            "filename": "simple_zarr_server-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2af592a2532b7618c8461d74b5115b7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 8018,
            "upload_time": "2023-06-12T15:51:10",
            "upload_time_iso_8601": "2023-06-12T15:51:10.510164Z",
            "url": "https://files.pythonhosted.org/packages/f3/19/abe4d8529a677bd49f0f0a0ba9885ac40e5371108e5e72b1e58493c551a0/simple_zarr_server-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-12 15:51:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "manzt",
    "github_project": "simple-zarr-server#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "simple-zarr-server"
}
        
Elapsed time: 0.07928s