Skip to main content

Python bindings for the OntoLogos OWL reasoner — RDFS, OWL RL, and OWL EL classification

Project description

ontologos

PyPI Python Documentation License

Python bindings for OntoLogos — a Rust-native OWL reasoner for RDFS, OWL RL, and OWL EL classification on PyPI 0.9.0. Build from main for DL and SWRL.

Channel: pip install ontologos installs 0.9.0 (EL, RL, RDFS). profile="dl" requires workspace 1.0.0 from main. 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-memoryReasoner(path=...) or Ontology / OntologyBuilder
  • Profiles"rdfs", "rl", "el", "auto" on PyPI 0.9.0; "dl", "dl-preview", "alc", "swrl" on workspace main / 1.0.0
  • 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.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 and reasonable for RL/RDFS. It maps a subset of OWL — not full OWL DL / HermiT replacement.

For engine-only workflows, consider reasonable, whelk-rs, or horned-owl directly.

Links

Resource URL
Python guide readthedocs — Python
Getting started readthedocs
Migration v0.8 → v0.9 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ontologos-1.0.0.tar.gz (406.0 kB view details)

Uploaded Source

Built Distributions

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

ontologos-1.0.0-cp310-abi3-win_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10+Windows ARM64

ontologos-1.0.0-cp310-abi3-win_amd64.whl (2.5 MB view details)

Uploaded CPython 3.10+Windows x86-64

ontologos-1.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

ontologos-1.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

ontologos-1.0.0-cp310-abi3-macosx_11_0_arm64.whl (2.5 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

ontologos-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file ontologos-1.0.0.tar.gz.

File metadata

  • Download URL: ontologos-1.0.0.tar.gz
  • Upload date:
  • Size: 406.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for ontologos-1.0.0.tar.gz
Algorithm Hash digest
SHA256 09cb89a2663adcf854543225fef98ffaf2b812d307e6512b295496831e511c52
MD5 5de2badb87841576f9be40b51f4172eb
BLAKE2b-256 529b744038215f6d46720a95fcb0309556726145eaa33e2cb942a99b84367c67

See more details on using hashes here.

File details

Details for the file ontologos-1.0.0-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for ontologos-1.0.0-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 e57437fde350fea8373132b482c9483eef18db2a78a834e34563daf233764739
MD5 c691f8359793f0fc11566c86e527cc23
BLAKE2b-256 a40806a854ce6ddbe5f8cb4bc58cf0a54643b07f9cc52e11c6c060b4f66f8631

See more details on using hashes here.

File details

Details for the file ontologos-1.0.0-cp310-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for ontologos-1.0.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2e124fe6f7b6b870e2e6705bf3c83d4e06888a280a0eb0acc87c56423e5c9a78
MD5 847f10fc124e08c8c850eb34ea7952d4
BLAKE2b-256 d6ebdcfec6a955a33a811a0e7faa841cccd560dcfb9608144d2d5a99cf97398e

See more details on using hashes here.

File details

Details for the file ontologos-1.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for ontologos-1.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0ec51c98a6d511ae2deedc348ad6001a0da6b62c8f8083d7704ac550b97385c
MD5 6b38c1ca58adb681d3ff7097a3a6c3e8
BLAKE2b-256 6ea69ec7bc8f9f240e6dd3fac3d7c4d9ca249a30768c0a58f6a952c96ef1b5e4

See more details on using hashes here.

File details

Details for the file ontologos-1.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ontologos-1.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b8174b625650242fe53010e9d658cbfe6a2732e475b5a40f9166e44826980ca2
MD5 832697d073c3682e1c6c0b119409c608
BLAKE2b-256 06f33dff7f12f32671e0d12468e0816e3e5952454a87b111688d19986dd3b391

See more details on using hashes here.

File details

Details for the file ontologos-1.0.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for ontologos-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a93678cfb3e620daccefe4ac7163b52ece0d0eff1c8ce303b6868d728149a3d2
MD5 a83310efe3ec6885c92bcc14b2baa41e
BLAKE2b-256 d1155e346e7c67ac6d1575005b184a632d02de8f3c54bf26b4bec3c80726538f

See more details on using hashes here.

File details

Details for the file ontologos-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for ontologos-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c76514b2715a36933972d48fe654210b4a3c5ac8276430caea8342a9fc4b7ba2
MD5 16acb4ef6fd59e42b78fa4f6eb693a88
BLAKE2b-256 117c52c5283330c79751243b1b4e844382fab1aa1b2680da5c6ee44256c1f93e

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