Skip to main content

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

PyPI version License: MIT CI Coverage Status CodeFactor Created with qCradle Renovate enabled

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numpy_flight-0.0.12.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

numpy_flight-0.0.12-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

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

Hashes for numpy_flight-0.0.12.tar.gz
Algorithm Hash digest
SHA256 2a62859024773f91b03c2468caa332d050c1981af8e9c69ee5e44bfd849cb3f4
MD5 c4e8f1d711c0ffd2205ea7bd39e30ceb
BLAKE2b-256 47e76621c56411186d4bad93eb4ec9ce4934fffa01cd71f2c0ba36a8bf011913

See more details on using hashes here.

Provenance

The following attestation bundles were made for numpy_flight-0.0.12.tar.gz:

Publisher: release.yml on tschm/numpy-flight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for numpy_flight-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 b7a8625163f44c3359e92b82e2fe7a5ce58766d1130341e6db556f9a80f93ba7
MD5 961de9788b7ed8be262f57b5996f0c20
BLAKE2b-256 c4802e67e8fbec7ff0f284457ab93c8146bfa6e3b6b2a17937378b79631fc5f4

See more details on using hashes here.

Provenance

The following attestation bundles were made for numpy_flight-0.0.12-py3-none-any.whl:

Publisher: release.yml on tschm/numpy-flight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page