OntoEnv

An environment manager for RDF ontologies. Point it at some files or URLs and it resolves every owl:imports for you — from the command line, Python, or Rust.
crates.io PyPI docs.rs GitHub License
pip install ontoenv    cargo install ontoenv-cli

Overview

OntoEnv is a tool for managing knowledge graphs, ontologies, and their interdependencies. It is designed to handle the part you would otherwise do by hand: an ontology declares owl:imports, those imports declare their own, and before long a single file needs a dozen others — some local, some on the web, some moved or renamed since they were published.

OntoEnv keeps an environment: a directory of ontologies it has discovered, plus everything it learned about them — canonical names, source locations, namespace prefixes, and the import graph connecting them. Ask for one ontology and you can get its complete imports closure as a single graph, in milliseconds, without re-parsing anything.

The minimum you need to know

Point OntoEnv at a directory, then ask for a closure. That is the whole idea.

$ pip install ontoenv
$ ontoenv init ./ontologies                              # build the environment
$ ontoenv closure https://example.org/site closure.ttl   # export IRI + its imports

The same thing from Python:

from ontoenv import OntoEnv

env = OntoEnv.connect("./ontology-env", search_directories=["./ontologies"])
env.update()

view, imported = env.get_closure("https://example.org/site")
print(f"{len(imported)} graphs, {len(view)} triples")

Two rules explain most of the rest of the API: connect opens an environment but never reads your files — update does that, explicitly. And get_* returns a fast read-only view, while copy_* returns a mutable rdflib graph.

Where to go next

What you get

  • Import resolution — follows owl:imports to fetch and cache every transitive dependency, local or remote.

  • A queryable dependency graph — ask for a closure, find every importer of an ontology, or detect cycles.

  • Fast restarts — the environment is stored in a compact binary format and reopens in milliseconds without re-parsing RDF.

  • Read-only views — query a 200k-triple closure through SPARQL without materializing it in memory.

  • Three front ends — a CLI, Python bindings with native rdflib interop, and the underlying Rust crate.

Upgrading

Coming from 0.5? Migrating from 0.5 to 0.6 lists the API changes you need to make. The full release history is in the Changelog.


Need a plain-text snapshot for LLM ingestion? Grab llms.txt.