caterva2


Namecaterva2 JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryNone
upload_time2024-03-25 13:30:08
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseGNU Affero General Public License version 3
keywords blosc2 pubsub
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Caterva2: On-demand access to Blosc2 data repositories

## What is it?

Caterva2 is a distributed system written in Python meant for sharing [Blosc2][] datasets (either native or converted on-the-fly from HDF5) among different hosts by using a [publish–subscribe][] messaging pattern.  Here, publishers categorize datasets into root groups that are announced to the broker and propagated to subscribers.  Also, every subscriber exposes a REST interface that allows clients to access the datasets.

![Figure: Caterva2 publish-subscribe](./doc/_static/Caterva2-PubSub.png)

[Blosc2]: https://www.blosc.org/pages/blosc-in-depth/
    "What Is Blosc? (Blosc blog)"

[publish–subscribe]: https://en.wikipedia.org/wiki/Publish–subscribe_pattern
    "Publish–subscribe pattern (Wikipedia)"

Caterva2 subscribers perform on demand data access with local caching (fit for re-publishing), which can be particularly useful for the efficient sharing of remote datasets locally, thus optimizing communication and storage resources within work groups.

![Figure: Caterva2 on-demand data access](./doc/_static/Caterva2-Data-On-Demand.png)

## Components of Caterva2

A Caterva2 deployment includes:

- One **broker** service to enable the communication between publishers and subscribers.
- Several **publishers**, each one providing subscribers with access to one root and the datasets that it contains. The root may be a native Caterva2 directory with Blosc2 and plain files, or an HDF5 file (support for other formats may be added).
- Several **subscribers**, each one tracking changes in multiple roots and datasets from publishers, and caching them locally for efficient reuse.
- Several **clients**, each one asking a subscriber to track roots and datasets, and provide access to their data and metadata.

Publishers and subscribers may be apart, in different networks with limited or expensive connectivity between them, while subscribers and clients will usually be close enough to have fast and cheap connectivity (e.g. a local network).

The Caterva2 package includes all the aforementioned components, although its main role is to provide a very simple and lightweight library to build your own Caterva2 clients.

## Use with caution

Currently, this project is in early alpha stage, and it is not meant for production use yet.  In case you are interested in Caterva2, please contact us at <contact@blosc.org>.

## Installation

You may install Caterva2 in several ways:.

- Pre-built wheel from PyPI:

  ```sh
  python -m pip install caterva2
  ```

- Wheel built from source code:

  ```sh
  git clone https://github.com/Blosc/Caterva2
  cd Caterva2
  python -m build
  python -m pip install dist/caterva2-*.whl
  ```

- Developer setup:

  ```sh
  git clone https://github.com/Blosc/Caterva2
  cd Caterva2
  python -m pip install -e .
  ```

In any case, if you intend to run Caterva2 services, client programs, or the test suite, you need to enable the proper extra features by appending `[feature1,feature2...]` to the last argument of `pip` commands above.  The following extras are supported:

- `services` for running Caterva2 services (broker, publisher, subscriber)
- `clients` to use Caterva2 client programs (command-line or terminal)
- `hdf5` to enable serving HDF5 files as Caterva2 roots at the publisher
- `blosc2-plugins` to enable extra Blosc2 features like Btune or JPEG 2000 support
- `plugins` to enable Web client features like the tomography display
- `tools` for additional utilities like `cat2import` and `cat2export` (see below)
- `tests` if you want to run the Caterva2 test suite

### Testing

After installing with the `[tests]` extra, you can quickly check that the package is sane by running the test suite (that comes with the package):

```sh
python -m caterva2.tests -v
```

You may also run tests from source code:

```sh
cd Caterva2
python -m pytest -v
```

Tests will use a copy of Caterva2's `root-example` directory.  After they finish, state files will be left under the `_caterva2_tests` directory for inspection (it will be re-created when tests are run again).

In case you want to run the tests with your own running daemons, you can do:

```shell
env CATERVA2_USE_EXTERNAL=1 python -m caterva2.tests -v
```

Neither `root-example` nor `_caterva2_tests` will be used in this case.

## Quick start

(Find more detailed step-by-step [tutorials](Tutorials) in Caterva2 documentation.)

For the purpose of this quick start, let's use the datasets within the `root-example` folder:

```sh
cd Caterva2
ls -F root-example/
```

```
README.md  dir1/  dir2/  ds-1d-b.b2nd  ds-1d.b2nd  ds-hello.b2frame
```

First, create a virtual environment and install Caterva2 with the `[services,clients]` extras (see above).  Then fire up the broker, start publishing a root named `foo` with `root-example` datasets, and create a subscriber:

```sh
cat2bro &  # broker
cat2pub foo root-example &  # publisher
cat2sub &  # subscriber
```

