This release is a pre-release and may not be stable for production use.
cimvocabcheck (Python)
Validate SPARQL queries and SHACL shapes against CIM/CGMES schema profiles from Python.
This package is a binding, not an engine. The analysis — SPARQL parsing, the algebra walk, the CGMES profile model, SHACL — is one Apache Jena implementation shared by every consumer, so a finding you get here is the same finding your editor, your CI job and your colleague's .NET service get. What this package adds is finding that engine, building its command line, and giving you its published report as typed Python.
Full documentation: https://opencgmes.soptim.de/cimvocabcheck/python
Install
pip install cimvocabcheck
Python 3.10+. The package has no Python dependencies. It does need an engine to drive — see Finding an engine; the simplest is a JRE 21+ and the CLI fat JAR.
Use it
from cimvocabcheck import validate
report = validate(["queries/line-segments.rq", "shapes/equipment.ttl"], schema="profiles/")
if not report.ok:
for finding in report.errors:
print(finding) # queries/line-segments.rq:3:12: ERROR[UNKNOWN_CLASS] Class …
Findings are data, not exceptions: a file with errors comes back as a report whose ok is
False. Exceptions are reserved for "the engine could not run or could not be trusted".
Validate everything in one call
Loading a CGMES profile set costs about a second; validating one more query after that costs
almost nothing. validate() therefore takes a list:
report = validate(sorted(Path("queries").glob("*.rq")), config="opencgmes.jsonc")
Spawning the engine once per file turns a one-second job into a one-second-per-file job.
validate_file() exists for the genuinely single-file case and simply calls validate().
Reading the report
report.ok # no input has an ERROR
report.summary.errors # counts, matching exactly what this report contains
report.results # one FileResult per input, in the order they were passed
report.errors # flat findings, each carrying the file it came from
report.findings(code=Code.UNKNOWN_CLASS)
report.for_file("queries/line-segments.rq")
report.tool.version # which engine produced this
Each finding carries severity, code, message, and — when the engine could resolve them —
line, column, term, graph and found_in_other_profiles (the "you have the wrong profile
in scope" hint).
Switch on code, never on message. Messages change between releases; codes do not.
from cimvocabcheck import Code
typos = report.findings(code=Code.UNKNOWN_CLASS) + report.findings(code=Code.UNKNOWN_PROPERTY)
Options
validate(
paths,
schema="profiles/", # RDFS file(s) or directories; or …
config="opencgmes.jsonc", # … a config file; or …
endpoint="http://localhost:3030/ds/query", # … a SPARQL endpoint
profiles=["http://iec.ch/TC57/ns/CIM/CoreEquipment-EU/3.0"],
strictness="strict", # permissive | default | strict | pedantic
verbose=True, # include WARN/INFO — the default here, unlike the CLI
cwd="…",
timeout=120,
)
With no schema, config or endpoint, the engine discovers the nearest opencgmes.jsonc above
cwd; without one, it checks syntax only.
Pass inputs as paths relative to cwd. They appear verbatim in the report, and CI annotations
only line up with your source tree when they are repository-relative.
verbose defaults to True here on purpose: a library hands back everything and lets you filter,
rather than discarding findings you cannot then recover. Pass verbose=False for the CLI's
errors-only behaviour.
Finding an engine
validate() discovers one in this order, and the error names every place it looked:
| # | Source | |
|---|---|---|
| 1 | the engine= argument |
a path to a JAR or binary, or an Engine |
| 2 | $CIMVOCABCHECK_JAR, then $CIMVOCABCHECK_BIN |
a fat JAR (run with java), or an executable |
| 3 | cimvocabcheck on PATH |
|
| 4 | docker run ghcr.io/soptim/cimvocabcheck-cli:<tag> |
last resort, with the engine image of the binding's own version: :1.2.0 for 1.2.0, :1.2.0-rc.1 for a release candidate, :edge (built from main) for a development build. Never :latest, which would change the engine under an unchanged binding |
A JAR engine needs a JRE 21 or newer, found via JAVA_HOME or PATH.
A local engine is never started under an ASCII-only locale: when the effective one (LC_ALL,
else LC_CTYPE, else LANG) is C, POSIX or unset, as in many containers and CI images, the
engine gets C.UTF-8 so it can open non-ASCII file names. It does too when a locale the
environment names is not installed (LANG=en_US.UTF-8 without the locale package, going by
locale -a): the C library then falls back to C for every category, so the engine gets
LC_ALL=C.UTF-8.
The Docker fallback mounts the working directory at the image's /work and passes inputs inside
it relative to it. Everything else it has to read is mounted read-only at /host followed by its
host path, and results still come back under the names you passed:
- an input, schema or config file outside the working directory, so a batch behaves as it does
with a local engine. An input that does not exist is passed on and reported as
UNREADABLE_INPUT; - an
opencgmes.jsoncabove the working directory, which is then passed as--configunless the call names its own schema source, so a run from a subdirectory sees the same config a local engine would; - the schema paths a config names, wherever they lead, so its relative paths work as they do on
the host. One that would land on a directory of the image itself (
../usr, from a config in the working directory) is refused.
Set CIMVOCABCHECK_DOCKER_IMAGE to pin a tag, or CIMVOCABCHECK_NO_DOCKER=1 to take it out of the
chain. Note that the first run pulls the image, and that an endpoint on localhost is the
container's localhost, not yours.
python -m cimvocabcheck --print-engine # which engine would be used here
Errors
| Exception | When |
|---|---|
EngineNotFoundError |
nothing to run; the message lists everywhere that was searched |
ToolError |
the engine reported a usage/config failure (exit 2), or failed outright |
ReportParseError |
output was not a report of the contract major this binding targets |
EngineTimeoutError |
timeout elapsed |
UnreachablePathError |
a path the Docker engine cannot reach: a schema or config outside the working directory that does not exist, a Windows path a config names, one that would land on a directory of the image itself, or (command line only) init --dir outside the working directory |
ToolError carries argv, returncode, stdout and stderr, so a CI log can show what
actually happened.
Command line
Installing the package puts a cimvocabcheck command on your PATH that forwards to whichever
engine it discovers — same flags, same output formats, same exit codes (0 clean, 1 findings,
2 usage). python -m cimvocabcheck does the same.
With the Docker engine the command rewrites the paths it is given the way the library does: a
config, schema or input outside the working directory is mounted. init --dir outside it is
refused, because the engine writes there and the mounts are read-only.
cimvocabcheck --schema profiles/ -f sarif queries/*.rq > cimvocabcheck.sarif
pre-commit
repos:
- repo: local
hooks:
- id: cimvocabcheck
name: CIMVocabCheck
entry: cimvocabcheck
language: python
additional_dependencies: ["cimvocabcheck"]
files: \.(rq|sparql|ttl|shacl)$
require_serial: true
require_serial matters: without it pre-commit splits the files across processes and each one
reloads the profile set.
Versioning and compatibility
This package tracks the engine it was generated against (1.2.x binding ↔ 1.2.x engine) and
accepts any engine declaring the same report contract major. Within a major the contract only
ever adds — new optional fields, new rule codes, new output formats — so the binding:
- keeps fields it does not know in
extrarather than dropping them, and - accepts codes it does not know (
annotation.is_known_codetells you), because the contract requires an unrecognised code to be treated as a generic finding, never as an error.
The contract itself is documented at https://opencgmes.soptim.de/cimvocabcheck/report-contract.
Developing
The result model is generated from the published JSON Schema by a generator shared with the
.NET and Rust bindings — edit the generator, not the model. Convenience methods live in
_ergonomics.py and survive regeneration.
python3 ../codegen/generate_models.py --target python # after a contract change
python3 ../codegen/generate_models.py --target python --check # what CI runs
python -m pytest # engine-backed tests skip when no engine is found
# Against a locally built engine (mvn -pl cimvocabcheck/cli -am package, from the repo root).
# The glob must expand before the assignment, and an absolute path survives a cwd change.
export CIMVOCABCHECK_JAR="$(ls "$PWD"/../../cli/target/cimvocabcheck-cli-*.jar)"
CIMVOCABCHECK_TESTS_REQUIRE_ENGINE=1 python -m pytest # fails, rather than skips, without the engine
License
Apache-2.0 — see LICENSE.
Metadata
Release files for cimvocabcheck 1.3.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cimvocabcheck-1.3.0rc1.tar.gz | 52.1 kB | With provenance | Details for cimvocabcheck-1.3.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cimvocabcheck-1.3.0rc1-py3-none-any.whl | Python 3 | none | any | Details for cimvocabcheck-1.3.0rc1-py3-none-any.whl |
Total release size: 96.3 kB
Release files / cimvocabcheck-1.3.0rc1.tar.gz
| Download URL | cimvocabcheck-1.3.0rc1.tar.gz |
|---|---|
| Size | 52.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7956a64220c854783d38cac43d7788c085009185d24d0d2bab09bbfd3d1ca497
|
|
BLAKE2b-256 checksum How to use checksums |
54fd7c95f21cfc1935bf82248c4698b6066b156b42d4f381e1f474f4fec9f5ae
|
| 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 Nov 24, 2026.
Transparency logRelease files / cimvocabcheck-1.3.0rc1-py3-none-any.whl
| Download URL | cimvocabcheck-1.3.0rc1-py3-none-any.whl |
|---|---|
| Size | 44.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
26491b7955316fbc0cf9fb1371d71b35f29ae6f11135fc8a45362e86cd35a065
|
|
BLAKE2b-256 checksum How to use checksums |
0514d982a3aa62b96e1ff303c09577981e3917e4c4792c62cbb8a930f44269fa
|
| 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 Nov 24, 2026.
Transparency logSecurity for cimvocabcheck 1.3.0rc1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for cimvocabcheck-1.3.0rc1.tar.gz
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 Nov 24, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.