-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathdurable_functions.py
More file actions
59 lines (47 loc) · 1.94 KB
/
Copy pathdurable_functions.py
File metadata and controls
59 lines (47 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
import logging
_logger = logging.getLogger('azure.functions.AsgiMiddleware')
df = None
def get_durable_package():
"""Determines which Durable SDK is being used.
If the `azure-functions-durable` package is installed, we
log a warning that this legacy package
is deprecated.
If both the legacy and current packages are installed,
we log a warning and prefer the current package.
If neither package is installed, we return None.
"""
_logger.info("Attempting to import Durable Functions package.")
using_legacy = False
using_durable_task = False
global df
if df:
_logger.info("Durable Functions package already loaded. DF: %s", df)
return df
try:
import azure.durable_functions as durable_functions
using_legacy = True
_logger.warning("`durabletask-azurefunctions` is available now! " \
"See <AKA.MS LINK HERE> for more details.")
except ImportError:
_logger.info("`azure-functions-durable` package not found.")
pass
try:
import durabletask.azurefunctions as durable_functions
using_durable_task = True
except ImportError:
_logger.info("`durabletask-azurefunctions` package not found.")
pass
if using_durable_task and using_legacy:
# Both packages are installed; prefer `durabletask-azurefunctions`.
_logger.warning("Both `azure-functions-durable` and " \
"`durabletask-azurefunctions` packages are installed. " \
"This may lead to unexpected behavior. Please resolve this " \
"conflict by removing one of these packages from the Python " \
"environment. Decorators from `durabletask-azurefunctions` will " \
"be used.")
if not using_durable_task and not using_legacy:
return None
df = durable_functions
return durable_functions