Skip to content

Commit 13ce446

Browse files
author
Denis Jelovina
committed
Update wait_for_testpypi_release.sh to improve response handling and retry logic; bump version to 0.8.17 in pyproject.toml
1 parent e1cc599 commit 13ce446

File tree

3 files changed

+137
-13
lines changed

3 files changed

+137
-13
lines changed

.github/scripts/wait_for_testpypi_release.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,25 @@ while [ $attempt -le $max_attempts ]; do
2222
# fetch JSON; tolerate transient network errors by not exiting on curl non-zero
2323
body=$(curl -sS --max-time 10 "${url}" || true)
2424
if [ -n "$body" ]; then
25-
found=$(printf "%s" "$body" | python3 - <<PY
26-
import sys, json
27-
try:
28-
j = json.load(sys.stdin)
25+
found=$(printf "%s" "$body" | python3 -c "import sys, json; j = json.load(sys.stdin); releases = j.get('releases', {}); print('1' if '${ver}' in releases else '0')")
26+
if [ "$found" = "1" ]; then
27+
echo "Found ${pkg} ${ver} on TestPyPI"
28+
exit 0
29+
fi
30+
else
31+
echo "No response from TestPyPI (attempt ${attempt})"
32+
fi
33+
34+
attempt=$((attempt + 1))
35+
if [ $attempt -le $max_attempts ]; then
36+
echo "Sleeping ${sleep_secs}s before retrying..."
37+
sleep ${sleep_secs}
38+
fi
39+
done
40+
41+
echo "Timed out waiting for ${pkg}==${ver} on TestPyPI after ${max_attempts} attempts" >&2
42+
exit 1
43+
2944
releases = j.get('releases', {})
3045
print('1' if '${ver}' in releases else '0')
3146
except Exception:

pyalp/README.md

Lines changed: 117 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,140 @@ source venv/bin/activate
1616
pip install --index-url https://test.pypi.org/simple/ --no-deps pyalp
1717
```
1818

19+
Basic usage
20+
-----------
21+
# pyalp (packaged)
22+
23+
This directory contains the Python package layout for the `pyalp` bindings
24+
that expose parts of the ALP GraphBLAS project via pybind11.
25+
26+
Quick start
27+
-----------
28+
29+
Create and activate a virtual environment, then install the package (example
30+
using TestPyPI):
31+
32+
```bash
33+
python -m venv venv
34+
source venv/bin/activate
35+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pyalp
36+
```
37+
1938
Basic usage
2039
-----------
2140

41+
The package exposes a small set of helpers and one or more compiled backend
42+
modules. Use these helpers to list and select available backends and to read
43+
runtime build metadata:
44+
2245
```python
2346
import pyalp
24-
print('pyalp version:', pyalp.version())
25-
print('build metadata:', pyalp.get_build_metadata())
26-
print('algorithm readme (first 200 chars):')
27-
print(pyalp.get_algorithm_metadata().get('readme','')[:200])
47+
print('pyalp build metadata:', pyalp.get_build_metadata())
48+
print('available backends:', pyalp.list_backends())
49+
50+
# Import a specific backend module (returns the compiled module)
51+
backend = pyalp.get_backend('pyalp_ref') # or 'pyalp_omp', 'pyalp_nonblocking'
52+
print('backend module:', backend)
2853
```
2954

55+
Backends and import caveat
56+
--------------------------
57+
58+
Wheels may include multiple compiled backend modules (for example
59+
`pyalp_ref`, `pyalp_omp`, `pyalp_nonblocking`). Historically, importing
60+
multiple different compiled backends in the same Python process could raise
61+
pybind11 registration errors (types duplicated). The bindings now use
62+
`py::module_local()` for core wrapper types, which reduces collisions, but if
63+
you encounter issues importing more than one backend in-process, prefer
64+
testing each backend in a separate process (the supplied test runner does
65+
this).
66+
3067
Runtime metadata
3168
----------------
3269

33-
The package provides a small runtime metadata module generated at build time
34-
from CMake. Useful keys in `pyalp.get_build_metadata()` include:
70+
The package provides a metadata module generated at build time by CMake. Use
71+
`pyalp.get_build_metadata()` to access keys such as:
3572

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

42-
`pyalp.get_algorithm_metadata()` contains available algorithm/backends and
43-
also includes a `readme` key with the package README contents.
79+
`pyalp.get_algorithm_metadata()` contains algorithm/backends info and a
80+
`readme` key with packaged README contents.
81+
82+
Minimal example — conjugate gradient (small test)
83+
------------------------------------------------
84+
85+
Save the following as `test_cg.py` and run `python test_cg.py` after installing
86+
`pyalp` and `numpy`. The example shows selecting a backend explicitly via
87+
`pyalp.get_backend()` and then using the backend's `Matrix`, `Vector`, and
88+
`conjugate_gradient` API.
89+
90+
```python
91+
#!/usr/bin/env python3
92+
"""
93+
Test script for the pyalp backend (example uses the OpenMP backend name
94+
`pyalp_omp`, but you can use `pyalp_ref` or another available backend).
95+
96+
Usage:
97+
python test_cg.py
98+
99+
Dependencies:
100+
- numpy
101+
- pyalp (installed and providing a backend such as pyalp_omp)
102+
"""
103+
104+
import numpy as np
105+
import pyalp
106+
107+
# Choose the backend module (change name if you want a different backend)
108+
pyalp = pyalp.get_backend('pyalp_omp') # or 'pyalp_ref', 'pyalp_nonblocking'
109+
110+
# Generate a small sparse linear system using numpy arrays
111+
N, M = 5, 5
112+
idata = np.array([0, 1, 2, 3, 3, 4, 2, 3, 3, 4, 1, 4, 1, 4, 4], dtype=np.int32)
113+
jdata = np.array([0, 1, 2, 3, 2, 2, 1, 4, 1, 1, 0, 3, 0, 3, 4], dtype=np.int32)
114+
vdata = np.array([1, 1, 1, 1, 0.5, 2, 1, 4, 4.4, 1, 0, 3.5, 0, 3, 1], dtype=np.float64)
115+
b = np.array([1.0, 1.0, 1.0, 1.0, 1.0], dtype=np.float64)
116+
x = np.array([1.0, 1.0, 0.0, 0.3, -1.0], dtype=np.float64)
117+
r = np.zeros(5, dtype=np.float64)
118+
u = np.zeros(5, dtype=np.float64)
119+
tmp = np.zeros(5, dtype=np.float64)
120+
121+
# Create the pyalp Matrix and Vector objects
122+
alpmatrixA = pyalp.Matrix(5, 5, idata, jdata, vdata)
123+
alpvectorx = pyalp.Vector(5, x)
124+
alpvectorb = pyalp.Vector(5, b)
125+
alpvectorr = pyalp.Vector(5, r)
126+
alpvectoru = pyalp.Vector(5, u)
127+
alpvectortmp = pyalp.Vector(5, tmp)
128+
129+
maxiterations = 2000
130+
verbose = 1
131+
132+
# Solve the linear system using the conjugate gradient method in the backend
133+
iterations, residual = pyalp.conjugate_gradient(
134+
alpmatrixA,
135+
alpvectorx,
136+
alpvectorb,
137+
alpvectorr,
138+
alpvectoru,
139+
alpvectortmp,
140+
maxiterations,
141+
verbose,
142+
)
143+
print('iterations =', iterations)
144+
print('residual =', residual)
145+
146+
# Convert the result vector to a numpy array and print it
147+
x_result = alpvectorx.to_numpy()
148+
print('x_result =', x_result)
149+
150+
# Check if the result is close to the expected solution
151+
assert np.allclose(x_result, np.array([1.0, 1.0, 0.0, 0.13598679, -0.88396565])), 'solution mismatch'
152+
```
44153

45154
Packaging notes (for maintainers)
46155
--------------------------------

pyalp/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pyalp"
7-
version = "0.8.16"
7+
version = "0.8.17"
88
description = "Python bindings for ALP GraphBLAS (minimal package layout)"
99
authors = [ { name = "ALP" } ]
1010
readme = "README.md"

0 commit comments

Comments
 (0)