Skip to main content

pyshacl-turbo

Python 3.11+ Rust License: MIT OR Apache-2.0 Python coverage measured by pytest-cov pySHACL non-JS suite: 100% (403/403)

Tests and wheels Compatibility Regex

A Rust SHACL engine with Python bindings. Shape compilation, Core validation, SPARQL constraints, targets, rules and inference execute in Rust. There is no runtime dependency on pySHACL or owlrl. Native execution releases the Python GIL.

Compatibility work targets pySHACL 0.40.1, excluding SHACL-JS. It is incomplete. The locally corrected upstream suite passes 403/403 cases (100%): 400 unchanged behavioral cases, one corrected fixture, and 2 explicitly recorded native equivalents for Python implementation tests. The corrected fixture checks that invalid geometry data is rejected and that supplying its missing subclass relationship makes it valid. Both engines pass these assertions with equivalent reports; see the correction and ADR 0018. The pinned W3C suite passes 120/120 (100%) with document inputs and 119/120 with RDFLib Graph inputs. The latter retains a documented input-dependent pySHACL behavior. These are separate measurements; see compatibility and the case-level upstream report.

Core and SPARQL patterns execute Python-compatible regexes natively, including lookarounds and backreferences. SPARQL REPLACE retains the pinned RDFLib replacement behavior; native callbacks and query results preserve exact literal terms. See ADR 0015 for the contract and remaining regex limits.

Count and length bounds retain exact arbitrary-precision values, with pySHACL's parameter-specific datatype rules. See ADR 0016 for integer and qualified-count behavior.

Build

Requires Rust/Cargo, Python 3.11+ and uv. Development uses Python 3.13. The repository pins Rust 1.98.0 for compilation and formatting.

make dev
make check

Python

from pyshacl_turbo import compile_shapes, validate

conforms, report_graph, report_text = validate(
    "data.ttl", shacl_graph="shapes.ttl", advanced=True
)

# Compile once and reuse across independent datasets.
program = compile_shapes("shapes.ttl", advanced=True)
conforms, report_graph, report_text = program.validate("data.ttl")

Inputs include RDFLib Graph/Dataset objects, paths, URLs, file objects, RDF text and bytes. Supported formats include Turtle, N-Triples, N-Quads, TriG, RDF/XML, N3 and JSON-LD. Named graphs remain available to SPARQL GRAPH clauses; Core validation sees their union. Reports are RDFLib graphs by default.

PyOxigraph Store input is also supported. Install the optional oxigraph extra when PyOxigraph is not already installed:

from pyoxigraph import RdfFormat, Store
from pyshacl_turbo import validate

store = Store()
store.load(path="data.trig", format=RdfFormat.TRIG)
conforms, report, text = validate(store, shacl_graph="shapes.ttl", advanced=True)

The Store input path avoids an intermediate RDFLib data graph. Independent Python extensions exchange a native N-Quads snapshot, so it is not zero-copy. See Store input details. Named graphs and blank-node labels are preserved. Literal spellings already normalized by a caller's Store cannot be recovered. Store rule and inference additions commit atomically only with inplace=True, after successful execution. Only new quads are committed; concurrent deletion of input quads is not undone.

RDFS and OWL-RL inference are implemented natively and selected with inference="rdfs", "owlrl" or "both". Coverage is still being expanded; current inferred graphs do not always match the reference's complete closure. owlrl is installed only by the reference-test extra, not as a runtime backend.

Rust

The standalone pyshacl-turbo-engine crate accepts exact-term oxrdf Dataset values and oxigraph::Store inputs. CompiledShapes::validate_store and expand_store copy a consistent quad snapshot without RDF text conversion. Their inplace flag controls atomic addition of derived quads to the Store. Compiled programs are shareable across threads; parallelism is caller-controlled.

Shape compilation uses shacl-structural-model with Turbo's exact RDF terms, then prepares native queries, regexes and indexes for execution. The original graph remains available for reports and source identity. See ADR 0017.

Performance

make benchmark

The compiler integration comparison records before/after compilation and validation timings, including reused shapes, with complete report parity required before timing.

The performance report compares RDFLib inputs and already loaded PyOxigraph Stores, including conversion and report construction. It includes shape reuse, increasing data and shape counts, SPARQL rules and reasoning. Every timed path first has to produce an equivalent complete report. Raw samples, versions and source hashes are in current.json. The original measurements are preserved in performance-baseline.json.

