Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/omop_graph/graph/kg.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def emb(self) -> "EmbeddingWriterInterface | EmbeddingReaderInterface":
backend_type = self._emb_config.backend_type or cfg.backend
faiss_cache_dir = cfg.faiss_cache_dir

backend = resolve_backend(backend_type)
backend = resolve_backend(backend_type, sqlite_path=cfg.sqlite_path)

if self._emb_config.client is not None:
# Write-capable interface
Expand Down
32 changes: 8 additions & 24 deletions src/omop_graph/graph/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
)

# Local Application Imports
from omop_graph.config import OmopGraphConfig
from omop_graph.extensions.omop_alchemy import PredicateKind
from omop_graph.graph.edges import EdgeView
from omop_graph.graph.traverse import GraphTrace, TraceStep
Expand Down Expand Up @@ -219,9 +218,9 @@ def find_shortest_paths(
source: int,
target: int,
predicate_kinds: Optional[frozenset[PredicateKind]] = None,
max_depth: Optional[int] = None,
max_depth: int = 6,
on: Optional[Any] = None,
max_paths: Optional[int] = None,
max_paths: int = 20,
traced: bool = False,
within_domain: bool = True,
) -> Tuple[List[GraphPath], Optional[GraphTrace]]:
Expand Down Expand Up @@ -256,12 +255,6 @@ def find_shortest_paths(
tuple[list[GraphPath], GraphTrace | None]
A list of paths and optionally the trace object.
"""
cfg = OmopGraphConfig.get_config()
if max_depth is None:
max_depth = cfg.max_depth
if max_paths is None:
max_paths = cfg.max_paths

if source == target:
path = GraphPath(steps=())
trace = (
Expand Down Expand Up @@ -429,9 +422,9 @@ def find_shortest_paths_batch(
source: int,
target: int,
predicate_kinds: Union[Set[PredicateKind], frozenset[PredicateKind], None] = None,
max_depth: Optional[int] = None,
max_depth: int = 6,
on: Optional[Any] = None,
max_paths: Optional[int] = None,
max_paths: int = 20,
within_domain: bool = True,
) -> List[GraphPath]:
"""
Expand Down Expand Up @@ -469,12 +462,6 @@ def find_shortest_paths_batch(
if source == target:
return [GraphPath(steps=())]

cfg = OmopGraphConfig.get_config()
if max_depth is None:
max_depth = cfg.max_depth
if max_paths is None:
max_paths = cfg.max_paths

# Frontiers: The set of nodes we are currently expanding
fwd_frontier = {source}
bwd_frontier = {target}
Expand Down Expand Up @@ -702,7 +689,7 @@ def find_standard_paths(
targets: Optional[Tuple[int, ...]],
candidate: CandidateHit,
predicate_kinds: Optional[frozenset[Any]] = None,
max_depth: Optional[int] = None,
max_depth: int = 6,
max_concepts: Optional[int] = None,
within_domain: bool = True,
) -> List[StandardConcept]:
Expand Down Expand Up @@ -746,10 +733,10 @@ def find_standard_paths(
Allowed edge types for traversal. Defaults to all kinds when None. Callers
in the grounding pipeline pass PredicateKind.IDENTITY exclusively, limiting
traversal to Maps-to relationships between non-standard and standard concepts.
max_depth : int, optional
max_depth : int
Maximum min_levels_of_separation permitted in the concept_ancestor check when
``targets`` is given, or maximum identity-hop count permitted when ``targets``
is None. Defaults to OmopGraphConfig.max_depth when None.
is None. Defaults to ``6``.
max_concepts : int, optional
Per-target cap on unique standard concepts collected (or an overall cap when
``targets`` is None). Once every bucket has reached this count the search
Expand Down Expand Up @@ -778,10 +765,7 @@ def find_standard_paths(
admissible heuristic added to the priority.
"""
# Placeholder for the non-parent-ID grounding so the target accumulation works
unconstrained_placeholder: int = 0

if max_depth is None:
max_depth = OmopGraphConfig.get_config().max_depth
unconstrained_placeholder: int = 0

source_view = kg.concept_view(candidate.concept_id)
source_is_std = source_view.standard_concept if source_view else False
Expand Down
7 changes: 2 additions & 5 deletions src/omop_graph/reasoning/grounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
from __future__ import annotations

import logging
from dataclasses import dataclass, field
from dataclasses import dataclass
from typing import List, Optional, Tuple

import numpy as np

from omop_graph.config import OmopGraphConfig
from omop_graph.extensions.omop_alchemy import PredicateKind
from omop_graph.graph.constraints import SearchConstraintConcept
from omop_graph.graph.kg import KnowledgeGraph
Expand Down Expand Up @@ -74,9 +73,7 @@ class GroundingConstraints:

parent_ids: Optional[Tuple[int, ...]]
search_constraint: Optional[SearchConstraintConcept]
max_depth: int = field(
default_factory=lambda: OmopGraphConfig.get_config().max_depth
)
max_depth: int = 6
predicate_kinds: frozenset[PredicateKind] = frozenset({PredicateKind.IDENTITY})

def __post_init__(self) -> None:
Expand Down
Loading