Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/reaction_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,15 @@ def prime_entity_caches(reaction_connections: pd.DataFrame) -> None:
# would make the network depend on build order (deltasignal specs/065).
from src.variant_emission import _sig_cache
_sig_cache.clear()
# So are the structure memos built from those getters (specs/065
# amendment 1); caches filled by their own direct query hold database
# truth and are kept.
import src.logic_network_generator as lng
for c in (lng._variant_leafsets_cache, lng._matching_leaves_cache,
lng._handoff_leaf_cache, lng._sets_chosen_cache):
c.clear()
from src import variant_keys
variant_keys.reset_caches()
clear_prefetch_cache()
reaction_ids = reaction_ids_from_connections(reaction_connections)
if not reaction_ids:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_variant_emission.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,19 @@ def test_priming_a_pathway_clears_set_member_signatures(monkeypatch):
ve._sig_cache[("M1", True)] = ("stale",)
rg.prime_entity_caches(None)
assert ve._sig_cache == {}


def test_priming_a_pathway_clears_derived_structure_caches(monkeypatch):
# specs/065 amendment 1: every memo computed from the prefetch-limited
# getters is per pathway.
import src.reaction_generator as rg
import src.logic_network_generator as lng
monkeypatch.setattr(rg, "reaction_ids_from_connections", lambda rc: ["R1"])
monkeypatch.setattr(rg, "prefetch_entity_data", lambda ids: None)
caches = (lng._variant_leafsets_cache, lng._matching_leaves_cache,
lng._handoff_leaf_cache, lng._sets_chosen_cache,
vk._memo, vk._variants_cache, vk._struct)
for c in caches:
c["stale"] = None
rg.prime_entity_caches(None)
assert all("stale" not in c for c in caches)
Loading