Skip to content

Commit 2126cc9

Browse files
docs: Add docstring and type signatures for get_dependencies_graph
Co-authored-by: aider (gemini/gemini-2.5-pro) <[email protected]>
1 parent 681cec9 commit 2126cc9

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

python/src/lib.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,26 @@ impl OntoEnv {
621621
}
622622

623623
/// Get the dependency closure of a given graph and return it as a new graph.
624+
///
625+
/// This method will look for `owl:imports` statements in the provided `graph`,
626+
/// then find those ontologies within the `OntoEnv` and compute the full
627+
/// dependency closure. The triples of all ontologies in the closure are
628+
/// returned as a new graph. The original graph is not modified.
629+
///
630+
/// Args:
631+
/// graph (rdflib.Graph): The graph to find dependencies for.
632+
/// destination_graph (Optional[rdflib.Graph]): If provided, the dependency graph will be added to this
633+
/// graph instead of creating a new one.
634+
/// recursion_depth (int): The maximum depth for recursive import resolution. A
635+
/// negative value (default) means no limit.
636+
/// fetch_missing (bool): If True, will fetch ontologies that are not in the environment.
637+
/// rewrite_sh_prefixes (bool): If True, will rewrite SHACL prefixes to be unique.
638+
/// remove_owl_imports (bool): If True, will remove `owl:imports` statements from the
639+
/// returned graph.
640+
///
641+
/// Returns:
642+
/// tuple[rdflib.Graph, list[str]]: A tuple containing the graph of dependencies and a list of the URIs of the
643+
/// imported ontologies.
624644
#[pyo3(signature = (graph, destination_graph=None, recursion_depth=-1, fetch_missing=false, rewrite_sh_prefixes=true, remove_owl_imports=true))]
625645
fn get_dependencies_graph<'a>(
626646
&self,

python/src/ontoenv.pyi

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,40 @@ class OntoEnv:
136136
"""
137137
...
138138

139+
def get_dependencies_graph(
140+
self,
141+
graph: Any,
142+
destination_graph: Optional[Any] = None,
143+
recursion_depth: int = -1,
144+
fetch_missing: bool = False,
145+
rewrite_sh_prefixes: bool = True,
146+
remove_owl_imports: bool = True,
147+
) -> tuple[Any, List[str]]:
148+
"""
149+
Get the dependency closure of a given graph and return it as a new graph.
150+
151+
This method will look for `owl:imports` statements in the provided `graph`,
152+
then find those ontologies within the `OntoEnv` and compute the full
153+
dependency closure. The triples of all ontologies in the closure are
154+
returned as a new graph. The original graph is not modified.
155+
156+
Args:
157+
graph: The graph to find dependencies for.
158+
destination_graph: If provided, the dependency graph will be added to this
159+
graph instead of creating a new one.
160+
recursion_depth: The maximum depth for recursive import resolution. A
161+
negative value (default) means no limit.
162+
fetch_missing: If True, will fetch ontologies that are not in the environment.
163+
rewrite_sh_prefixes: If True, will rewrite SHACL prefixes to be unique.
164+
remove_owl_imports: If True, will remove `owl:imports` statements from the
165+
returned graph.
166+
167+
Returns:
168+
A tuple containing the graph of dependencies and a list of the URIs of the
169+
imported ontologies.
170+
"""
171+
...
172+
139173
def add(self, location: Any, overwrite: bool = False, fetch_imports: bool = True) -> str:
140174
"""
141175
Add a new ontology to the OntoEnv.

0 commit comments

Comments
 (0)