OntoEnv¶
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:
connectopens saved state.updatereads ontology sources.get_*returns a read-only view.copy_*allocates a mutablerdflibgraph.
These names distinguish catalog access from source access, and views from allocated copies.
Where to go next¶
Tutorials
Build a small environment and inspect an import closure, from the CLI or Python.
Work through an example →How-to guides
Specific tasks: constrain discovery, work offline, run a service, attach storage, or recover after an interrupted write.
Find a procedure →Reference
CLI commands, Python methods, configuration keys, and storage interfaces.
Consult the reference →Explanation
Design constraints and trade-offs: closure transformations, lifecycle choices, views versus copies, and performance limits.
Read the design notes →What OntoEnv saves¶
RDF graphs from local files and remote URLs.
Canonical ontology IRIs, aliases, source locations, and namespace prefixes.
Direct and transitive
owl:importsrelationships, 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.