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.11.tar.gz (412.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.11-cp313-cp313t-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.13tWindows x86-64

pyshifty-0.0.11-cp313-cp313t-musllinux_1_2_x86_64.whl (97.0 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ x86-64

pyshifty-0.0.11-cp313-cp313t-musllinux_1_2_aarch64.whl (96.0 MB view details)

Uploaded CPython 3.13tmusllinux: musl 1.2+ ARM64

pyshifty-0.0.11-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (97.3 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ x86-64

pyshifty-0.0.11-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.4 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ ARM64

pyshifty-0.0.11-cp313-cp313t-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.13tmacOS 11.0+ ARM64

pyshifty-0.0.11-cp311-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.11+Windows x86-64

pyshifty-0.0.11-cp311-abi3-musllinux_1_2_x86_64.whl (96.9 MB view details)

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

pyshifty-0.0.11-cp311-abi3-musllinux_1_2_aarch64.whl (96.0 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

pyshifty-0.0.11-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (97.2 MB view details)

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

pyshifty-0.0.11-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (96.3 MB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

pyshifty-0.0.11-cp311-abi3-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: pyshifty-0.0.11.tar.gz
  • Upload date:
  • Size: 412.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.11.tar.gz
Algorithm Hash digest
SHA256 18591dadfb06d99c16d3158813ffd947a9527cfd7eb52496489df772489a5a9e
MD5 ac3d739e7a5323655fcd1d018404a13e
BLAKE2b-256 575aa106e4271b29665913fafafaf647db973c1c09bc5a9f9b0a8e6387df6ed4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyshifty-0.0.11-cp313-cp313t-win_amd64.whl
  • Upload date:
  • Size: 6.9 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.11-cp313-cp313t-win_amd64.whl
Algorithm Hash digest
SHA256 9db651c67f665daa58c7002431c8e6a78856893446ce69cbc05e1aecb6a48f5e
MD5 9c2d81861b89f213277ca98f54daba3c
BLAKE2b-256 ea3ebbda88be3250f063415a8ea647762121f62aead82d45fb65c10c2652a422

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp313-cp313t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 78e224a17090958376ee43aa6ff41b29817f7d9828dcfe24488f743806f16b9a
MD5 b15d06b6464c7214f31ee34a15782f15
BLAKE2b-256 3409ba563797e4b5a56f394bfae070b5be2ba1375b053629e3ec3d05a461b15c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp313-cp313t-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 9df0e9ee06fcae6834a4655641d0915df6e752772b93bcca6eacf66713e8b743
MD5 02c1d769796318c6b4be246ead21e696
BLAKE2b-256 782e9c508facd9cd626a0b37018069295457d9b2f0493987252b2b5aa3bb4e3d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a1e3a4cc724cadc2864bb497847e8e9c0231a273600dcc1bb9eb587040b08f32
MD5 128b775bfba17991a697ac643118dcdd
BLAKE2b-256 8b7c314f389c2510d490adf5e386c3e0ed1ab9bca7767ac054b0b924525b9de7

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e959aa4f6b2d357a67e82d3ba389d6805d3adfd1aba2de205013787f2fd630c7
MD5 3daa1e26f22b994b150cf51a5ec964e7
BLAKE2b-256 308f019368c2f5a72370e3ee6f5dc0033dc3da832a6c955affe575b265b9fa6e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp313-cp313t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fabcff0389396a78c53a4e1a446238bffc51add3e6b5f4bef6878f4ddc25f511
MD5 314c1e72d7b38e914f15883042032fa6
BLAKE2b-256 3b3cc339b78ff33dcde7461594ecbe6c8cd4d759653f45de694cb463dbd954b1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyshifty-0.0.11-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 6.9 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.11-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 64412cf1882ed36ad707152944c65e74617faf92e9f62da33c2336fe83e97701
MD5 7b9ab1a8a41e44ec8a734afeaacf1bd1
BLAKE2b-256 ec8617a20243e773d54b6528d2043f386c80c21f2e91656be1601d7a07ae1a8f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9131dd0a72940234b19d116f088f959e19fa0388ecee3392313566ba3f9eac4c
MD5 17a3bcb704527ef63b4cd6565e21d80c
BLAKE2b-256 3948624cf888ce6f00b25fd1a28ac7f79c04b61571181c28f270855a020d07d2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a44305cdb98555a6582a3c06a37089eaaeb6157a251be84ce80d1aa4a5e47ee6
MD5 7b472ba7bdc56c717fbeaa692fb9e4be
BLAKE2b-256 64c7011d95d52b8da6565233cbb9bb581735768c2f2c918d2a33c5efb0253ed6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd41ee3ed30d8a49de44906905561ba68e10ee9c1860991b1dce8739e0cf90a6
MD5 c931a2551e72bd3bcb9641fa28b9c553
BLAKE2b-256 318a0cea921033e77872e8de781489083469991c02a8344d7ba40c6593482561

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 301c0a66d70cb2a59ac06a6252e42c54b131f1420c5a8dda826105b116bb1897
MD5 ffa34cd1de5a845aaa6ab824632c5dd1
BLAKE2b-256 1d0608243c88ab7431407d6c50d83e3d7010f1833853c788aff30d71e48a40e5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pyshifty-0.0.11-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fd2e23bfc8e52c37bd0800ba4eea780ebefe1703ab7f680759a68410a2bcaf33
MD5 286cb44b93e5eb380d5bd919ef53e556
BLAKE2b-256 cdab347cfa7443ca91ec8b4fef5d887b6a0600cf503adf2c428f5e0b8300af93

See more details on using hashes here.

Provenance

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