@lru_cache on fetch_versioned_implementation (#1178)

This commit is contained in:
Kevin Shi 2024-03-04 17:50:51 -05:00 committed by GitHub
parent a7c820147e
commit 0b0665044f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,4 @@
import functools
import importlib
from typing import Any
@ -16,6 +17,7 @@ class DanswerVersion:
global_version = DanswerVersion()
@functools.lru_cache(maxsize=128)
def fetch_versioned_implementation(module: str, attribute: str) -> Any:
module_full = f"ee.{module}" if global_version.get_is_ee_version() else module
return getattr(importlib.import_module(module_full), attribute)