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

Uploaded CPython 3.13tWindows x86-64

pyshifty-0.0.12-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.12-cp313-cp313t-musllinux_1_2_aarch64.whl (96.6 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyshifty-0.0.12-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (97.9 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ x86-64

pyshifty-0.0.12-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.9 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.13tmacOS 11.0+ ARM64

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

Uploaded CPython 3.11+Windows x86-64

pyshifty-0.0.12-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.12-cp311-abi3-musllinux_1_2_aarch64.whl (96.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

pyshifty-0.0.12-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.12-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.8 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

pyshifty-0.0.12-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.12.tar.gz.

File metadata

  • Download URL: pyshifty-0.0.12.tar.gz
  • Upload date:
  • Size: 429.8 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.12.tar.gz
Algorithm Hash digest
SHA256 e7654f170db69f551311bef3d578286d7aa500cb46972e64d1900a96ada98b64
MD5 afd14e40eb358d2a0ab29754d7914703
BLAKE2b-256 992ed6f0a400369d9527427354db5e19e8eabbbb25d8f83e861ff32afabb05a9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyshifty-0.0.12-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.12-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 776c958933c91ca96eb52b0b0846827820e1f36f195ea95e6fd7d3aed68178ce
MD5 cf342cd3efc9301c198cff5d94bb5d9c
BLAKE2b-256 7c44f79c889f5c90030312d3aba75df38944fc08763ac8e151c311819ece0c11

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4a9dd61a7b28714b85bbbbe894fe826a5645c11696d483f235f7ef16091c9e58
MD5 7593d102d6a8dac00534131e8d2b1b5e
BLAKE2b-256 fd02ad14fb61f9345d1a67df8d0dff622c2a42f759f64a4bd660d46560536d08

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 40854ef6145e2db15ded4785aac6409e99b6e1740c6bfe82f351c0a9ec974bba
MD5 df9498dba01a0bcdbbf023e8b0713c24
BLAKE2b-256 6e7f9a1ebc0219b246993e442156c65fa920b16d32d9d602684f0135656fb164

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7fee5f66f0eb738f2e817efbe3089e018aa8105ae61583f9871a3cb913436a1b
MD5 e21bab33677895522bdb0719c42d540e
BLAKE2b-256 68628dd3a39953dc55adbf6d41c2d0248d5785d086cd89bc4357abb91f5da23a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3d46bdf8f455bd20e571f24a8e0c9bf506ec6f056b7e0c94977f638bae5334da
MD5 3e057e0ffdbe45de7422daee7a2738fd
BLAKE2b-256 c9a0464c302937717a3df944312e85a66c381247b39bd80468ceb6502472da0c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fee5f25cd40dbc7e64fe2d707c63623acf26d6daf54de4a96d9807d2b50a3aa5
MD5 d4e8c3799130304a2e43f1d47999a2e7
BLAKE2b-256 7fa10d5a911d73b30b18bb8f663f287cb21fc8ddc1aa97167d0af5235a96b66b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyshifty-0.0.12-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.12-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ecbbc84c60d0069201bf29cb473dc33ab3d16fb92207fd0e28189d60e0d91609
MD5 86a3357ef8c622b534182d5fb39c15d9
BLAKE2b-256 bd8dc43039d52b2a726d9d10f86784ad5ea0da8fca75ecfb6304761497980a42

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0fc6b993bcae3f8f49affe040b484ad8c24810ebb125f6b085cd9e479fc6e7fa
MD5 9e7a4c2724db190eecafdd879b6a39d9
BLAKE2b-256 627f23c15209051b75050495d93bd01a1aa043ca77ab93f1e6f1ca146dd84fd8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 94f025a38a39ec288daa2e9bf9506eec195c1d4afc9afb1f42ef7c4d61784e9f
MD5 889a9838dbede324d1600d915acebbef
BLAKE2b-256 abc37a0432bff0970b1ac743d40ccedcbdb9d282357aac5bb47d8a09fe1acfc8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0a6deefeac0691344f7458d313058d5ae7dd2c12f8e7408dcbc71d8b42bf114b
MD5 2ff056a417647cbe9f24cf3590835a14
BLAKE2b-256 8b59025773cd3e20579181e3913a09802d3373ce1c8a8c5fdbdd41bf3bb36886

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 53787e5a00436c1aa7ea930825ab388b682a17f67afecf76338b264082d6fd6b
MD5 19bb2a1d7254a45da9fb9a2dd56d7b33
BLAKE2b-256 b2da2d763e9475d32fbe759a0f2f3a2a67d75e2ed97f4f10f9022eceec140b19

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.12-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76d9159a04f754d3f83e831f244bd66514cdb23bb6115d0573d548e58682e383
MD5 87c6acff67b5d37eeebd56373d18e0a7
BLAKE2b-256 3788a3a6471127863ba6d0372f5f0207402bd97b64ba29f09428ce8497eef763

See more details on using hashes here.

Provenance

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