Skip to main content

Python bindings for the shifty validation engine

Project description

shifty Python bindings

This crate packages the shifty validator as a CPython extension using PyO3. It exposes the shifty module for RDFlib-centric workflows while reusing the same Rust engine that powers the CLI.

Installation

From PyPI (package name pyshifty, import name shifty):

pip install pyshifty

From the repository root you can develop locally with

cd python
uv sync  # or `pip install -r requirements.txt` if you prefer
uvx maturin develop --extras rdflib --release

The GitHub Actions workflow (.github/workflows/python.yml) publishes the package to PyPI as pyshifty and uses this README as the long description, so keep it up to date when the bindings change.

Usage

The extension exports one-shot helpers plus a CompiledShapeGraph cache that mirrors the CLI subcommands:

import shifty

# Validation. When you request diagnostics, a fourth element is returned.
conforms, results_graph, report_text, diag = shifty.validate(
    data_graph,
    shapes_graph,  # optional; omit to reuse data_graph as shapes_graph
    run_inference=True,
    inference={"min_iterations": 1, "max_iterations": 8},
    graphviz=True,
    heatmap=True,
    trace_events=True,
    return_inference_outcome=True,
)
print(diag["graphviz"])        # DOT for the shapes graph
print(diag["heatmap"])         # DOT for the execution heatmap
print(diag["trace_events"][0]) # First trace event (dict)
print(diag["inference_outcome"])

# Inference-only. Diagnostics are returned as a second element when requested.
inferred_graph, diag = shifty.infer(
    data_graph,
    shapes_graph,  # optional; omit to reuse data_graph as shapes_graph
    min_iterations=1,
    max_iterations=4,
    graphviz=True,
    union=True,
    return_inference_outcome=True,
)
print(diag["inference_outcome"]["triples_added"])

# Cache shapes once, then reuse them across datasets.
compiled = shifty.generate_ir(
    shapes_graph,
    skip_invalid_rules=True,
    warnings_are_errors=False,
    do_imports=True,
)
conforms, _, _, diag = compiled.validate(data_graph, run_inference=True)
print("Compiled cache conforms?", conforms)

Key options (mirroring the CLI flags):

  • skip_invalid_rules (default: False), warnings_are_errors, do_imports
  • shapes_graph is optional for top-level validate/infer; when omitted (or None), Shifty uses the provided data_graph as both the data and shapes graph.
  • RDFlib inputs are ingested in-memory (no temporary Turtle graph files written by the binding). When do_imports=True, Shifty reads owl:imports IRIs from the in-memory root graph and asks OntoEnv to resolve those dependencies from their declared locations.
  • Inference knobs: min_iterations, max_iterations, run_until_converged/no_converge, error_on_blank_nodes, debug, union (include original data); the inference={...} dict still works and aliases like inference_min_iterations remain.
  • Diagnostics: graphviz (DOT for shapes), heatmap + heatmap_all (execution heatmap, triggers a validation pass), trace_events, trace_file, trace_jsonl, return_inference_outcome (adds iteration/insert counts).

If you omit all diagnostics, validate returns (conforms, results_graph, report_text) and infer returns the inferred rdflib.Graph just like before.

See example.py and brick.py in this directory for full RDFlib/OntoEnv examples.

Docs

Sphinx docs live in python/docs. Build them with:

cd python/docs
make html

The build writes llms.txt into the HTML output directory (python/docs/_build/html/llms.txt).

Packaging notes

  • Cargo.toml declares readme = "README.md", so this file must be checked into the repo.
  • The sdist job in GitHub Actions uses the same path when stamping metadata via maturin.
  • Any new runtime assets (fixtures, schemas, etc.) should be listed in pyproject.toml under tool.maturin.sdist.include so they reach PyPI.

Project details


Download files

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

Source Distribution

pyshifty-0.0.9.tar.gz (298.4 kB view details)

Uploaded Source

Built Distributions

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

pyshifty-0.0.9-cp313-cp313t-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.13tWindows x86-64

pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_x86_64.whl (94.0 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_aarch64.whl (93.2 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (94.3 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ x86-64

pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (93.4 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ ARM64

pyshifty-0.0.9-cp313-cp313t-macosx_11_0_arm64.whl (7.3 MB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

pyshifty-0.0.9-cp311-abi3-win_amd64.whl (6.7 MB view details)

Uploaded CPython 3.11+Windows x86-64

pyshifty-0.0.9-cp311-abi3-musllinux_1_2_x86_64.whl (94.0 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

pyshifty-0.0.9-cp311-abi3-musllinux_1_2_aarch64.whl (93.1 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

pyshifty-0.0.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (94.2 MB view details)

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

pyshifty-0.0.9-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (93.4 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

pyshifty-0.0.9-cp311-abi3-macosx_11_0_arm64.whl (7.3 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file pyshifty-0.0.9.tar.gz.

File metadata

  • Download URL: pyshifty-0.0.9.tar.gz
  • Upload date:
  • Size: 298.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshifty-0.0.9.tar.gz
Algorithm Hash digest
SHA256 31eeb9164b1eb495d37266b0a16d8a525aac5a8f17ebe53227bde1fa731091ef
MD5 e197eba9d49b75bbcbac14b54ea701f0
BLAKE2b-256 35dfa3e317cb97a2316621b0adb2a101ae92174c8a9a90f3f098266d4ed6e4c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9.tar.gz:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: pyshifty-0.0.9-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 6.7 MB
  • Tags: CPython 3.13t, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshifty-0.0.9-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 d361a80b4b6fbc4ff679eb15430e038e30cc6979b5a6e1a9bbc44fb88c7e71b2
MD5 a1af571657661fd879e56e70950501da
BLAKE2b-256 aa05c7e379e6c2b542695d9307931a4a12a4e04c0cdd395906da620996ac1034

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp313-cp313t-win_amd64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 73eddba61ce8369cb24532bb62bdf1331aa0ff913ad114683b00207495f54cd8
MD5 2452fe245cf2a8504cd467473dd0aef7
BLAKE2b-256 bcac04c84abcea9416067496edc644c8e89015d401f46aeca56744609b087b72

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_x86_64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9466ae46256ff601f6071ff64505ae7602dd1638e73c64dde05d2a640a935937
MD5 795941e6de97b4fd071a69504ca72797
BLAKE2b-256 874b75d4b5c25dee77932a6263ab61c437c2e75a9c347f3fa2f9733775fb1fcc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp313-cp313t-musllinux_1_2_aarch64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0ba16d7b767fc62ccd770c8648eceb90a4511516aa934c6b420417939f9090d
MD5 ab9f342ebbc38484abc3d615b59404ca
BLAKE2b-256 097e4696a6e2ebc6e43d562e6af860c82438652eb2d63682d4df7cb91c4b5f1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2a2d972851dde88af3680ed813d38803c19ee3fd62267ede5c6614fb17a1aee9
MD5 b3130ce894521192714f1a00da0474ab
BLAKE2b-256 66927613b1088c55fb3137ae8c78875d22ff74d9dd9aed30af4c238186ba76ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20794b730b8fb5a2f98fbf1fb0efcef67b44002c01a180158c084158dd991fbd
MD5 3ff08c8c4d25a1a2876047c62534e7f3
BLAKE2b-256 65c3e2ede11fe854c28584d40d5f34c6035be766af260132ed23398f04211a08

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp313-cp313t-macosx_11_0_arm64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: pyshifty-0.0.9-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.7 MB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyshifty-0.0.9-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 039c2a88c044a24560230243bb0333785041657586deae34cf55ce6cb4112e9e
MD5 a44829b4ece478e17fff6e756862c2bf
BLAKE2b-256 0e39e8a5cf00294bea8afcc8ea4bec71ade6464e62966e71d22ee98461b31401

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp311-abi3-win_amd64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9cb0334f78d367d4801f61d642d7abe220d027f3f9859f78fa07471dd9a7320c
MD5 79111bb8679d63e5479090a7aa64d32c
BLAKE2b-256 546c6f564b15d2a856ef4edb1efc311a588b6f91a1b2e5acbdca84b8828a6139

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 ec9647e6071fa63616dc35698a6a3e0cff6d160e630b5465dd90a48a2d178312
MD5 6032f3d8b07287fcc1d0c1fb584b47a6
BLAKE2b-256 c8466b3abd066b9d7221c067e963a5daab994df3ddcf2c5446d08db6baa03e31

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e6deb2e6c8ac27b595517300a515ba53b5075c60701dad7a91d8ad1b1b0b3d00
MD5 4f77801112e661a09347391465da635e
BLAKE2b-256 ef1f9135580fe5eac86a2d0cf46a084460a32fa42385b720d659eef2c53a270f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 42347eb1c4eceb686a5d2138af2a7cdff33b401bed3acffcdb788fd1983cd2f5
MD5 d42c465a13235bcaab2ef5db2bc8bd59
BLAKE2b-256 7ca329919daf1d2a3d5ab1b11f02d1cf89a2ca4e89226b767b994fd659c5b65e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyshifty-0.0.9-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.9-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 88b5fdba0e63fc83e2049cc4f0f664016d42fa935a1417c204e720136c63102b
MD5 cff79fdba07dc862b1cfcaf3d68679ce
BLAKE2b-256 4090553656375b7ba35b519cad52a7f93eb184845d5232ac678d50bbd8f636b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.9-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on gtfierro/shifty

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page