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.13.tar.gz (431.2 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.13-cp313-cp313t-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.13tWindows x86-64

pyshifty-0.0.13-cp313-cp313t-musllinux_1_2_x86_64.whl (97.6 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

pyshifty-0.0.13-cp313-cp313t-musllinux_1_2_aarch64.whl (96.5 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyshifty-0.0.13-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (97.8 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ x86-64

pyshifty-0.0.13-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.7 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ ARM64

pyshifty-0.0.13-cp313-cp313t-macosx_11_0_arm64.whl (7.6 MB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

pyshifty-0.0.13-cp311-abi3-win_amd64.whl (7.0 MB view details)

Uploaded CPython 3.11+Windows x86-64

pyshifty-0.0.13-cp311-abi3-musllinux_1_2_x86_64.whl (97.5 MB view details)

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

pyshifty-0.0.13-cp311-abi3-musllinux_1_2_aarch64.whl (96.4 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

pyshifty-0.0.13-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (97.8 MB view details)

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

pyshifty-0.0.13-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.7 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

pyshifty-0.0.13-cp311-abi3-macosx_11_0_arm64.whl (7.6 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyshifty-0.0.13.tar.gz
  • Upload date:
  • Size: 431.2 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.13.tar.gz
Algorithm Hash digest
SHA256 c037748f9ebb5173a930100bbc17d9fba8dd2ed7ac9ef719498efb95f87e2099
MD5 7d18f3b8af93b5475351fe0b3686440f
BLAKE2b-256 94c211ec7f011fbd0f85b99cf4fcac9bdbebda5e714b178150f40230e6ed61fd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13.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.13-cp313-cp313t-win_amd64.whl.

File metadata

  • Download URL: pyshifty-0.0.13-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 7.0 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.13-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 ed49601ef0c8ecd8c10c00b1c3a195be67270e8e0c63d0ac517e372a61c71c91
MD5 20eef9205b4a60e6c9ec327155c61051
BLAKE2b-256 a76d289e25a871112c9b4c187b381e204255cd884a12e7bf97c25fa136b2ad94

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp313-cp313t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0a368b1d526b45ecc7b65c1489b388eac185f72453ecc2849da43ec5b7eab280
MD5 d088636f509310e9a652e18066b272dc
BLAKE2b-256 9863b3f257a997b44fe1182207d1368df6e711f83e39bef7db51d6f601de98e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp313-cp313t-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 10a84d56e9420d533bc04a9b4eb6201906025ce9b336d87fbf274f32dad3604b
MD5 259d2695ddaac5e6f58ea717a33ee16a
BLAKE2b-256 afe9d7767f56c55e61feab210450e2acf5dc0bc077ee99b5f330443d3ae28782

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1064ea7850a04c4fed427c50a8311adb6aa83d63f3a55a7ef05a60580e2e3f9a
MD5 fc105a5c19a085a2ea8d57c2c6bb2dc5
BLAKE2b-256 526f3833a182a6b51d1ed62fb013732dd33533a1bac11240196136f5fa01e7df

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dfc5fb2bb502a3454e640d920dfe491ec0f2cee80a82571168a42314af964ba1
MD5 7007bca5376b4b48178b49bd1142df09
BLAKE2b-256 cb7de78b2216f637f3705da49ed3843608393eb358d816bddb2272197be915ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp313-cp313t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6440e3dc1fdf666b63596032a86870c59cf0f52f3d751d4ae7c1169fc9ac2a9e
MD5 a5d40f4ee2f96e8f8275c3d2b9226264
BLAKE2b-256 19c5af7a3809c26ec704087f3f3f9366d025ecfa26c00b162eeedb5bda028efb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: pyshifty-0.0.13-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 7.0 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.13-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 453ec8a7cc5fef9bf95b1e93ec556fa42b21330c037efb0449da9e701a878266
MD5 60002a42e1deee03f4f7aea8859762e8
BLAKE2b-256 17af791c299ab2e381e5aa226fe3374a6034a9d56c7f350edb500afb96dd805a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 03bf3f6ee5b2dd730c6543ce90b5171fc094096da8e34c6918e78dd22626f7cb
MD5 529acdcc9c40dc26234e93cba64b901b
BLAKE2b-256 db6cc03e27e7254d287efd3067482e4ea4f6dde6507456770b75c11a2ad3512a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 6faac7692272633b371a7f205f01d197fe95fc950fb30dcc9ff28b6fbcea9b8b
MD5 366e0a6d52706b733710b65411a3599f
BLAKE2b-256 cac88fd4832bf95ada0372b704e0707c331234b01914236e798eb0db943ab846

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a73b24f85531a2fdaaf8f7a8053302af143ea216a053015bf83df783a9f7ec9a
MD5 ff928bf9b1814382c5aefeb972e1ac27
BLAKE2b-256 e741936321e13c388e802e2629bdaaf98230330596d1acbeeff5cc33b475b39c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 37ee26293910e045b24bb45dcae77183110f47d258721c67a46099de905e8c21
MD5 e38da5e86a9cc1bdb3ebe139d5000e57
BLAKE2b-256 f99accdc1818a5df4f7331939a128d83f701d71c3142a2a645912ff6ebd794b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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.13-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyshifty-0.0.13-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8d5b17dfa10fee420d8c7398e076c33277aa10c049fde4eeb4767f69c753921f
MD5 a5d8e16ad2f2878e91857b1e99cdce8b
BLAKE2b-256 35b7fc42959c1c069735dee3a2293fa0e249c1a04a1644bebb7f7d3467aaad79

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyshifty-0.0.13-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