Skip to main content

py-mmut-rdf

A Python library providing RDF ontology definitions for MMUT (MicroModel and Transformations). This library contains a generated TTL (Turtle) file with MMUT ontology definitions and provides a convenient Python interface to access the ontology classes and properties.

Ontology Visualization

Visualized the ontology with WebVOWL

SysML Ontology

Installation

See: https://pypi.org/project/py_mmut_rdf/

pip install py-mmut-rdf

Usage

from py_mmut_rdf import MMUT
from rdflib import URIRef, Graph, RDF

g = Graph()
g.bind("mmut", MMUT._NS)
g.add((URIRef("http://example.org#model_x"), RDF.type, MMUT.RDFMicroModel))

SHACL Validation in Python

from importlib.resources import files
from pyshacl import validate
from rdflib import Graph

data_graph = Graph()
# data_graph.parse("path/to/your-model.ttl", format="turtle")

shapes_path = files("py_mmut_rdf").joinpath("mmut-shapes.ttl")
conforms, report_graph, report_text = validate(
	data_graph=data_graph,
	shacl_graph=str(shapes_path),
)

print(conforms)
print(report_text)

SHACL Validation

The library includes SHACL shapes in py_mmut_rdf/mmut-shapes.ttl.

Install pySHACL if needed:

pip install pyshacl

1. Loop Example (should fail)

pyshacl -s py_mmut_rdf/mmut-shapes.ttl path/to/test-loop.ttl -f human

Expected result: Conforms: False

2. Real MMUT Example

pyshacl -s py_mmut_rdf/mmut-shapes.ttl path/to/mmut-squirrl.ttl -f human

Tip: add -d for verbose diagnostics.

Development

Regenerating the Ontology

If you need to recreate the TTL file:

python create_mmut_ontology.py

Testing

Run the test script to verify everything works:

python -m pytest tests/

Building the Package

poetry build

Publish the Package

poetry publish --username __token__ --password <TOKEN>

Versioning via Git Tags

The package version is derived automatically from Git tags during build/release.

Use semantic version tags, e.g.:

git tag v0.0.3
git push origin v0.0.3

In GitHub Actions, the workflow fetches tags and builds the package with the tag-derived version.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Metadata

Release files for py_mmut_rdf 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py_mmut_rdf 0.0.3
File Size Uploaded
py_mmut_rdf-0.0.3.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py_mmut_rdf 0.0.3
File Interpreter ABI Platform
py_mmut_rdf-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / py_mmut_rdf-0.0.3.tar.gz

Download URL py_mmut_rdf-0.0.3.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
317a483ae1d07f3fdd6319bf89bcde12aca3326985a84185a316fced7c497fb8
BLAKE2b-256 checksum
How to use checksums
bc4936ef30bdc1e328337b23d57311951b2a3da6b0b4813b1e9fede4970c5b73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.13.13 Linux/6.17.0-1010-azure

Release files / py_mmut_rdf-0.0.3-py3-none-any.whl

Download URL py_mmut_rdf-0.0.3-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30a0ed5156853a89f9ad753050813b51b7b4e8e5fc185afc94951e85fd8a0769
BLAKE2b-256 checksum
How to use checksums
c2f13be401094be5a4e7a7dbfbf061ebf7618f80ec5bc0b5a5a571cfaac96cbe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.3.4 CPython/3.13.13 Linux/6.17.0-1010-azure

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page