Skip to content

Commit

Permalink
Cleaner EE fallback for no op (#3106)
Browse files Browse the repository at this point in the history
* treat async values differently

* cleaner approach

* spacing

* typing
  • Loading branch information
pablonyx authored Nov 11, 2024
1 parent ba805f7 commit 5166649
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion backend/danswer/utils/variable_functionality.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import importlib
import inspect
from typing import Any
from typing import TypeVar

Expand Down Expand Up @@ -139,8 +140,19 @@ def fetch_ee_implementation_or_noop(
Exception: If EE is enabled but the fetch fails.
"""
if not global_version.is_ee_version():
return lambda *args, **kwargs: noop_return_value
if inspect.iscoroutinefunction(noop_return_value):

async def async_noop(*args: Any, **kwargs: Any) -> Any:
return await noop_return_value(*args, **kwargs)

return async_noop

else:

def sync_noop(*args: Any, **kwargs: Any) -> Any:
return noop_return_value

return sync_noop
try:
return fetch_versioned_implementation(module, attribute)
except Exception as e:
Expand Down

0 comments on commit 5166649

Please sign in to comment.