Measurements are workload-specific. Sparse targeting can be slower because Turbo must copy the input graph. Reasoning timings are provisional where the complete inferred graphs differ, even when validation reports agree. Reference backend errors are recorded without assigning a speedup. The latest run was made while other workspace builds were active; its raw samples show substantial scheduling variation. Sparse-target workloads remain slower with fresh RDFLib input. See the report's load notes before using its speedup ratios for capacity planning.

The last full matrix includes literal identity, report graph context and inference axiom fixes. It predates the recursion and undefined-function changes in ADR 0012; its recorded source hashes identify the measured checkpoint. Earlier matrices remain in benchmarks/. The newer Core measurements include the Python pattern compatibility changes in ADR 0013, at 100, 1,000 and 10,000 nodes. The SPARQL pattern measurements exercise native REGEX and REPLACE at 100 and 1,000 nodes through both RDFLib and Store inputs. The report records concurrent build load alongside the raw interleaved samples. These measurements precede ADR 0016's integer-parameter changes; their source hashes identify the measured implementation.

# Run alone, separately from builds and other tests.
.venv/bin/python benchmarks/check_core.py

# Full-report-gated SPARQL regex and replacement comparison.
.venv/bin/python benchmarks/matrix.py --kinds sparql-patterns --repeats 7 --output benchmarks/sparql-patterns.json

# Original SPARQL pipeline comparison, including both reference backends.
make benchmark-pipeline

Verification and architecture

Local regressions compare full reports, rule output, graph mutation, blank-node identity, namespace handling, Store inputs and errors. Pinned W3C and pySHACL assets live under tests/w3c and vendor/pyshacl respectively.

make coverage
make test-compatibility
make test-regex
make test-sparql-evaluator
make test-coverage
.venv/bin/python scripts/run_upstream.py
.venv/bin/python scripts/run_upstream.py --reference
.venv/bin/python scripts/audit_reference_fixture.py

The three workflow badges report required CI checks on main. Each workflow also runs on pull requests, daily, and on manual dispatch:

Workflow What it verifies
Tests and wheels Python and Rust regressions, formatting and lint on Linux Python 3.11/3.13 and macOS Python 3.13; SPARQL evaluator tests with compatibility features disabled and enabled; source archive rebuilt into Linux x86-64/ARM64, macOS Intel/Apple Silicon, and Windows x86-64 wheels, installed with only runtime dependencies. The release also requires Compatibility and Regex at the same prepared revision.
Compatibility All pinned W3C Core/SPARQL cases through both document and Graph APIs, the complete locally corrected non-JS pySHACL inventory, and the corrected geometry test with both engines and full report comparison. Case-level JSON and W3C JUnit XML are uploaded as artifacts.
Regex The patched matcher's full upstream suite, unit tests with Turbo's base features, Python-mode VM regressions, and formatting, using its own pinned test dependencies.

The Python coverage report measures the complete pyshacl_turbo Python package with pytest-cov, including uncovered files and branches. CI requires 100% line and branch coverage on Linux Python 3.13. XML, JSON and HTML reports are uploaded for each run; passing main runs publish the HTML report and measured percentage badge to GitHub Pages. make test-coverage generates the same report locally in htmlcov/. This measures Python API/CLI code coverage; it does not measure Rust code coverage or SHACL compatibility. No package files are omitted from the denominator.

A green Compatibility badge means the documented baseline holds: 403/403 locally corrected upstream passes, 120/120 W3C document passes and 119/120 W3C Graph passes. Every upstream case must pass; the one local fixture correction and two native equivalents remain identified in the report. The corrected fixture must also pass its independent two-engine audit. The W3C Graph divergence remains a strict expected failure. New failures and unexpected Graph passes fail CI. These badges do not claim complete pySHACL compatibility.

Upstream allowances which turn failures into passes are disabled for both engines. The bridge blocks reference validation and rule execution. Original comparators are test infrastructure only. The private workload in the motivating screenshot has not been tested.

Architectural decisions are in docs/adr. The exact-term dataset avoids premature literal canonicalization. Documented local Rust dependency patches preserve RDFLib string identity and SHACL SPARQL prebinding.

