From 982ae6a1c39913ded58362431e42e6e3201f35ee Mon Sep 17 00:00:00 2001 From: Andrew Dillon Date: Wed, 2 Oct 2024 12:40:23 -0500 Subject: [PATCH] Make tests pass locally --- .../src/OpenMediaMatch/blueprints/matching.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/matching.py b/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/matching.py index d2b4c384e..b63f030af 100644 --- a/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/matching.py +++ b/hasher-matcher-actioner/src/OpenMediaMatch/blueprints/matching.py @@ -7,6 +7,7 @@ from dataclasses import dataclass import datetime import random +import sys import typing as t import time @@ -308,9 +309,16 @@ def index_cache_is_stale() -> bool: def _get_index(signal_type: t.Type[SignalType]) -> SignalTypeIndex[int] | None: entry = _get_index_cache().get(signal_type.get_name()) + + if entry is not None and is_in_pytest(): + entry.reload_if_needed(get_storage()) + if entry is None: current_app.logger.debug("[lookup_signal] no cache, loading index") return get_storage().get_signal_type_index(signal_type) if entry.is_ready: return entry.index return None + +def is_in_pytest(): + return "pytest" in sys.modules \ No newline at end of file