Python host package for GraphReFly over the native Rust graph engine.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file graphrefly-0.23.0-cp312-abi3-win_arm64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-win_arm64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12+, Windows ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8dfbe33ca1f825e0901c0131e8fa1fde90c2a459ebad591795fafe6812929a51
|
|
| MD5 |
8043b5b34f73f76eac1309c0e748cf44
|
|
| BLAKE2b-256 |
43345b15227b1e66cf482139135e5c7fc904607962d397a79e967fc730fce3a3
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-win_arm64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-win_arm64.whl -
Subject digest:
8dfbe33ca1f825e0901c0131e8fa1fde90c2a459ebad591795fafe6812929a51 - Sigstore transparency entry: 2129515538
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-win_amd64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-win_amd64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6410342d727a82f9a487268a8a33e7d0ad41e72885015409d7d20f837e200e2
|
|
| MD5 |
4894403ee5fe5ed7eddbd00319dcd5d7
|
|
| BLAKE2b-256 |
6f236f53357ce589875026834fb65bd0d6a6a313ec1a82869706a7996db5bcf4
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-win_amd64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-win_amd64.whl -
Subject digest:
b6410342d727a82f9a487268a8a33e7d0ad41e72885015409d7d20f837e200e2 - Sigstore transparency entry: 2129516477
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
714026a0b776a21053e6990cf8af584206bf5ce4d4d72e90155c6e7d40c2255d
|
|
| MD5 |
58940c3b7b8659ff3c7098be717a1a07
|
|
| BLAKE2b-256 |
d365370b904a084eac448db44c4da7e1665aee2f8c42e70b2abcfda9506c32e9
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
714026a0b776a21053e6990cf8af584206bf5ce4d4d72e90155c6e7d40c2255d - Sigstore transparency entry: 2129515198
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.12+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7bc04fa24f934822e1637714defabd8dcaead4ea95d95350ea92ecdab3ecaa0
|
|
| MD5 |
fd7402bb5166c468808e92f9f4b145fa
|
|
| BLAKE2b-256 |
26882c13016b198fe4f15a19f4539f876c86c521cddc9cc1cec0066e72fcacb9
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
d7bc04fa24f934822e1637714defabd8dcaead4ea95d95350ea92ecdab3ecaa0 - Sigstore transparency entry: 2129514488
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6effe2b0603548846d63db0b5576ac5dd283506e49d7024c92894271cc832e
|
|
| MD5 |
1f67b5ec7687f9acecce0c9533608c44
|
|
| BLAKE2b-256 |
8bf87625a8add00e7cd8c2d2df7c26fa62420c1d0c49a75e4961546e6168c409
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
ce6effe2b0603548846d63db0b5576ac5dd283506e49d7024c92894271cc832e - Sigstore transparency entry: 2129513769
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 997.9 kB
- Tags: CPython 3.12+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85403dff18833bd6f3fd06648eb7db7259ca890cc47a4598fd30f235016c32c6
|
|
| MD5 |
cb118fbcb2db34737161a367fded4816
|
|
| BLAKE2b-256 |
9267b6e6c89f15fcb8850e1ce11ef227b400f4e9a59d8950c75a353ab15f4981
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
85403dff18833bd6f3fd06648eb7db7259ca890cc47a4598fd30f235016c32c6 - Sigstore transparency entry: 2129515786
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 990.1 kB
- Tags: CPython 3.12+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7cde0b77ffaf8c8cf47110d7b77a216954aa1099df7a224568676963b922d67
|
|
| MD5 |
4475fda54240964e9e3d74cc1175f329
|
|
| BLAKE2b-256 |
6241d7430fe9fa0c4f6ad1371938ec4959e5e08ea37294366fd9f1de026ec32a
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-macosx_11_0_arm64.whl -
Subject digest:
a7cde0b77ffaf8c8cf47110d7b77a216954aa1099df7a224568676963b922d67 - Sigstore transparency entry: 2129516819
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type:
File details
Details for the file graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.12+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3f269ef44ece156ddc4bbd48bb2e93017ee8fbe7366530fe46c46161a8165df
|
|
| MD5 |
cc0326ffb6220863187192221671e6a9
|
|
| BLAKE2b-256 |
910a777a2ddf78a5c3ff070e46d3d3bfde6f3357f36eeb36a5879f53630d5614
|
Provenance
The following attestation bundles were made for graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on graphrefly/graphrefly-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
graphrefly-0.23.0-cp312-abi3-macosx_10_12_x86_64.whl -
Subject digest:
a3f269ef44ece156ddc4bbd48bb2e93017ee8fbe7366530fe46c46161a8165df - Sigstore transparency entry: 2129515011
- Sigstore integration time:
-
Permalink:
graphrefly/graphrefly-py@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/graphrefly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@41ec2a6583b1f2a6a8089d948a3b1711c853df70 -
Trigger Event:
push
-
Statement type: