-
Notifications
You must be signed in to change notification settings - Fork 75
feat: Add support for new Durable Python SDK #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
5c51d8e
6a0ad5a
9d468bf
6aeafae
37714d4
5ec891e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
| import logging | ||
|
|
||
| _logger = logging.getLogger('azure.functions.DurableFunctions') | ||
|
|
||
| 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. | ||
| """ | ||
| global df | ||
| if df: | ||
| return df | ||
|
|
||
| try: | ||
| import azure.durable_functions as durable_functions # noqa | ||
| except ImportError: | ||
| _logger.debug("`azure.durable_functions` package not found.") | ||
| return None | ||
|
|
||
| if hasattr(durable_functions, 'version') and durable_functions.version.startswith("2."): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The current SDK does not expose azure.durable_functions.version. This will always log v1 package is used right?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFD V2 will expose this property
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct — with the current published SDK there's no |
||
| _logger.debug("Using `azure.durable_functions` v2.x package.") | ||
| else: | ||
| _logger.debug("Using `azure.durable_functions` v1.x package.") | ||
|
|
||
| df = durable_functions | ||
|
|
||
| return df | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which case this will return none? Won't a durable app always has the SDK installed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question — the
Nonepath is reachable and intentional in two cases:Non-durable apps (the common case).
register_durable_converters()runs at import ofazure.functionsfor every app. The majority of apps don't haveazure-functions-durableinstalled, soget_durable_package()returnsNoneand registration is a deliberate no-op.A user references a durable decorator without the SDK installed. The durable decorators (
orchestration_trigger,entity_trigger,activity_triggeronTriggerApi;durable_client_inputonBindingApi) are defined unconditionally in the baseazure-functionslibrary and inherited by everyFunctionApp/Blueprint. So a user can reference@app.orchestration_triggereven without the SDK present. In that case_get_durable_blueprint()getsNoneand raises the explicit "please installazure-functions-durable" error, instead of surfacing a confusingImportError/AttributeError.So a correctly-configured durable app will always have the SDK, but
Noneis the right guard for both the non-durable-app import path and the misconfigured-durable-app path.