Skip to main content

ontologos

PyPI Python Documentation License

Python bindings for OntoLogos — a Rust-native OWL reasoner for RDFS, OWL RL, OWL EL, OWL 2 DL, and SWRL on PyPI (1.1.4 published).

Install: pip install ontologos. Production profiles: rdfs, rl, el, auto, dl, swrl. Preview: alc, dl-preview. See Release status and 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-memoryReasoner(path=...) or Ontology / OntologyBuilder
  • Profiles"rdfs", "rl", "el", "auto", "dl", "swrl" on PyPI; "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_of with incremental=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.1.4 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.

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.

Release files for ontologos 1.1.4

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

Source distribution (sdist)

Source distribution for ontologos 1.1.4
File Size Uploaded
ontologos-1.1.4.tar.gz 427.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for ontologos 1.1.4
File
ontologos-1.1.4-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
ontologos-1.1.4-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
ontologos-1.1.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
ontologos-1.1.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
ontologos-1.1.4-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
ontologos-1.1.4-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 16.6 MB

Release files / ontologos-1.1.4.tar.gz

Download URL ontologos-1.1.4.tar.gz
Size 427.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6fae8d1bde3b46ad014ccc96a9fb9475dd9a178157e575835e21a9338c50cbc6
BLAKE2b-256 checksum
How to use checksums
216f3044c3414606a7061d1dea55d1eae11450584a6b482e2a4e924494912c5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / ontologos-1.1.4-cp310-abi3-win_arm64.whl

Download URL ontologos-1.1.4-cp310-abi3-win_arm64.whl
Size 2.4 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
a70769a4df47ed3546bce76b2be5991db061fa815333d9ffbbd7dd04f782f8f7
BLAKE2b-256 checksum
How to use checksums
1d21a0025f2f29c577aa7e5b083950e8e0d88b934381bc53af11c0e58011d742
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / ontologos-1.1.4-cp310-abi3-win_amd64.whl

Download URL ontologos-1.1.4-cp310-abi3-win_amd64.whl
Size 2.7 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d32636d015a353008565e097b1769b2bbcf1058ddfbd07ccc7e005eed67c1889
BLAKE2b-256 checksum
How to use checksums
c969a570b0ee2075d88b9fb23e502a465a49272595ddb3894d80787edbe68a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / ontologos-1.1.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL ontologos-1.1.4-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 2.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
a68a7a68f97138442d6023da199e923d0c3b38502271e91a16edf327af4dd839
BLAKE2b-256 checksum
How to use checksums
bc10bae019f639a87d62b03b842ff26952f8a6008f6d2376ed2d5a9d66fd1de2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / ontologos-1.1.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL ontologos-1.1.4-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 2.8 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
18f57add13f967c622d9ce63f530821a3e6a0aad8f7e495223ab0d9d5f23d2c5
BLAKE2b-256 checksum
How to use checksums
91b6bfc87d8319efff4eccbf38154195ee0c8715d659f5d4f5a599a05f796f11
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / ontologos-1.1.4-cp310-abi3-macosx_11_0_arm64.whl

Download URL ontologos-1.1.4-cp310-abi3-macosx_11_0_arm64.whl
Size 2.6 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d56a889b45807f33758a21c5fadf0d09d48dce3f5ff0acc8cd887103d7ccbaf8
BLAKE2b-256 checksum
How to use checksums
82f864bd6d3d1ee56f735b6c554ab2b63ee00ceb15cac7fb480b7e35e0fa9ca5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / ontologos-1.1.4-cp310-abi3-macosx_10_12_x86_64.whl

Download URL ontologos-1.1.4-cp310-abi3-macosx_10_12_x86_64.whl
Size 2.7 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
df6b0252730bc5a51bd6df5b272687e7cd40abc77f079b3cf83509ddf44f920e
BLAKE2b-256 checksum
How to use checksums
2e1cbb8b6fc2aff8340b4e3f750269848965b65b3edc6e5eadf6822f467d7319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release history Release notifications | RSS feed

This release

1.1.4 This release

7 release files

1.1.3

7 release files

1.1.2

7 release files

1.1.1

7 release files

1.1.0

7 release files

1.0.1

7 release files

1.0.0

7 release files

0.9.0

7 release files

0.8.0

7 release files

0.7.0

7 release files

0.6.1

7 release files

0.6.0

7 release files

0.5.0

7 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

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