Python bindings for the OntoLogos OWL reasoner — RDFS, OWL RL, and OWL EL classification
Project description
ontologos
Python bindings for OntoLogos — a Rust-native OWL reasoner for RDFS, OWL RL, OWL EL, OWL 2 DL, and SWRL on PyPI 1.0.0.
Install:
pip install ontologos(v1.0.0). Production profiles:rdfs,rl,el,auto,dl,swrl. Preview:alc,dl-preview. See Profile stability.
Load .owl / .ttl files or build ontologies in memory, run the same profile engines as the CLI, and export taxonomies to pandas or Polars. Powered by PyO3 and the stable Python ABI (abi3).
Full guide: ontologos.readthedocs.io — Python
Features
- File or in-memory —
Reasoner(path=...)orOntology/OntologyBuilder - Profiles —
"rdfs","rl","el","auto","dl","swrl"on PyPI 1.0.0;"dl-preview","alc"are preview - Classify — RDFS/RL materialization reports or EL taxonomy dicts
- Explain — proof graph dicts with IRI-resolved conclusions (EL full traces)
- Incremental — multi-pass
add_subclass_of/remove_subclass_ofwithincremental=True - Export — optional
subsumptions_to_pandas/subsumptions_to_polars
Install
Requires Python 3.10+.
pip install ontologos
Optional DataFrame helpers:
pip install 'ontologos[pandas]'
pip install 'ontologos[polars]'
Pre-built wheels are published for:
| OS | Architectures |
|---|---|
| Linux | x86_64, aarch64 (manylinux) |
| macOS | x86_64, aarch64 |
| Windows | x64, aarch64 |
One abi3 wheel per platform covers Python 3.10–3.13+. If no wheel matches, build from source (Rust + maturin).
Quick start
Download Pizza for EL examples (from a clone: ./benchmarks/scripts/download.sh at repo root):
# From repository clone only:
./benchmarks/scripts/download.sh
Classify an OWL file
import ontologos
# OWL EL taxonomy
reasoner = ontologos.Reasoner(path="pizza.owl", profile="el")
taxonomy = reasoner.classify()
print(taxonomy["subsumption_count"], taxonomy["subsumptions"][:3])
# RDFS materialization
reasoner = ontologos.Reasoner(path="ontology.owl", profile="rdfs")
report = reasoner.classify()
print(report["inferred_axioms"])
# Auto-detect profile (EL or RL)
reasoner = ontologos.Reasoner(path="ontology.owl", profile="auto")
result = reasoner.classify()
Build in memory
from ontologos import OntologyBuilder, Reasoner
builder = OntologyBuilder()
builder.add_class("http://example.org/A")
builder.add_class("http://example.org/B")
builder.subclass_of("http://example.org/A", "http://example.org/B")
ontology = builder.build()
reasoner = Reasoner(ontology=ontology, profile="el")
taxonomy = reasoner.classify()
Load from JSON dict instead of the builder (v2 or v3; writers on workspace 1.0.0 emit v3):
from ontologos import Ontology, Reasoner
ontology = Ontology.from_dict({
"format_version": 2,
"entities": [
{"iri": "http://example.org/A", "kind": "Class"},
{"iri": "http://example.org/B", "kind": "Class"},
],
"axioms": [
{"SubClassOf": {
"subclass": "http://example.org/A",
"superclass": "http://example.org/B",
}}
],
})
reasoner = Reasoner(ontology=ontology, profile="el")
reasoner.classify()
Incremental edits
reasoner = Reasoner(ontology=ontology, profile="el", incremental=True)
reasoner.classify()
reasoner.add_subclass_of("http://example.org/B", "http://example.org/C")
reasoner.classify() # re-classify with warm session
reasoner.remove_subclass_of("http://example.org/A", "http://example.org/B")
reasoner.classify()
Explain inferences
graph = reasoner.explain()
print(graph["node_count"])
for node in graph["nodes"][:5]:
print(node["rule"], node.get("conclusion_sub"))
| Profile | Explain coverage |
|---|---|
| EL | Full inference traces |
| RL / RDFS | Asserted axioms seeded; inferred steps lack per-rule premises until upstream exposes traces |
| auto | Routes like classify |
Export to DataFrame
from ontologos import subsumptions_to_pandas
df = subsumptions_to_pandas(taxonomy)
# columns: subclass, superclass
API overview
| Type / method | Description |
|---|---|
Reasoner(path=..., profile=..., incremental=False) |
Load OWL file and classify |
Reasoner(ontology=..., ...) |
Classify in-memory ontology |
reasoner.classify() |
Run engine; returns taxonomy or materialization dict |
reasoner.explain() |
Proof graph dict (node_count, nodes, parse_meta) |
reasoner.taxonomy |
Last EL taxonomy (after classify) |
reasoner.parse_meta |
Parser warnings and axiom counts |
reasoner.add_subclass_of / remove_subclass_of |
Incremental axiom edits |
reasoner.add_axiom_json |
Add axiom via JSON object (v2/v3 shape) |
Ontology.from_json / from_dict |
Load JSON snapshot (v2 or v3) |
OntologyBuilder |
Fluent builder → build() |
subsumptions_to_pandas / subsumptions_to_polars |
Optional taxonomy export |
Invalid profiles and unsupported constructs raise RuntimeError with a message string.
Reasoner is not thread-safe — do not mutate from multiple threads.
Development
From a repository clone:
cd crates/ontologos-py
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install 'maturin>=1.7,<2.0' pytest '.[pandas]'
maturin develop --release
pytest tests/ -q
Pizza EL golden test (requires corpus):
./benchmarks/scripts/download.sh # from repo root
pytest tests/test_pizza_golden.py -q
What OntoLogos is (and is not)
OntoLogos is an orchestration layer: profile detection, a unified ontology model, CLI, Python wheels, and security limits on top of in-house EL, ontologos-dl for OWL 2 DL, and reasonable for RL/RDFS. It maps a subset of OWL — validate on your corpus before production cutover.
For engine-only workflows, consider reasonable, whelk-rs, or horned-owl directly.
Links
| Resource | URL |
|---|---|
| Python guide | readthedocs — Python |
| Getting started | readthedocs |
| Migration v0.9 → v1.0 | migration guide |
| Repository | github.com/eddiethedean/ontologos |
| Rust crates | crates.io — ontologos-core |
| Changelog | CHANGELOG.md |
License
Licensed under either of Apache-2.0 or MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ontologos-1.0.1.tar.gz.
File metadata
- Download URL: ontologos-1.0.1.tar.gz
- Upload date:
- Size: 406.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f09f9c35ec5f62ccd23be4f53cc14355825378f67bda0b6ba598000d3f3835d4
|
|
| MD5 |
f883a79c0d428c48b10cfea7979b9d64
|
|
| BLAKE2b-256 |
2ef13f35027f80aa25690977e1ac9227d7f07b99b88c3b4a22a6aeb67f51c410
|
File details
Details for the file ontologos-1.0.1-cp310-abi3-win_arm64.whl.
File metadata
- Download URL: ontologos-1.0.1-cp310-abi3-win_arm64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.10+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28d2905923a78e2672b65559a6646bf81cc5d6f12a29afe7a4f392cef4dfc423
|
|
| MD5 |
491c8050715a042184dfaafcbdecc70a
|
|
| BLAKE2b-256 |
6eeebfe51a08de23bba8b5b97f7c9d79dfe10722eda510c3ac02f63d7147f226
|
File details
Details for the file ontologos-1.0.1-cp310-abi3-win_amd64.whl.
File metadata
- Download URL: ontologos-1.0.1-cp310-abi3-win_amd64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab21205b98f34b7f2cfe6c4603650f5116c1a4836d0492d7d4ef573c5ac90b53
|
|
| MD5 |
18a48c3fcd06d1e44be4c00c6c858f61
|
|
| BLAKE2b-256 |
a889ff90f6ee619f63505f3bfa5ec9b48f7dd4cc4b502e824acbe940da6b9698
|
File details
Details for the file ontologos-1.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: ontologos-1.0.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
216c302a99e8297ecdcef775e618d3e8f41a94805731e877a172bea20fbf9376
|
|
| MD5 |
27641e38b8e8fea0bd3e605509f862e3
|
|
| BLAKE2b-256 |
658812bca6f5412388430a6d2394d848a430e2225b0fe4c705d03d5906467252
|
File details
Details for the file ontologos-1.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: ontologos-1.0.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.10+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
def6c7c362d55e3fc80564be9a68ef709037e15d1792da7ce98009d9341e3862
|
|
| MD5 |
8719c12977ae6a6294cfc9f781e672a9
|
|
| BLAKE2b-256 |
bc04ccd9baeb9d4aec26ac3af5419fd01dc2ea01c2cac81329969f166f346946
|
File details
Details for the file ontologos-1.0.1-cp310-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ontologos-1.0.1-cp310-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.5 MB
- Tags: CPython 3.10+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b363292cd59823c671d641ca3d067f338b39fbc4d66551f1fee5b7bcd8ae79d5
|
|
| MD5 |
ab21181e673a6d62318fc3b4b33494d5
|
|
| BLAKE2b-256 |
5371c96c2d054c5e15dd06466ae43a59fba03443440c4ed2c924ac162ad089f0
|
File details
Details for the file ontologos-1.0.1-cp310-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: ontologos-1.0.1-cp310-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.10+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8f0d39b9c7ddd03e767990fbe03e97d2b28bb0d291c2c7d39f180405871d11c
|
|
| MD5 |
48b96feb74470147613dcbb4eed62c56
|
|
| BLAKE2b-256 |
2f383d7374f453e4bf0e12f463ba9f905284e2f95d26e69b1f24fe00f4127f8d
|