Skip to main content

DaphneLib: Python API for DAPHNE

Project description

DaphneLib

DaphneLib is a Python wrapper for DAPHNE. Refer to the online documentation.

Compatibility

Make sure to use the same version numbers on minor granularity for DAPHNE and DaphneLib to ensure compatibility. E.g., using the DAPHNE v0.3 release for DaphneLib v0.3.0.

Prerequisites

Before starting with DaphneLib, it is necessary to obtain the DAPHNE system (binaries) separately. Follow the instructions at Quickstart for Users to obtain DAPHNE. Make sure that DAPHNE is running on it's own before using DaphneLib by executing the DAPHNE binary (path-to/daphne/bin/daphne --help). Depending on how you obtained DAPHNE, it could be that you need to extend the LD_LIBRARY_PATH environment variable:

export LD_LIBRARY_PATH=path-to/daphne/lib:path-to/daphne/thirdparty/installed/lib:$LD_LIBRARY_PATH

Installation

pip install daphne-lib

Setup

The environment variable DAPHNELIB_DIR_PATH must be set to the directory with libdaphnelib.so and libAllKernels.so in it.

export DAPHNELIB_DIR_PATH='path-to/daphne/lib'

Usage

More script examples on github and usage guide in the online docs.

from daphne.context.daphne_context import DaphneContext
import numpy as np

dc = DaphneContext()

# Create data in numpy.
a = np.arange(8.0).reshape((2, 4))

# Transfer data to DaphneLib (lazily evaluated).
X = dc.from_numpy(a)

print("How DAPHNE sees the data from numpy:")
X.print().compute()

# Add 100 to each value in X.
X = X + 100.0

# Compute in DAPHNE, transfer result back to Python.
print("\nResult of adding 100 to each value, back in Python:")
print(X.compute())

For Developers

Build

Build Python wheel package:

pip install build
./clean.sh && python3 -m build --wheel

Dev Setup

With editable install

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Publish

Use twine for publishing to PyPI. Install via pip install twine.

  1. Set version in pyproject.toml according to the DAPHNE version and semver
  2. Build according to Build section
  3. twine check dist/daphne_lib-<version>-py3-none-any.whl
    • checks the wheel file
  4. twine upload -u __token__ dist/daphne_lib-<version>-py3-none-any.whl
    • to publish to PyPI
    • twine prompts for your PyPI token

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

daphne_lib-0.3.0-py3-none-any.whl (53.3 kB view details)

Uploaded Python 3

File details

Details for the file daphne_lib-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: daphne_lib-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 53.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for daphne_lib-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7be6d9f53aab6936da798bd1ae44d4253dd5c032f53baa7256b3d30a91a894a
MD5 c78835832254b8df46dce6529c6e55f7
BLAKE2b-256 25f262a9e43d67469e14eed4427b3d11746c036d87df05af545e618e4fbee021

See more details on using hashes here.

Supported by

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