GraphReFly Python
graphrefly is the Python host package for GraphReFly: a reactive graph runtime
with a Python-owned facade over the native Rust engine.
Install it from PyPI:
pip install graphrefly
GraphReFly is alpha software, but the Python host/native binding closeout is now backed by the clean-slate conformance suite. The package requires Python 3.12+.
Quick Start
from graphrefly import Graph
with Graph("hello") as graph:
count = graph.state(1, name="count")
doubled = graph.derived([count], lambda value: value * 2, name="doubled")
with doubled.subscribe(lambda msg: print(msg.kind, msg.value)):
count.set(2)
count.set(3)
assert doubled.cache() == 6
The subscription receives the initial cached value and each later update. The
graph owns the node topology; with Graph(...) closes facade resources when the
scope exits.
Core Shape
from graphrefly import Graph
graph = Graph("demo")
source = graph.state(1, name="source")
plus_one = graph.derived([source], lambda value: value + 1, name="plus_one")
advanced = graph.node(
[source],
lambda ctx: ctx.emit(ctx.data(0) + 10),
name="advanced",
)
with plus_one.subscribe(lambda msg: print(msg.kind, msg.value)):
source.set(4)
assert plus_one.cache() == 5
assert advanced.cache() == 14
assert plus_one.status in {"settled", "resolved"}
Use Graph.derived(...) for value-level functions. Use Graph.node(...) when
you need the callback-scoped Ctx surface for advanced graph behavior such as
per-node state, raw wave data reads, invalidation hooks, pull demand, or
deferred rewire.
Public Surface
The Python facade exports:
Graph,Node[T],Ctx,PullContext,RewireNextSubscription,Retain,GraphReentryQueueDataMessage[T],ErrorMessage,ControlMessage,Message[T],GraphEventSENTINELfor rawctx.wave_dataINVALIDATE/no-DATA projection- checkpoint and restore helpers:
GraphCheckpoint,RestoreRef,RestoreContext,RestoreDescriptor,RestoreRegistry,restore_ref,restore_registry,restore_graph - async boundary helpers:
AsyncRunner,from_awaitable,from_async_iter,async_node,asyncio_runner,trio_runner,anyio_runner - network source adapters:
HttpRequest,HttpResponse,HttpStreamHead,HttpStreamHeadEvent,HttpStreamChunkEvent,HttpStreamErrorEvent,HttpStreamCompleteEvent,HttpStreamDriverEvent,SseEvent,LocalHttpDriver,LocalHttpStreamDriver,from_http,from_sse - wire bridge facades:
wire_bridge,wire_bridge_protobuf,wire_edge_group,wire_bridge_ack_driver - public exceptions under
GraphReflyError
The private native extension is loaded as graphrefly._native; it is not the
public API.
Boundary Notes
- The sync wave protocol runs in Rust. Python callbacks enter through the native dispatcher path; Python does not reimplement the wave core.
- Native graph handles are single-thread host objects in this foundation slice.
Noneis valid Python DATA. Absence of DATA is separate andNode.cache()raisesGraphReflyNoDataErrorwhen no DATA is present. UseNode.cache(default=...)orNode.has_valuefor non-exceptional absence handling.ctx.wave_datais the raw advanced dep input shape. Ergonomic helpers such asctx.data()andctx.has_data()are derived from that shape.Graph.close()andwith Graph(...)are Python host lifetime scopes. They release facade-created subscriptions/observers and graph-owned retain roots; they do not emit protocolTEARDOWNorCOMPLETE.- Public Python exposes facade methods only; raw protocol ingress, arbitrary message construction/sending, and native handles remain hidden.
Async Runners
Async work enters only through explicit runner helpers. The core API does not own an asyncio loop, Trio nursery, AnyIO task group, background thread, portal, or hidden pump.
Install optional runtime adapters with:
pip install "graphrefly[async]"
import trio
from graphrefly import Graph, from_awaitable, trio_runner
async def fetch_value() -> int:
return 42
async def main() -> None:
graph = Graph("trio-demo")
async with trio.open_nursery() as nursery:
node = from_awaitable(
graph,
trio_runner(nursery),
fetch_value,
name="value",
)
with node.subscribe(lambda msg: print(msg.kind, msg.value)):
await trio.lowlevel.checkpoint()
When a host runtime completes work away from the graph owner thread, keep re-entry explicit:
graph = Graph("queued-demo")
queue = graph.reentry_queue()
runner = queue.wrap_runner(host_owned_runner)
node = from_awaitable(graph, runner, fetch_value, name="queued")
with node.subscribe(lambda msg: None):
queue.drain(max_items=None)
The queue accepts only GraphReFly-owned private completions; it is not a public callable enqueue or graph mutation channel.
from_http and from_sse follow the same boundary rule: callers provide both
an explicit AsyncRunner and a host-owned driver. The package does not own an
event loop or ship a default HTTP client in this slice; from_sse parses
text/event-stream bytes from LocalHttpStreamDriver without hidden retry,
reconnect, or Last-Event-ID management.
Documentation
- Python docs: https://py.graphrefly.dev/
- API reference: https://py.graphrefly.dev/api/
- Language-neutral spec: https://graphrefly.dev/spec/
- Repository: https://github.com/graphrefly/graphrefly-py
This repo owns the Python package docs: public docstrings, generated Python API
reference, Starlight source pages, examples, PyPI install material, and package
release notes, plus the package-local website/ site configuration. The
package-local docs policy is docs/docs.jsonl.
Shared graphrefly.dev website architecture, shared concepts, protocol authority,
and the public blog stay in ~/src/graphrefly under D563. Generated API output
comes from docstrings through the griffe-backed Starlight generator; do not edit
generated website/src/content/docs/api/ output by hand.
Local Development
This package expects sibling checkouts:
~/src/graphrefly-py
~/src/graphrefly-rs
Install and test:
uv sync --group dev --group docs
cd ../graphrefly-rs
mise exec -- bash -lc 'cd ../graphrefly-py && uv run maturin develop --release'
cd ../graphrefly-py
uv run pytest
uv run ruff check .
uv run mypy src
uv run python scripts/check_api_docs.py
cd website && pnpm docs:gen:check
cd website && pnpm build
python -c "import graphrefly; print(graphrefly.version())"
The Python repo validates Starlight and griffe-generated API output and deploys the
package-local docs artifact to https://py.graphrefly.dev/. The shared
~/src/graphrefly website links to this route but does not copy generated Python
API pages into the main graphrefly.dev artifact.
The Rust foundation can be checked directly from the sibling repo:
cd ~/src/graphrefly-rs
mise exec -- cargo test -p graphrefly-bindings-py
Metadata
Release files for graphrefly 0.23.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| graphrefly-0.23.0-cp312-abi3-win_arm64.whl | CPython 3.12 | abi3 | Windows ARM64 | Details |
| graphrefly-0.23.0-cp312-abi3-win_amd64.whl | CPython 3.12 | abi3 | Windows x86-64 | Details |
| graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ x86-64 | Details |
| graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl | CPython 3.12 | abi3 | Linux musl 1.2+ ARM64 | Details |
| graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details |
| graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details |
| graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details |
| graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details |
Total release size: 8.7 MB
Release files / graphrefly-0.23.0-cp312-abi3-win_arm64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-win_arm64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
8dfbe33ca1f825e0901c0131e8fa1fde90c2a459ebad591795fafe6812929a51
|
|
BLAKE2b-256 checksum How to use checksums |
43345b15227b1e66cf482139135e5c7fc904607962d397a79e967fc730fce3a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-win_amd64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-win_amd64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b6410342d727a82f9a487268a8a33e7d0ad41e72885015409d7d20f837e200e2
|
|
BLAKE2b-256 checksum How to use checksums |
6f236f53357ce589875026834fb65bd0d6a6a313ec1a82869706a7996db5bcf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 1.3 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
714026a0b776a21053e6990cf8af584206bf5ce4d4d72e90155c6e7d40c2255d
|
|
BLAKE2b-256 checksum How to use checksums |
d365370b904a084eac448db44c4da7e1665aee2f8c42e70b2abcfda9506c32e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | CPython 3.12 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
d7bc04fa24f934822e1637714defabd8dcaead4ea95d95350ea92ecdab3ecaa0
|
|
BLAKE2b-256 checksum How to use checksums |
26882c13016b198fe4f15a19f4539f876c86c521cddc9cc1cec0066e72fcacb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ce6effe2b0603548846d63db0b5576ac5dd283506e49d7024c92894271cc832e
|
|
BLAKE2b-256 checksum How to use checksums |
8bf87625a8add00e7cd8c2d2df7c26fa62420c1d0c49a75e4961546e6168c409
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 997.9 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
85403dff18833bd6f3fd06648eb7db7259ca890cc47a4598fd30f235016c32c6
|
|
BLAKE2b-256 checksum How to use checksums |
9267b6e6c89f15fcb8850e1ce11ef227b400f4e9a59d8950c75a353ab15f4981
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 990.1 kB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a7cde0b77ffaf8c8cf47110d7b77a216954aa1099df7a224568676963b922d67
|
|
BLAKE2b-256 checksum How to use checksums |
6241d7430fe9fa0c4f6ad1371938ec4959e5e08ea37294366fd9f1de026ec32a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logRelease files / graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
a3f269ef44ece156ddc4bbd48bb2e93017ee8fbe7366530fe46c46161a8165df
|
|
BLAKE2b-256 checksum How to use checksums |
910a777a2ddf78a5c3ff070e46d3d3bfde6f3357f36eeb36a5879f53630d5614
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logSecurity for graphrefly 0.23.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 8 files in this release have been uploaded with provenance metadata.
Attestation for graphrefly-0.23.0-cp312-abi3-win_arm64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 9, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.