OntoEnv ======= .. raw:: html
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: .. code-block:: console $ 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: .. code-block:: 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 ---------------- .. raw:: htmlBuild a small environment and inspect an import closure, from the CLI or Python.
Work through an example →Specific tasks: constrain discovery, work offline, run a service, attach storage, or recover after an interrupted write.
Find a procedure →CLI commands, Python methods, configuration keys, and storage interfaces.
Consult the reference →Design constraints and trade-offs: closure transformations, lifecycle choices, views versus copies, and performance limits.
Read the design notes →