PRs use conventional titles and squash merges; main requires signed commits, passing test, compatibility, regex, and Conventional Commit checks, and the configured owner review. Repository maintenance follows the public Legra release policy and the shared legra-ai/github-actions pipeline. Release artifacts and recovery are described in releasing.

License

Original project code is dual-licensed under MIT or Apache-2.0, at your option (MIT OR Apache-2.0). Copyright 2026 DataRoad Inc, Delaware, USA, trading as Legra. Vendored code and assets retain their licenses and provenance.

Metadata

Release files for pyshacl-turbo 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyshacl-turbo 0.1.0
File Size Uploaded
pyshacl_turbo-0.1.0.tar.gz 862.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyshacl-turbo 0.1.0
File
pyshacl_turbo-0.1.0-cp311-abi3-win_amd64.whl CPython 3.11 abi3 Windows x86-64 Details
pyshacl_turbo-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl CPython 3.11 abi3 Linux glibc 2.28+ x86-64 Details
pyshacl_turbo-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl CPython 3.11 abi3 Linux glibc 2.28+ ARM64 Details
pyshacl_turbo-0.1.0-cp311-abi3-macosx_11_0_arm64.whl CPython 3.11 abi3 macOS 11.0+ ARM64 Details
pyshacl_turbo-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl CPython 3.11 abi3 macOS 10.12+ x86-64 Details

Total release size: 18.7 MB

Release files / pyshacl_turbo-0.1.0.tar.gz

Download URL pyshacl_turbo-0.1.0.tar.gz
Size 862.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5eb9f935f61cc8f0cad347f3932b8874ac67a263d4834fb68fdc8d2ebb6f0379
BLAKE2b-256 checksum
How to use checksums
e5bdbefc01dc67ccafd44d8f293a68dcb33b3a57efcea3e532ee0ffa1291bc8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.0-cp311-abi3-win_amd64.whl

Download URL pyshacl_turbo-0.1.0-cp311-abi3-win_amd64.whl
Size 3.6 MB
Tags CPython 3.11 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
ec15016a51b9b715996dc299043c3c0fa7fe597672c98869d90032d312abaf98
BLAKE2b-256 checksum
How to use checksums
d9d767dea083031e1ed7a3ca63902b62bc6a0235e759479df49712e67ff105f6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl

Download URL pyshacl_turbo-0.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
Size 3.6 MB
Tags CPython 3.11 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
725fbc6c13fc0b7fb2dcb5db2707f225c3ed6482063a03fc5f65e37d847c7657
BLAKE2b-256 checksum
How to use checksums
616a4abb666216edc6bac90eccd851752207068739421f0a8e38c78ef25385fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl

Download URL pyshacl_turbo-0.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
Size 3.4 MB
Tags CPython 3.11 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
51af78be1dcf9056b4f690fa03e996ed2caeb506998689ba42669e470e6b1cd5
BLAKE2b-256 checksum
How to use checksums
339efe3df249c442433714b6bc51d7c04b63bd6f1136bb9376e57f8b25f2a3f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.0-cp311-abi3-macosx_11_0_arm64.whl

Download URL pyshacl_turbo-0.1.0-cp311-abi3-macosx_11_0_arm64.whl
Size 3.5 MB
Tags CPython 3.11 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b3197b1d267c726af769677f07a1d8bf576073617d1410d697aa227319dfb8a3
BLAKE2b-256 checksum
How to use checksums
ba63ac90dc254b16b00c8df8ed220e941fe4e57f7254b973b36f53b900ac4811
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release files / pyshacl_turbo-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl

Download URL pyshacl_turbo-0.1.0-cp311-abi3-macosx_10_12_x86_64.whl
Size 3.7 MB
Tags CPython 3.11 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
f327669f611d6bb53140a0d2a19280ac02a3cf5d8667de7786618badad2e56f1
BLAKE2b-256 checksum
How to use checksums
bf4701ffa608b14414f8568566c91d70f59ce995eba10b315f11591d21422548
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.4

6 release files

0.2.3

6 release files

0.2.2

6 release files

0.2.1

6 release files

0.2.0

6 release files

0.1.3

6 release files

0.1.2

6 release files

0.1.1

6 release files

This release

0.1.0 This release

6 release 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