Skip to main content

rete-graph — Python client for .rete files

Query local and remote .rete graph files with SPARQL from Python. A .rete file is a single, immutable, range-queryable RDF graph file (rete): drop it on any HTTP host that supports Range requests and query it in place — the client fetches only the byte ranges a query touches, never the whole file.

These are native bindings (PyO3) to the same Rust engine that powers the rete CLI and the browser playground.

Install

uv pip install rete-graph        # or: pip install rete-graph

Wheels cover Linux (x86_64/aarch64), macOS, Windows — and, from 0.2.0, browser Python: in JupyterLite or marimo's WASM playground, %pip install rete-graph resolves a Pyodide (PyEmscripten) wheel and remote graphs are queried over sync-XHR range requests, no server anywhere.

A runnable tour with captured outputs lives in examples/tutorial.ipynb, and examples/agents/ turns a graph into agent tools for LangChain and Pydantic AI.

Use

import rete_graph as rete

# Remote: lazy HTTP range reads — a selective query over a multi-GB file
# fetches KBs. Any S3/R2/CDN/GitHub URL with Range + CORS works.
g = rete.open("https://data.graphplaza.com/boe/boe.rete")

rows = g.query("""
    SELECT ?s ?label WHERE {
        ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label
    } LIMIT 10
""")
for row in rows:
    print(row["s"].value, "→", row["label"].to_python())

print(g.stats())   # {'fileLength': ..., 'bytes': ..., 'requests': ...}

query() returns {variable: Term} rows for SELECT, a bool for ASK, and (s, p, o) triples for CONSTRUCT/DESCRIBE. A Term carries .kind / .value / .datatype / .lang, plus .to_python() (int/float/bool for common XSD types) and .n3.

More:

g = rete.open("data/example.rete")            # local file, opened lazily too
g = rete.open(rete.build(nt_text))            # build a graph in memory ("nt"/"nq"/"ttl")
g = rete.open(rete.build(rdflib_graph))       # or straight from an rdflib Graph/Dataset
g = rete.open(url, headers={"Authorization": "Bearer ..."})   # authed hosts

g.examples()                                  # SPARQL examples embedded in the file — run as-is
g.query(q, reason=True)                       # OWL 2 QL entailment (query rewriting)
g.query_df("SELECT ...")                      # pandas DataFrame (pip install rete-graph[pandas])
g.schema()                                    # class/predicate profile
g.prefix_search("Berl")                       # label autocomplete
g.text_search("volcano eruption")             # full-text (files built with --text-index)
g.info(), g.quads, g.content_hash()

SPARQL 1.1 SERVICE federation works out of the box — join a .rete file against any public SPARQL endpoint in one query.

Prepare a .rete step by step

The lazy Builder configures a build — sources, embedded Dataset Card, pyramid, full-text index — then run() / export():

builder = (
    rete.Builder()
    .add_file("people.ttl")                    # or .add(text) / .add(rdflib_graph)
    .card(title="People", license="CC0-1.0", created="2026-07-16")
    .pyramid(algo="louvain")                   # or "types", or .pyramid(False)
    .text_index()
)
builder.run()                                  # bytes; counts in builder.stats
builder.export("people.rete")                  # immutable, host-anywhere file
builder.graph().card()                         # read the embedded card back

See the "Python: build a .rete" tutorial in the docs for the full walkthrough.

Custom storage (fsspec, S3, GCS, …)

Anything that can serve byte ranges can back a graph — pass an object with read_at(offset, length) -> bytes and len():

import fsspec, rete_graph as rete

class FsspecReader:
    def __init__(self, url, **kw):
        self.f = fsspec.open(url, "rb", **kw).open()
        self.size = self.f.size
    def len(self):
        return self.size
    def read_at(self, offset, length):
        self.f.seek(offset)
        return self.f.read(length)

g = rete.open(reader=FsspecReader("s3://my-bucket/data.rete", anon=False))

Building from source

The package is a maturin project; the repo convention is to build in Docker (nothing on the host):

# from the repository root
docker run --rm -v "$PWD":/io ghcr.io/pyo3/maturin build \
    --release -m clients/python/Cargo.toml --out clients/python/dist

