ontoenv module¶
- class ontoenv.OntoEnv(path=None, recreate=False, create_or_use_cached=False, read_only=False, search_directories=None, require_ontology_names=False, strict=False, offline=False, use_cached_ontologies=False, resolution_policy=Ellipsis, root=Ellipsis, includes=None, excludes=None, temporary=False, no_search=False)¶
Bases:
object- add(location, overwrite=False, fetch_imports=True, force=False)¶
Add a new ontology to the OntoEnv
- add_no_imports(location, overwrite=False, force=False)¶
Add a new ontology to the OntoEnv without exploring owl:imports.
- close()¶
- dump(includes=None)¶
Print the contents of the OntoEnv
- flush()¶
- get_closure(uri, destination_graph=None, rewrite_sh_prefixes=True, remove_owl_imports=True, recursion_depth=Ellipsis)¶
Merge the imports closure of uri into a single graph and return it alongside the closure list.
The first element of the returned tuple is either the provided destination_graph (after mutation) or a brand-new rdflib.Graph. The second element is an ordered list of ontology IRIs in the resolved closure starting with uri. Set rewrite_sh_prefixes or remove_owl_imports to control post-processing of the merged triples.
- get_dependencies_graph(graph, destination_graph=None, recursion_depth=Ellipsis, fetch_missing=False, rewrite_sh_prefixes=True, remove_owl_imports=True)¶
Get the dependency closure of a given graph and return it as a new graph.
This method will look for owl:imports statements in the provided graph, then find those ontologies within the OntoEnv and compute the full dependency closure. The triples of all ontologies in the closure are returned as a new graph. The original graph is left untouched unless you also supply it as the destination_graph.
- Parameters:
graph (rdflib.Graph) – The graph to find dependencies for.
destination_graph (Optional[rdflib.Graph]) – If provided, the dependency graph will be added to this graph instead of creating a new one.
recursion_depth (int) – The maximum depth for recursive import resolution. A negative value (default) means no limit.
fetch_missing (bool) – If True, will fetch ontologies that are not in the environment.
rewrite_sh_prefixes (bool) – If True, will rewrite SHACL prefixes to be unique.
remove_owl_imports (bool) – If True, will remove owl:imports statements from the returned graph.
- Returns:
A tuple containing the populated dependency graph and the sorted list of imported ontology IRIs.
- Return type:
tuple[rdflib.Graph, list[str]]
- get_graph(uri)¶
Get the graph with the given URI as an rdflib.Graph
- get_importers(uri)¶
Get the names of all ontologies that import the given ontology
- get_ontology(uri)¶
Get the ontology metadata with the given URI
- get_ontology_names()¶
Get the names of all ontologies in the OntoEnv
- import_dependencies(graph, recursion_depth=Ellipsis, fetch_missing=False)¶
Import the dependencies referenced by owl:imports triples in graph.
When fetch_missing is true, the environment attempts to download unresolved imports before computing the closure. After merging the closure triples into graph, all owl:imports statements are removed. The returned list contains the deduplicated ontology IRIs that were successfully imported.
- import_graph(destination_graph, uri, recursion_depth=Ellipsis)¶
- is_offline()¶
- is_strict()¶
- list_closure(uri, recursion_depth=Ellipsis)¶
List the ontologies in the imports closure of the given ontology
- no_search()¶
- requires_ontology_names()¶
- resolution_policy()¶
- set_no_search(no_search)¶
- set_offline(offline)¶
- set_require_ontology_names(require)¶
- set_resolution_policy(policy)¶
- set_strict(strict)¶
- store_path()¶
- to_rdflib_dataset()¶
Convert the OntoEnv to an in-memory rdflib.Dataset populated with all named graphs
- update(all=False)¶
- class ontoenv.Ontology¶
Bases:
object- id¶
- imports¶
- last_updated¶
- location¶
- name¶
- namespace_map¶
- version_properties¶
- ontoenv.run_cli(args)¶
Run the Rust CLI implementation and return its process-style exit code.