(To stop them later on, bring each one to the foreground with `fg` and press Ctrl+C.)

### HDF5 roots

If you want to try and publish your own HDF5 file as a root, you need to include the `hdf5` extra in your Caterva2 installation.  Then you may just run:

```sh
cat2pub foo /path/to/your-file.h5 &
```

You can also get an example HDF5 file with some datasets by running:

```sh
python -m caterva2.services.hdf5root root-example.h5
```

You may want to test compatibility with [silx' HDF5 examples](https://www.silx.org/pub/h5web/) (`epics.h5` and `grove.h5` are quite illustrative).

### The command line client

Now that the services are running, we can use the `cat2cli` client to talk
to the subscriber. In another shell, let's list all the available roots in the system:

```sh
cat2cli roots
```

```
foo
```

We only have the `foo` root that we started publishing. If other publishers were running,
we would see them listed here too.

Let's ask our local subscriber to subscribe to the `foo` root:

```sh
cat2cli subscribe foo  # -> Ok
```

Now, one can list the datasets in the `foo` root:

```sh
cat2cli list foo
```

```
foo/README.md
...
foo/ds-hello.b2frame
...
foo/dir2/ds-4d.b2nd
```

Let's ask the subscriber for more info about the `foo/dir2/ds-4d.b2nd` dataset:

```sh
cat2cli info foo/dir2/ds-4d.b2nd
```

```
{
    'shape': [2, 3, 4, 5],
    'chunks': [1, 2, 3, 4],
    'blocks': [1, 2, 2, 2],
    'dtype': 'complex128',
    'schunk': {
        # ...
    }
}
```

Let's print data from a specified dataset:

```sh
cat2cli show foo/ds-hello.b2frame[:12]  # -> Hello world!
```

It allows printing slices instead of the whole dataset too:

```sh
cat2cli show foo/dir2/ds-4d.b2nd[1,2,3]
```

```
[115.+115.j 116.+116.j 117.+117.j 118.+118.j 119.+119.j]
```

Finally, we can tell the subscriber to download the dataset:

```sh
cat2cli download foo/dir2/ds-4d.b2nd
```

```
Dataset saved to foo/dir2/ds-4d.b2nd
```

### Using a configuration file

All the services mentioned above (and clients, to some limited extent) may get their configuration from a `caterva2.toml` file at the current directory (or an alternative file given with the `--conf` option).  Caterva2 source code includes a fully documented `caterva2.sample.toml` file (see also [caterva2.toml](caterva2.toml) in Caterva2 tutorials).

## Tools

Although Caterva2 allows publishing an HDF5 file directly as a root (with datasets converted to Blosc2 arrays on-the-fly), it also includes a simple script that can import its full hierarchy to a new Caterva2 root directory.  You may use it like:

```sh
cat2import existing-hdf5-file.h5 new-caterva2-root
```

The tool is still pretty limited in its supported input and generated output, please invoke it with `--help` for more information (see also [cat2import](cat2import) in Caterva2 utilities documentation).

Caterva2 also ships a complementary tool to export a Caterva root directory to an HDF5 file; see [cat2export](cat2export) in Caterva2 utilities documentation.  You may use it like:
```sh
cat2export existing-caterva2-root new-hdf5-file.h5
```

That's all folks!

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "caterva2",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "blosc2, pubsub",
    "author": null,
    "author_email": "Blosc Development Team <contact@blosc.org>",
    "download_url": "https://files.pythonhosted.org/packages/f2/7b/85d6a4340162a40b40f7f39f962343aeb0a5f2eb60eab35e35e3a3f3edb6/caterva2-0.2.0.tar.gz",
    "platform": null,
    "description": "# Caterva2: On-demand access to Blosc2 data repositories\n\n## What is it?\n\nCaterva2 is a distributed system written in Python meant for sharing [Blosc2][] datasets (either native or converted on-the-fly from HDF5) among different hosts by using a [publish\u2013subscribe][] messaging pattern.  Here, publishers categorize datasets into root groups that are announced to the broker and propagated to subscribers.  Also, every subscriber exposes a REST interface that allows clients to access the datasets.\n\n![Figure: Caterva2 publish-subscribe](./doc/_static/Caterva2-PubSub.png)\n\n[Blosc2]: https://www.blosc.org/pages/blosc-in-depth/\n    \"What Is Blosc? (Blosc blog)\"\n\n[publish\u2013subscribe]: https://en.wikipedia.org/wiki/Publish\u2013subscribe_pattern\n    \"Publish\u2013subscribe pattern (Wikipedia)\"\n\nCaterva2 subscribers perform on demand data access with local caching (fit for re-publishing), which can be particularly useful for the efficient sharing of remote datasets locally, thus optimizing communication and storage resources within work groups.\n\n![Figure: Caterva2 on-demand data access](./doc/_static/Caterva2-Data-On-Demand.png)\n\n## Components of Caterva2\n\nA Caterva2 deployment includes:\n\n- One **broker** service to enable the communication between publishers and subscribers.\n- Several **publishers**, each one providing subscribers with access to one root and the datasets that it contains. The root may be a native Caterva2 directory with Blosc2 and plain files, or an HDF5 file (support for other formats may be added).\n- Several **subscribers**, each one tracking changes in multiple roots and datasets from publishers, and caching them locally for efficient reuse.\n- Several **clients**, each one asking a subscriber to track roots and datasets, and provide access to their data and metadata.\n\nPublishers and subscribers may be apart, in different networks with limited or expensive connectivity between them, while subscribers and clients will usually be close enough to have fast and cheap connectivity (e.g. a local network).\n\nThe Caterva2 package includes all the aforementioned components, although its main role is to provide a very simple and lightweight library to build your own Caterva2 clients.\n\n## Use with caution\n\nCurrently, this project is in early alpha stage, and it is not meant for production use yet.  In case you are interested in Caterva2, please contact us at <contact@blosc.org>.\n\n## Installation\n\nYou may install Caterva2 in several ways:.\n\n- Pre-built wheel from PyPI:\n\n  ```sh\n  python -m pip install caterva2\n  ```\n\n- Wheel built from source code:\n\n  ```sh\n  git clone https://github.com/Blosc/Caterva2\n  cd Caterva2\n  python -m build\n  python -m pip install dist/caterva2-*.whl\n  ```\n\n- Developer setup:\n\n  ```sh\n  git clone https://github.com/Blosc/Caterva2\n  cd Caterva2\n  python -m pip install -e .\n  ```\n\nIn any case, if you intend to run Caterva2 services, client programs, or the test suite, you need to enable the proper extra features by appending `[feature1,feature2...]` to the last argument of `pip` commands above.  The following extras are supported:\n\n- `services` for running Caterva2 services (broker, publisher, subscriber)\n- `clients` to use Caterva2 client programs (command-line or terminal)\n- `hdf5` to enable serving HDF5 files as Caterva2 roots at the publisher\n- `blosc2-plugins` to enable extra Blosc2 features like Btune or JPEG 2000 support\n- `plugins` to enable Web client features like the tomography display\n- `tools` for additional utilities like `cat2import` and `cat2export` (see below)\n- `tests` if you want to run the Caterva2 test suite\n\n### Testing\n\nAfter installing with the `[tests]` extra, you can quickly check that the package is sane by running the test suite (that comes with the package):\n\n```sh\npython -m caterva2.tests -v\n```\n\nYou may also run tests from source code:\n\n```sh\ncd Caterva2\npython -m pytest -v\n```\n\nTests will use a copy of Caterva2's `root-example` directory.  After they finish, state files will be left under the `_caterva2_tests` directory for inspection (it will be re-created when tests are run again).\n\nIn case you want to run the tests with your own running daemons, you can do:\n\n```shell\nenv CATERVA2_USE_EXTERNAL=1 python -m caterva2.tests -v\n```\n\nNeither `root-example` nor `_caterva2_tests` will be used in this case.\n\n## Quick start\n\n(Find more detailed step-by-step [tutorials](Tutorials) in Caterva2 documentation.)\n\nFor the purpose of this quick start, let's use the datasets within the `root-example` folder:\n\n```sh\ncd Caterva2\nls -F root-example/\n```\n\n```\nREADME.md  dir1/  dir2/  ds-1d-b.b2nd  ds-1d.b2nd  ds-hello.b2frame\n```\n\nFirst, create a virtual environment and install Caterva2 with the `[services,clients]` extras (see above).  Then fire up the broker, start publishing a root named `foo` with `root-example` datasets, and create a subscriber:\n\n```sh\ncat2bro &  # broker\ncat2pub foo root-example &  # publisher\ncat2sub &  # subscriber\n```\n\n(To stop them later on, bring each one to the foreground with `fg` and press Ctrl+C.)\n\n### HDF5 roots\n\nIf you want to try and publish your own HDF5 file as a root, you need to include the `hdf5` extra in your Caterva2 installation.  Then you may just run:\n\n```sh\ncat2pub foo /path/to/your-file.h5 &\n```\n\nYou can also get an example HDF5 file with some datasets by running:\n\n```sh\npython -m caterva2.services.hdf5root root-example.h5\n```\n\nYou may want to test compatibility with [silx' HDF5 examples](https://www.silx.org/pub/h5web/) (`epics.h5` and `grove.h5` are quite illustrative).\n\n### The command line client\n\nNow that the services are running, we can use the `cat2cli` client to talk\nto the subscriber. In another shell, let's list all the available roots in the system:\n\n```sh\ncat2cli roots\n```\n\n```\nfoo\n```\n\nWe only have the `foo` root that we started publishing. If other publishers were running,\nwe would see them listed here too.\n\nLet's ask our local subscriber to subscribe to the `foo` root:\n\n```sh\ncat2cli subscribe foo  # -> Ok\n```\n\nNow, one can list the datasets in the `foo` root:\n\n```sh\ncat2cli list foo\n```\n\n```\nfoo/README.md\n...\nfoo/ds-hello.b2frame\n...\nfoo/dir2/ds-4d.b2nd\n```\n\nLet's ask the subscriber for more info about the `foo/dir2/ds-4d.b2nd` dataset:\n\n```sh\ncat2cli info foo/dir2/ds-4d.b2nd\n```\n\n```\n{\n    'shape': [2, 3, 4, 5],\n    'chunks': [1, 2, 3, 4],\n    'blocks': [1, 2, 2, 2],\n    'dtype': 'complex128',\n    'schunk': {\n        # ...\n    }\n}\n```\n\nLet's print data from a specified dataset:\n\n```sh\ncat2cli show foo/ds-hello.b2frame[:12]  # -> Hello world!\n```\n\nIt allows printing slices instead of the whole dataset too:\n\n```sh\ncat2cli show foo/dir2/ds-4d.b2nd[1,2,3]\n```\n\n```\n[115.+115.j 116.+116.j 117.+117.j 118.+118.j 119.+119.j]\n```\n\nFinally, we can tell the subscriber to download the dataset:\n\n```sh\ncat2cli download foo/dir2/ds-4d.b2nd\n```\n\n```\nDataset saved to foo/dir2/ds-4d.b2nd\n```\n\n### Using a configuration file\n\nAll the services mentioned above (and clients, to some limited extent) may get their configuration from a `caterva2.toml` file at the current directory (or an alternative file given with the `--conf` option).  Caterva2 source code includes a fully documented `caterva2.sample.toml` file (see also [caterva2.toml](caterva2.toml) in Caterva2 tutorials).\n\n## Tools\n\nAlthough Caterva2 allows publishing an HDF5 file directly as a root (with datasets converted to Blosc2 arrays on-the-fly), it also includes a simple script that can import its full hierarchy to a new Caterva2 root directory.  You may use it like:\n\n```sh\ncat2import existing-hdf5-file.h5 new-caterva2-root\n```\n\nThe tool is still pretty limited in its supported input and generated output, please invoke it with `--help` for more information (see also [cat2import](cat2import) in Caterva2 utilities documentation).\n\nCaterva2 also ships a complementary tool to export a Caterva root directory to an HDF5 file; see [cat2export](cat2export) in Caterva2 utilities documentation.  You may use it like:\n```sh\ncat2export existing-caterva2-root new-hdf5-file.h5\n```\n\nThat's all folks!\n",
    "bugtrack_url": null,
    "license": "GNU Affero General Public License version 3",
    "summary": null,
    "version": "0.2.0",
    "project_urls": {
        "Home": "https://github.com/Blosc/Caterva2"
    },
    "split_keywords": [
        "blosc2",
        " pubsub"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09c7f60b9fbf85c676826f633d8c7b8d47e75d14b4dcb1c84b9a5c4f0dd2e9c7",
                "md5": "7c8dcfd51bc26cf7ac040e456d0f1f66",
                "sha256": "c90b44f3a1716ea2f3748adefe07c94193769392f761a324aa67cf86c54c2570"
            },
            "downloads": -1,
            "filename": "caterva2-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7c8dcfd51bc26cf7ac040e456d0f1f66",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 99793,
            "upload_time": "2024-03-25T13:30:06",
            "upload_time_iso_8601": "2024-03-25T13:30:06.307807Z",
            "url": "https://files.pythonhosted.org/packages/09/c7/f60b9fbf85c676826f633d8c7b8d47e75d14b4dcb1c84b9a5c4f0dd2e9c7/caterva2-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f27b85d6a4340162a40b40f7f39f962343aeb0a5f2eb60eab35e35e3a3f3edb6",
                "md5": "c3f4d0767024d4bcc74ff140cf33c1ee",
                "sha256": "699c3ca5297b62f07e870d311b0744fdc79e3cd39c2f7b8820984f241ec1244e"
            },
            "downloads": -1,
            "filename": "caterva2-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "c3f4d0767024d4bcc74ff140cf33c1ee",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 1832207,
            "upload_time": "2024-03-25T13:30:08",
            "upload_time_iso_8601": "2024-03-25T13:30:08.024041Z",
            "url": "https://files.pythonhosted.org/packages/f2/7b/85d6a4340162a40b40f7f39f962343aeb0a5f2eb60eab35e35e3a3f3edb6/caterva2-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 13:30:08",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Blosc",
    "github_project": "Caterva2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "caterva2"
}
        
Elapsed time: 0.45483s