mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-06-26 16:01:09 +02:00
Cleaner EE fallback for no op (#3106)
* treat async values differently * cleaner approach * spacing * typing
This commit is contained in:
parent
ba805f766f
commit
5166649eae
@ -1,5 +1,6 @@
|
|||||||
import functools
|
import functools
|
||||||
import importlib
|
import importlib
|
||||||
|
import inspect
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import TypeVar
|
from typing import TypeVar
|
||||||
|
|
||||||
@ -139,8 +140,19 @@ def fetch_ee_implementation_or_noop(
|
|||||||
Exception: If EE is enabled but the fetch fails.
|
Exception: If EE is enabled but the fetch fails.
|
||||||
"""
|
"""
|
||||||
if not global_version.is_ee_version():
|
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:
|
try:
|
||||||
return fetch_versioned_implementation(module, attribute)
|
return fetch_versioned_implementation(module, attribute)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user