Fix EE Import backoff Logic (#1959)

This commit is contained in:
Yuhong Sun authored and GitHub committed 2024-07-27 11:06:11 -07:00
1 parent 6c32821ad4
commit f2f60c9cc0
5 files changed
+37 -22

No files matched your search

@@ -37,9 +37,24 @@ def fetch_versioned_implementation(module: str, attribute: str) -> Any:
module_full = f"ee.{module}" if is_ee else module
try:
return getattr(importlib.import_module(module_full), attribute)
except ModuleNotFoundError:
# try the non-ee version as a fallback
except ModuleNotFoundError as e:
logger.warning(
"Failed to fetch versioned implementation for %s.%s: %s",
module_full,
attribute,
e,
)
if is_ee:
if "ee.danswer" not in str(e):
# If it's a non Danswer related import failure, this is likely because
# a dependent library has not been installed. Should raise this failure
# instead of letting the server start up
raise e
# Use the MIT version as a fallback, this allows us to develop MIT
# versions independently and later add additional EE functionality
# similar to feature flagging
return getattr(importlib.import_module(module), attribute)
raise