Skip to content
This repository was archived by the owner on May 14, 2026. It is now read-only.

Commit 32dfb9b

Browse files
authored
Merge pull request #17 from tomsch420/main
Fixed pyproject.toml
2 parents c7af5c6 + cf47957 commit 32dfb9b

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "krrood"
7-
version = "1.0.2"
7+
version = "1.0.3"
88
description = "A university data generator based on the LUBM (Lehigh University Benchmark) ontology"
99
readme = "README.md"
1010
requires-python = ">=3.10"
@@ -51,7 +51,7 @@ include = ["krrood*"]
5151
exclude = ["test*"]
5252

5353
[tool.setuptools.package-data]
54-
my_library = ["templates/*.j2"] # glob patterns allowed
54+
my_library = ["ormatic/templates/*.j2"] # glob patterns allowed
5555

5656
[tool.pytest.ini_options]
5757
testpaths = ["test"]

src/krrood/entity_query_language/symbol_graph.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from __future__ import annotations
22

33
import os
4+
import weakref
45
from copy import copy
56
from dataclasses import dataclass, field, fields
67
from functools import cached_property
8+
from weakref import WeakKeyDictionary
79

810
from rustworkx import PyDiGraph
911
from typing_extensions import (
@@ -34,6 +36,7 @@ class PredicateRelation(Relation):
3436
The relation carries the predicate instance that asserted the edge and a flag indicating
3537
whether it was inferred transitively or added directly.
3638
"""
39+
3740
source: WrappedInstance
3841
target: WrappedInstance
3942
predicate: BinaryPredicate
@@ -51,6 +54,7 @@ def color(self) -> str:
5154
@dataclass
5255
class WrappedInstance:
5356
"""A node wrapper around a concrete Symbol instance used in the instance graph."""
57+
5458
instance: Symbol
5559
index: Optional[int] = field(init=False, default=None)
5660
_symbol_graph_: Optional[SymbolGraph] = field(
@@ -94,7 +98,9 @@ class SymbolGraph:
9498
_instance_graph: PyDiGraph[WrappedInstance, PredicateRelation] = field(
9599
default_factory=PyDiGraph
96100
)
97-
_instance_index: Dict = field(default_factory=dict, init=False, repr=False)
101+
_instance_index: WeakKeyDictionary[Symbol, WrappedInstance] = field(
102+
default_factory=WeakKeyDictionary, init=False, repr=False
103+
)
98104
_relation_index: Dict[type, set[tuple[int, int]]] = field(
99105
default_factory=dict, init=False, repr=False
100106
)

test/test_eql/test_symbol_graph.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import os
2+
import time
23

34
import pytest
45

56
from krrood.entity_query_language.symbol_graph import SymbolGraph
7+
from krrood.entity_query_language.symbolic import symbolic_mode
68
from ..dataset import semantic_world_like_classes
9+
from ..dataset.example_classes import Position
710
from krrood.class_diagrams.utils import classes_of_module
11+
from krrood.entity_query_language.entity import an, entity, let
812

913
try:
1014
import pydot
@@ -22,3 +26,19 @@ def test_visualize_symbol_graph():
2226
assert len(symbol_graph._type_graph.wrapped_classes) == 14
2327
if os.path.exists("symbol_graph.svg"):
2428
os.remove("symbol_graph.svg")
29+
30+
31+
@pytest.mark.skip
32+
def test_memory_leak():
33+
"""
34+
Test if the SymbolGraph does not artificially keep objects alive that would be garbage collected.
35+
"""
36+
37+
def create_data():
38+
point = Position(1, 2, 3)
39+
40+
create_data()
41+
time.sleep(1)
42+
with symbolic_mode():
43+
q = an(entity(let(Position)))
44+
assert list(q.evaluate()) == []

0 commit comments

Comments
 (0)