OntoEnv

crates.io PyPI docs.rs GitHub License
pip install ontoenv    cargo install ontoenv-cli

An owl:imports statement gives you an IRI. It does not tell you which file to open. The ontology may live in a local checkout, at a URL, behind an alias, or nowhere you can currently reach.

OntoEnv is a library and command-line tool that maps ontology IRIs to the files or URLs where their RDF graphs can be found. It follows owl:imports to build a dependency graph, then saves the graphs and their mappings in an environment. Reopening that environment reads the saved catalog instead of parsing every source again.

Basic workflow

Scan a directory once. Then ask for an ontology by IRI:

$ 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 distinctions explain most of the API:

  • connect opens saved state. update reads ontology sources.

  • get_* returns a read-only view. copy_* allocates a mutable rdflib graph.

These names distinguish catalog access from source access, and views from allocated copies.

Where to go next

What OntoEnv saves

  • RDF graphs from local files and remote URLs.

  • Canonical ontology IRIs, aliases, source locations, and namespace prefixes.

  • Direct and transitive owl:imports relationships, including missing imports and cycles.

  • A catalog that can be reopened without parsing every stored graph.

The same environment is available through the CLI, Python bindings with rdflib interoperability, and the 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.