uv pip install clients/python/dist/*.whl

Tests: uv pip install pytest && pytest clients/python/tests.

Wheels are abi3 (>= 3.9): one wheel per platform covers every CPython. Releases are published to PyPI by .github/workflows/python-client-publish.yml on a py-v* tag.

Download files

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

Source Distribution

rete_graph-0.3.0.tar.gz (392.2 kB view details)

Uploaded Source

Built Distributions

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

rete_graph-0.3.0-cp39-abi3-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

rete_graph-0.3.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl (924.0 kB view details)

Uploaded CPython 3.9+PyEmscripten 2026.0 wasm32

rete_graph-0.3.0-cp39-abi3-pyemscripten_2025_0_wasm32.whl (972.0 kB view details)

Uploaded CPython 3.9+PyEmscripten 2025.0 wasm32

rete_graph-0.3.0-cp39-abi3-manylinux_2_28_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

rete_graph-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.0 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

rete_graph-0.3.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (5.4 MB view details)

Uploaded CPython 3.9+macOS 10.12+ universal2 (ARM64, x86-64)macOS 10.12+ x86-64macOS 11.0+ ARM64

File details

Details for the file rete_graph-0.3.0.tar.gz.

File metadata

  • Download URL: rete_graph-0.3.0.tar.gz
  • Upload date:
  • Size: 392.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0.tar.gz
Algorithm Hash digest
SHA256 6eed6254ca8e4482b5df6eee2b1006f753bb42e9a1e2b595e8cc7e4a61cd3c56
MD5 19e7f712052a183537961be006a128b3
BLAKE2b-256 a7d0ec8d3b89488725bac4016a6b68e88076159bb2cafdeb0938f03f5c2b727a

See more details on using hashes here.

File details

Details for the file rete_graph-0.3.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: rete_graph-0.3.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b690b71533e8c02d37815952c70003c4341c1fd58851919c49489b774cd44638
MD5 0b7076f7cab1b2cba2fdee861b99df24
BLAKE2b-256 d3308926ab2f611dcc81bac8fd47d13fd0bfb7be67757631327cd552de6f804a

See more details on using hashes here.

File details

Details for the file rete_graph-0.3.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl.

File metadata

  • Download URL: rete_graph-0.3.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl
  • Upload date:
  • Size: 924.0 kB
  • Tags: CPython 3.9+, PyEmscripten 2026.0 wasm32
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0-cp39-abi3-pyemscripten_2026_0_wasm32.whl
Algorithm Hash digest
SHA256 ef11a0dce6d946f723988ec87539721091e10d3c64ef0f75d0bf8285f1559408
MD5 ef9f00c417fd0c241c66ecbffc6ba1a8
BLAKE2b-256 770d7475695886dd6b0700c47f49f9fc88825721fea4438cf6d99e199f6494d3

See more details on using hashes here.

File details

Details for the file rete_graph-0.3.0-cp39-abi3-pyemscripten_2025_0_wasm32.whl.

File metadata

  • Download URL: rete_graph-0.3.0-cp39-abi3-pyemscripten_2025_0_wasm32.whl
  • Upload date:
  • Size: 972.0 kB
  • Tags: CPython 3.9+, PyEmscripten 2025.0 wasm32
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0-cp39-abi3-pyemscripten_2025_0_wasm32.whl
Algorithm Hash digest
SHA256 902071ede1e2f37eb282fbe2960c9e9638509cc7b9cfbee20dcb5d7094b0b5e6
MD5 663d7f75047fa0e13941c1bd0fffaad5
BLAKE2b-256 ffd89f5494d16eaa6b6420992134f608f0bac6e9ae5a52513af9d78cf0c62455

See more details on using hashes here.

File details

Details for the file rete_graph-0.3.0-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

  • Download URL: rete_graph-0.3.0-cp39-abi3-manylinux_2_28_aarch64.whl
  • Upload date:
  • Size: 2.7 MB
  • Tags: CPython 3.9+, manylinux: glibc 2.28+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 52405cd2aeedd97bf324e8f0df1e58b71c10bebf5134d44268299f89c306c349
MD5 0f80a33b88e9998659bb41cbfd7fd447
BLAKE2b-256 eb4b3e945f45c8b93675d2cad7c5a65aef44b7303a745aa64315502040c85fae

See more details on using hashes here.

File details

Details for the file rete_graph-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: rete_graph-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: CPython 3.9+, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b6431edd7d1779bf7534bd82762cd8f4cab83653392c654655ded25532800012
MD5 781aa6b0f71f6362d47f2f7c01aa4da8
BLAKE2b-256 96dcfe51ff634794bf0a1ccce1f0a9c2d07943d21d9fed5bd98728ff2d17013c

See more details on using hashes here.

File details

Details for the file rete_graph-0.3.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl.

File metadata

  • Download URL: rete_graph-0.3.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
  • Upload date:
  • Size: 5.4 MB
  • Tags: CPython 3.9+, macOS 10.12+ universal2 (ARM64, x86-64), macOS 10.12+ x86-64, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for rete_graph-0.3.0-cp39-abi3-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl
Algorithm Hash digest
SHA256 7f7722c69773b66233becccbee890cca02f66edc78069a35a7cd32b3fd62449e
MD5 a67959a4e765e2104f2a7333c5f255af
BLAKE2b-256 7caceefc1a40680961ce708b1c41fd1080acbc89278850d47692527e6c2d3e53

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.2

7 files

0.3.1

7 files

This release

0.3.0 This release

7 files

0.2.3

7 files

0.2.2

7 files

0.2.1

7 files

0.2.0

7 files

0.1.0

5 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page