Skip to main content

Python bindings for ALP GraphBLAS (minimal package layout)

Project description

pyalp (packaged)

This directory contains the Python package layout for the pyalp bindings that expose parts of the ALP GraphBLAS project via pybind11.

Quick start

Create and activate a virtual environment, then install the package (example using PyPI (recommended):

python -m venv venv
source venv/bin/activate
pip install alp-graphblas

If you want to try a pre-release from TestPyPI instead, use the TestPyPI index but install the same package name alp-graphblas (pip will pull the package and its dependencies from the given index):

python -m venv venv
source venv/bin/activate
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple alp-graphblas

Basic usage

pyalp (packaged)

This directory contains the Python package layout for the pyalp bindings that expose parts of the ALP GraphBLAS project via pybind11.

Quick start

Create and activate a virtual environment, then install the published package alp-graphblas from PyPI or TestPyPI as shown above. Note: the import name inside Python remains pyalp (the package provides the pyalp module), so your code still does import pyalp after installation.

Basic usage

The package exposes a small set of helpers and one or more compiled backend modules. Use these helpers to list and select available backends and to read runtime build metadata:

import pyalp
print('pyalp build metadata:', pyalp.get_build_metadata())
print('available backends:', pyalp.list_backends())

# Import a specific backend module (returns the compiled module)
backend = pyalp.get_backend('pyalp_ref')  # or 'pyalp_omp', 'pyalp_nonblocking'
print('backend module:', backend)

Backends and import caveat

Wheels may include multiple compiled backend modules (for example pyalp_ref, pyalp_omp, pyalp_nonblocking). Historically, importing multiple different compiled backends in the same Python process could raise pybind11 registration errors (types duplicated). The bindings now use py::module_local() for core wrapper types, which reduces collisions, but if you encounter issues importing more than one backend in-process, prefer testing each backend in a separate process (the supplied test runner does this).

Runtime metadata

The package provides a metadata module generated at build time by CMake. Use pyalp.get_build_metadata() to access keys such as:

  • version — pyalp package version
  • build_type — CMake build type used (e.g., Release)
  • alp_version — ALP repository version or tag used to build
  • alp_git_commit / alp_git_branch — Git information captured by CI
  • license — detected repository license (e.g. Apache-2.0)

pyalp.get_algorithm_metadata() contains algorithm/backends info and a readme key with packaged README contents.

Minimal example — conjugate gradient (small test)

Save the following as test_cg.py and run python test_cg.py after installing pyalp and numpy. The example shows selecting a backend explicitly via pyalp.get_backend() and then using the backend's Matrix, Vector, and conjugate_gradient API.

#!/usr/bin/env python3
"""
Test script for the pyalp backend (example uses the OpenMP backend name
`pyalp_omp`, but you can use `pyalp_ref` or another available backend).

Usage:
		python test_cg.py

Dependencies:
		- numpy
		- pyalp (installed and providing a backend such as pyalp_omp)
"""

import numpy as np
import pyalp

# Choose the backend module (change name if you want a different backend)
pyalp = pyalp.get_backend('pyalp_omp')  # or 'pyalp_ref', 'pyalp_nonblocking'

# Generate a small sparse linear system using numpy arrays
N, M = 5, 5
idata = np.array([0, 1, 2, 3, 3, 4, 2, 3, 3, 4, 1, 4, 1, 4, 4], dtype=np.int32)
jdata = np.array([0, 1, 2, 3, 2, 2, 1, 4, 1, 1, 0, 3, 0, 3, 4], dtype=np.int32)
vdata = np.array([1, 1, 1, 1, 0.5, 2, 1, 4, 4.4, 1, 0, 3.5, 0, 3, 1], dtype=np.float64)
b = np.array([1.0, 1.0, 1.0, 1.0, 1.0], dtype=np.float64)
x = np.array([1.0, 1.0, 0.0, 0.3, -1.0], dtype=np.float64)
r = np.zeros(5, dtype=np.float64)
u = np.zeros(5, dtype=np.float64)
tmp = np.zeros(5, dtype=np.float64)

# Create the pyalp Matrix and Vector objects
alpmatrixA = pyalp.Matrix(5, 5, idata, jdata, vdata)
alpvectorx = pyalp.Vector(5, x)
alpvectorb = pyalp.Vector(5, b)
alpvectorr = pyalp.Vector(5, r)
alpvectoru = pyalp.Vector(5, u)
alpvectortmp = pyalp.Vector(5, tmp)

maxiterations = 2000
verbose = 1

# Solve the linear system using the conjugate gradient method in the backend
iterations, residual = pyalp.conjugate_gradient(
		alpmatrixA,
		alpvectorx,
		alpvectorb,
		alpvectorr,
		alpvectoru,
		alpvectortmp,
		maxiterations,
		verbose,
)
print('iterations =', iterations)
print('residual =', residual)

# Convert the result vector to a numpy array and print it
x_result = alpvectorx.to_numpy()
print('x_result =', x_result)

# Check if the result is close to the expected solution
assert np.allclose(x_result, np.array([1.0, 1.0, 0.0, 0.13598679, -0.88396565])), 'solution mismatch'

Packaging notes (for maintainers)

  • The CI uses a top-level CMake configure/build to produce the native shared object and a CMake-configured _metadata.py. The packaging setup.py then copies the built .so and _metadata.py into the wheel.
  • The CI passes Git/version information into CMake so the generated metadata is populated even in detached/CI environments.

If you modify the metadata template, update pyalp/src/pyalp/_metadata.py.in.

License

See the repository LICENSE at the project root; the packaging pipeline attempts to detect and embed the license string in runtime metadata.

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 Distributions

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

alp_graphblas-0.8.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

alp_graphblas-0.8.31-cp312-cp312-macosx_15_0_arm64.whl (490.9 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

alp_graphblas-0.8.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

alp_graphblas-0.8.31-cp311-cp311-macosx_15_0_arm64.whl (490.9 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

alp_graphblas-0.8.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

alp_graphblas-0.8.31-cp310-cp310-macosx_15_0_arm64.whl (490.9 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

alp_graphblas-0.8.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

alp_graphblas-0.8.31-cp39-cp39-macosx_15_0_arm64.whl (490.9 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

Details for the file alp_graphblas-0.8.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 57bfcbb81b6ef8e775c03cfee5ccc230f37593f7c18dd6bce35561473e880b13
MD5 067262df793c108e2d95e80f341651f9
BLAKE2b-256 628016ea22b5dc87e5bd868b6685a531178f8ed8adb5cb21c374b28c8a9d4383

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 950f12a7ea16825aab9313b6bce98660af43f269d20e20f4ecf8fc741ef36466
MD5 70ed37a6476edc8c0e28a8f0d44377b2
BLAKE2b-256 21cf90b93a012b64210477c9c726abeea43fff5d792a793f251c717b58b8ce47

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 018ef0bfaa77d2fb86380c8ab5feab1adfbd3a0acf30c4b7cf49a43344cc62c1
MD5 03783f929e57032784980b343cc63ebc
BLAKE2b-256 650a65abcc82b85f5787c743d6d58c6614ae70c976fcfcd130a29c4ed2006be5

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 434c8bb2267e345a30ea46c2286cb8e1c9afd85af513f5f109b044d477656eeb
MD5 2b23502686ec068ff284012a5691b9ee
BLAKE2b-256 8018d0a47b3330a5e72b719aebca23e0f2fb5648bf54c7a5de0f47e758f4c513

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 47ca05970c1541d92db36b3db2ce64330011e1063baee4a2805ea289c0d8538c
MD5 a73a7519f52feb83d8934c60f8b1b5b1
BLAKE2b-256 44da852d49226f0669aa4651d954e15188e9218231670b04968a45f7c2d8cb0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4f8009f75f7eb940e15d89649d43127c1caaead0bb95792650aae16876545736
MD5 bee3659dfa1881ff3e468a779d062ca7
BLAKE2b-256 1d13c0d3922be4ddb8818c901985be43392a0711d1aed3dc69ede34fce12f32e

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 642c0b5c1c916ec4e1129d839daf67df53fe6c4dc7764f6a6fe1e8b7a3e851d5
MD5 7bc7e4b56c9e55ba99b26cdbeaeb5c94
BLAKE2b-256 fb29831ef59a443a3988c6c338c9d3bd19078fcd554c0e9b6e8fa2924a68749c

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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

File details

Details for the file alp_graphblas-0.8.31-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for alp_graphblas-0.8.31-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 16fe4fb513d0de75c3e09df5bcce989c073f244a8bb5a3445ada45b11bbc86e3
MD5 15460d2425d8e2f74dea2316b9aa9013
BLAKE2b-256 eb0b61f9414442fb6c6c9d537d24e4fa6b0096bd7587aa1f0d84eb74f3da9e2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for alp_graphblas-0.8.31-cp39-cp39-macosx_15_0_arm64.whl:

Publisher: promote-to-pypi.yml on Algebraic-Programming/ALP

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