File size: 683 Bytes
399944f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from __future__ import annotations
from typing import Optional

from .store import GraphStore

__all__ = ["get_graph"]

# Internal singleton-ish instance
_graph_instance: Optional[GraphStore] = None

def get_graph() -> GraphStore:
    """
    Return the global GraphStore instance.

    Lazily connects on first call, then reuses that instance.
    """
    global _graph_instance
    if _graph_instance is None:
        _graph_instance = GraphStore.connect()
    return _graph_instance


def set_graph_for_testing(store: GraphStore) -> None:
    """
    Override the global graph instance (e.g., in tests or notebooks).
    """
    global _graph_instance
    _graph_instance = store