numpy-flight


Namenumpy-flight JSON
Version 0.0.14 PyPI version JSON
download
home_pageNone
SummaryA little client/server for applications driven by numpy
upload_time2025-07-10 07:28:41
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [Numpy with Apache Arrow Flight](https://tschm.github.io/numpy-flight/book)

[![PyPI version](https://badge.fury.io/py/numpy-flight.svg)](https://badge.fury.io/py/numpy-flight)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.txt)
[![CI](https://github.com/tschm/numpy-flight/actions/workflows/ci.yml/badge.svg)](https://github.com/tschm/numpy-flight/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/tschm/numpy-flight/badge.svg?branch=main)](https://coveralls.io/github/tschm/numpy-flight?branch=main)
[![CodeFactor](https://www.codefactor.io/repository/github/tschm/numpy-flight/badge)](https://www.codefactor.io/repository/github/tschm/numpy-flight)
[![Created with qCradle](https://img.shields.io/badge/Created%20with-qCradle-blue?style=flat-square)](https://github.com/tschm/package)
[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://github.com/renovatebot/renovate)

## A Problem

We provide

- An abstract base class for an Apache flight server
- A client class to communicate with such servers

The client provides a simple interface for sending NumPy arrays,
performing computations, and retrieving results, all while handling
the serialization and deserialization automatically in the background
using Apache Arrow.

To create a server we expect the user to overload a function performing
the calcutation based on a dictionary of numpy arrays.

## Features

- Seamless conversion between NumPy arrays and Arrow Tables
- Simple interface for data transfer operations
- Type-safe operations with proper error handling

## Installation

You can install this client via

```bash
pip install numpy-flight
```

## Usage

### Basic Setup

We introduce the Baseclass 'Server':

```python
>>> from flight import Server

>>> class TestServer(Server):
...     def f(self, matrices):
...          self.logger.info(f"{matrices.keys()}")
...          # Simple implementation for testing - just return the input
...          return {key : 2*value for key, value in matrices.items()}
```

All complexity is hidden in the class 'Server' which is itself a child
of the pyarrrow's FlightServerBase class. It is enough to implement
the method 'f' which is expecting a dictionary of numpy arrays. It will
also return a dictionary of numpy arrays.

The server can be started locally with

```python
>>> server = TestServer.start(host="127.0.0.1", port=5555)
```

While the server is running we can use a Python client for computations

```python
>>> import numpy as np
>>> from flight import Client

>>> with Client(location="grpc://127.0.0.1:5555") as client:
...     output = client.compute(command="compute", data={"input": np.array([1,2,3])})

>>> print(output["input"])
[2 4 6]

```

Clients for other languages are thinkable.
We shut the server down with

```python
server.shutdown()
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "numpy-flight",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": "Thomas Schmelzer <thomas.schmelzer@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/dc/c2/1a1a2285bf2064d267e07be745681783bcdc3160a6cb3b519e8ade38168d/numpy_flight-0.0.14.tar.gz",
    "platform": null,
    "description": "# [Numpy with Apache Arrow Flight](https://tschm.github.io/numpy-flight/book)\n\n[![PyPI version](https://badge.fury.io/py/numpy-flight.svg)](https://badge.fury.io/py/numpy-flight)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.txt)\n[![CI](https://github.com/tschm/numpy-flight/actions/workflows/ci.yml/badge.svg)](https://github.com/tschm/numpy-flight/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/tschm/numpy-flight/badge.svg?branch=main)](https://coveralls.io/github/tschm/numpy-flight?branch=main)\n[![CodeFactor](https://www.codefactor.io/repository/github/tschm/numpy-flight/badge)](https://www.codefactor.io/repository/github/tschm/numpy-flight)\n[![Created with qCradle](https://img.shields.io/badge/Created%20with-qCradle-blue?style=flat-square)](https://github.com/tschm/package)\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg)](https://github.com/renovatebot/renovate)\n\n## A Problem\n\nWe provide\n\n- An abstract base class for an Apache flight server\n- A client class to communicate with such servers\n\nThe client provides a simple interface for sending NumPy arrays,\nperforming computations, and retrieving results, all while handling\nthe serialization and deserialization automatically in the background\nusing Apache Arrow.\n\nTo create a server we expect the user to overload a function performing\nthe calcutation based on a dictionary of numpy arrays.\n\n## Features\n\n- Seamless conversion between NumPy arrays and Arrow Tables\n- Simple interface for data transfer operations\n- Type-safe operations with proper error handling\n\n## Installation\n\nYou can install this client via\n\n```bash\npip install numpy-flight\n```\n\n## Usage\n\n### Basic Setup\n\nWe introduce the Baseclass 'Server':\n\n```python\n>>> from flight import Server\n\n>>> class TestServer(Server):\n...     def f(self, matrices):\n...          self.logger.info(f\"{matrices.keys()}\")\n...          # Simple implementation for testing - just return the input\n...          return {key : 2*value for key, value in matrices.items()}\n```\n\nAll complexity is hidden in the class 'Server' which is itself a child\nof the pyarrrow's FlightServerBase class. It is enough to implement\nthe method 'f' which is expecting a dictionary of numpy arrays. It will\nalso return a dictionary of numpy arrays.\n\nThe server can be started locally with\n\n```python\n>>> server = TestServer.start(host=\"127.0.0.1\", port=5555)\n```\n\nWhile the server is running we can use a Python client for computations\n\n```python\n>>> import numpy as np\n>>> from flight import Client\n\n>>> with Client(location=\"grpc://127.0.0.1:5555\") as client:\n...     output = client.compute(command=\"compute\", data={\"input\": np.array([1,2,3])})\n\n>>> print(output[\"input\"])\n[2 4 6]\n\n```\n\nClients for other languages are thinkable.\nWe shut the server down with\n\n```python\nserver.shutdown()\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A little client/server for applications driven by numpy",
    "version": "0.0.14",
    "project_urls": {
        "repository": "https://github.com/tschm/numpy-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "39315a843a53dcae8e28225d99a15e9b2bfd0830144135b4630eadb1c0ddf3e4",
                "md5": "0e29b6394c9dbb6caca8b51ee48728a8",
                "sha256": "7ac0235c3e9b61936792eeef60eeb219c33e1647e00e63243a352f6136ddb0d8"
            },
            "downloads": -1,
            "filename": "numpy_flight-0.0.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0e29b6394c9dbb6caca8b51ee48728a8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 8016,
            "upload_time": "2025-07-10T07:28:40",
            "upload_time_iso_8601": "2025-07-10T07:28:40.524115Z",
            "url": "https://files.pythonhosted.org/packages/39/31/5a843a53dcae8e28225d99a15e9b2bfd0830144135b4630eadb1c0ddf3e4/numpy_flight-0.0.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dcc21a1a2285bf2064d267e07be745681783bcdc3160a6cb3b519e8ade38168d",
                "md5": "aee095c0a08063642f3efcb6d1b6870e",
                "sha256": "3bddf3c7f211d7e6c0573b1480b36bfe857e909af3ff3ecff66ef59baacc26ae"
            },
            "downloads": -1,
            "filename": "numpy_flight-0.0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "aee095c0a08063642f3efcb6d1b6870e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7796,
            "upload_time": "2025-07-10T07:28:41",
            "upload_time_iso_8601": "2025-07-10T07:28:41.650155Z",
            "url": "https://files.pythonhosted.org/packages/dc/c2/1a1a2285bf2064d267e07be745681783bcdc3160a6cb3b519e8ade38168d/numpy_flight-0.0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-10 07:28:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tschm",
    "github_project": "numpy-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "numpy-flight"
}
        
Elapsed time: 0.40168s