Skip to main content

Python library providing RDF ontology definitions for SysML.

Project description

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

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

py_mmut_rdf-0.0.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_mmut_rdf-0.0.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file py_mmut_rdf-0.0.3.tar.gz.

File metadata

  • Download URL: py_mmut_rdf-0.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/6.17.0-1010-azure

File hashes

Hashes for py_mmut_rdf-0.0.3.tar.gz
Algorithm Hash digest
SHA256 317a483ae1d07f3fdd6319bf89bcde12aca3326985a84185a316fced7c497fb8
MD5 97eb471b1e30352bc5b9395472384fa2
BLAKE2b-256 bc4936ef30bdc1e328337b23d57311951b2a3da6b0b4813b1e9fede4970c5b73

See more details on using hashes here.

File details

Details for the file py_mmut_rdf-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: py_mmut_rdf-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.13.13 Linux/6.17.0-1010-azure

File hashes

Hashes for py_mmut_rdf-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 30a0ed5156853a89f9ad753050813b51b7b4e8e5fc185afc94951e85fd8a0769
MD5 e5bf1c9cfc047a3e23d8ee5c5d12acc0
BLAKE2b-256 c2f13be401094be5a4e7a7dbfbf061ebf7618f80ec5bc0b5a5a571cfaac96cbe

See more details on using hashes here.

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