A little client/server for applications driven by numpy
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Numpy with Apache Arrow Flight
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
pip install numpy-flight
Usage
Basic Setup
We introduce the Baseclass 'Server':
>>> from tschm.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
>>> server = TestServer.start(host="127.0.0.1", port=5555)
While the server is running we can use a Python client for computations
>>> import numpy as np
>>> from tschm.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
server.shutdown()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numpy_flight-0.0.12.tar.gz.
File metadata
- Download URL: numpy_flight-0.0.12.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2a62859024773f91b03c2468caa332d050c1981af8e9c69ee5e44bfd849cb3f4
|
|
| MD5 |
c4e8f1d711c0ffd2205ea7bd39e30ceb
|
|
| BLAKE2b-256 |
47e76621c56411186d4bad93eb4ec9ce4934fffa01cd71f2c0ba36a8bf011913
|
Provenance
The following attestation bundles were made for numpy_flight-0.0.12.tar.gz:
Publisher:
release.yml on tschm/numpy-flight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numpy_flight-0.0.12.tar.gz -
Subject digest:
2a62859024773f91b03c2468caa332d050c1981af8e9c69ee5e44bfd849cb3f4 - Sigstore transparency entry: 234816448
- Sigstore integration time:
-
Permalink:
tschm/numpy-flight@4f14a01dff2525d22548f7f3061840f4ac0d5838 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tschm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4f14a01dff2525d22548f7f3061840f4ac0d5838 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file numpy_flight-0.0.12-py3-none-any.whl.
File metadata
- Download URL: numpy_flight-0.0.12-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7a8625163f44c3359e92b82e2fe7a5ce58766d1130341e6db556f9a80f93ba7
|
|
| MD5 |
961de9788b7ed8be262f57b5996f0c20
|
|
| BLAKE2b-256 |
c4802e67e8fbec7ff0f284457ab93c8146bfa6e3b6b2a17937378b79631fc5f4
|
Provenance
The following attestation bundles were made for numpy_flight-0.0.12-py3-none-any.whl:
Publisher:
release.yml on tschm/numpy-flight
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
numpy_flight-0.0.12-py3-none-any.whl -
Subject digest:
b7a8625163f44c3359e92b82e2fe7a5ce58766d1130341e6db556f9a80f93ba7 - Sigstore transparency entry: 234816449
- Sigstore integration time:
-
Permalink:
tschm/numpy-flight@4f14a01dff2525d22548f7f3061840f4ac0d5838 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tschm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4f14a01dff2525d22548f7f3061840f4ac0d5838 -
Trigger Event:
workflow_dispatch
-
Statement type: