azure-functions-durable 1.2.7__py3-none-any.whl → 1.2.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azure/durable_functions/decorators/durable_app.py +9 -1
- azure/durable_functions/models/DurableOrchestrationClient.py +70 -0
- azure/durable_functions/models/OrchestrationRuntimeStatus.py +3 -0
- azure/durable_functions/models/TaskOrchestrationExecutor.py +6 -3
- azure/durable_functions/models/history/HistoryEventType.py +2 -0
- {azure_functions_durable-1.2.7.data → azure_functions_durable-1.2.9.data}/data/_manifest/bsi.json +1 -1
- {azure_functions_durable-1.2.7.data → azure_functions_durable-1.2.9.data}/data/_manifest/manifest.cat +0 -0
- {azure_functions_durable-1.2.7.data → azure_functions_durable-1.2.9.data}/data/_manifest/manifest.spdx.json +2984 -4704
- azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json.sha256 +1 -0
- {azure_functions_durable-1.2.7.dist-info → azure_functions_durable-1.2.9.dist-info}/METADATA +1 -1
- {azure_functions_durable-1.2.7.dist-info → azure_functions_durable-1.2.9.dist-info}/RECORD +17 -17
- {azure_functions_durable-1.2.7.dist-info → azure_functions_durable-1.2.9.dist-info}/WHEEL +1 -1
- tests/models/test_DurableOrchestrationBindings.py +12 -0
- tests/models/test_DurableOrchestrationClient.py +119 -1
- tests/orchestrator/test_sequential_orchestrator.py +44 -4
- azure_functions_durable-1.2.7.data/data/_manifest/manifest.spdx.json.sha256 +0 -1
- {azure_functions_durable-1.2.7.dist-info → azure_functions_durable-1.2.9.dist-info}/LICENSE +0 -0
- {azure_functions_durable-1.2.7.dist-info → azure_functions_durable-1.2.9.dist-info}/top_level.txt +0 -0
|
@@ -7,9 +7,17 @@ from azure.durable_functions.entity import Entity
|
|
|
7
7
|
from azure.durable_functions.orchestrator import Orchestrator
|
|
8
8
|
from azure.durable_functions import DurableOrchestrationClient
|
|
9
9
|
from typing import Union
|
|
10
|
-
from azure.functions import FunctionRegister, TriggerApi, BindingApi, AuthLevel
|
|
10
|
+
from azure.functions import FunctionRegister, TriggerApi, BindingApi, AuthLevel
|
|
11
11
|
from functools import wraps
|
|
12
12
|
|
|
13
|
+
try:
|
|
14
|
+
from azure.functions import SettingsApi
|
|
15
|
+
except ImportError: # backwards compatibility path
|
|
16
|
+
class SettingsApi:
|
|
17
|
+
"""Backwards compatibility mock of SettingsApi."""
|
|
18
|
+
|
|
19
|
+
pass
|
|
20
|
+
|
|
13
21
|
|
|
14
22
|
class Blueprint(TriggerApi, BindingApi, SettingsApi):
|
|
15
23
|
"""Durable Functions (DF) Blueprint container.
|
|
@@ -709,3 +709,73 @@ class DurableOrchestrationClient:
|
|
|
709
709
|
else:
|
|
710
710
|
ex_msg = "Received unexpected payload from the durable-extension: " + str(response)
|
|
711
711
|
raise Exception(ex_msg)
|
|
712
|
+
|
|
713
|
+
async def suspend(self, instance_id: str, reason: str) -> None:
|
|
714
|
+
"""Suspend the specified orchestration instance.
|
|
715
|
+
|
|
716
|
+
Parameters
|
|
717
|
+
----------
|
|
718
|
+
instance_id : str
|
|
719
|
+
The ID of the orchestration instance to suspend.
|
|
720
|
+
reason: str
|
|
721
|
+
The reason for suspending the instance.
|
|
722
|
+
|
|
723
|
+
Raises
|
|
724
|
+
------
|
|
725
|
+
Exception:
|
|
726
|
+
When the suspend call failed with an unexpected status code
|
|
727
|
+
|
|
728
|
+
Returns
|
|
729
|
+
-------
|
|
730
|
+
None
|
|
731
|
+
"""
|
|
732
|
+
request_url = f"{self._orchestration_bindings.rpc_base_url}instances/{instance_id}/" \
|
|
733
|
+
f"suspend?reason={quote(reason)}"
|
|
734
|
+
response = await self._post_async_request(request_url, None)
|
|
735
|
+
switch_statement = {
|
|
736
|
+
202: lambda: None, # instance is suspended
|
|
737
|
+
410: lambda: None, # instance completed
|
|
738
|
+
404: lambda: f"No instance with ID '{instance_id}' found.",
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
has_error_message = switch_statement.get(
|
|
742
|
+
response[0],
|
|
743
|
+
lambda: f"The operation failed with an unexpected status code {response[0]}")
|
|
744
|
+
error_message = has_error_message()
|
|
745
|
+
if error_message:
|
|
746
|
+
raise Exception(error_message)
|
|
747
|
+
|
|
748
|
+
async def resume(self, instance_id: str, reason: str) -> None:
|
|
749
|
+
"""Resume the specified orchestration instance.
|
|
750
|
+
|
|
751
|
+
Parameters
|
|
752
|
+
----------
|
|
753
|
+
instance_id : str
|
|
754
|
+
The ID of the orchestration instance to query.
|
|
755
|
+
reason: str
|
|
756
|
+
The reason for resuming the instance.
|
|
757
|
+
|
|
758
|
+
Raises
|
|
759
|
+
------
|
|
760
|
+
Exception:
|
|
761
|
+
When the resume call failed with an unexpected status code
|
|
762
|
+
|
|
763
|
+
Returns
|
|
764
|
+
-------
|
|
765
|
+
None
|
|
766
|
+
"""
|
|
767
|
+
request_url = f"{self._orchestration_bindings.rpc_base_url}instances/{instance_id}/" \
|
|
768
|
+
f"resume?reason={quote(reason)}"
|
|
769
|
+
response = await self._post_async_request(request_url, None)
|
|
770
|
+
switch_statement = {
|
|
771
|
+
202: lambda: None, # instance is resumed
|
|
772
|
+
410: lambda: None, # instance completed
|
|
773
|
+
404: lambda: f"No instance with ID '{instance_id}' found.",
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
has_error_message = switch_statement.get(
|
|
777
|
+
response[0],
|
|
778
|
+
lambda: f"The operation failed with an unexpected status code {response[0]}")
|
|
779
|
+
error_message = has_error_message()
|
|
780
|
+
if error_message:
|
|
781
|
+
raise Exception(error_message)
|
|
@@ -27,3 +27,6 @@ class OrchestrationRuntimeStatus(Enum):
|
|
|
27
27
|
|
|
28
28
|
Pending = 'Pending'
|
|
29
29
|
"""The orchestration instance has been scheduled but has not yet started running."""
|
|
30
|
+
|
|
31
|
+
Suspended = 'Suspended'
|
|
32
|
+
"""The orchestration instance has been suspended and may go back to running at a later time."""
|
|
@@ -165,11 +165,14 @@ class TaskOrchestrationExecutor:
|
|
|
165
165
|
|
|
166
166
|
# We provide the ability to deserialize custom objects, because the output of this
|
|
167
167
|
# will be passed directly to the orchestrator as the output of some activity
|
|
168
|
-
if event_type == HistoryEventType.SUB_ORCHESTRATION_INSTANCE_COMPLETED
|
|
168
|
+
if (event_type == HistoryEventType.SUB_ORCHESTRATION_INSTANCE_COMPLETED
|
|
169
|
+
and directive_result.Result is not None):
|
|
169
170
|
return json.loads(directive_result.Result, object_hook=_deserialize_custom_object)
|
|
170
|
-
if event_type == HistoryEventType.TASK_COMPLETED
|
|
171
|
+
if (event_type == HistoryEventType.TASK_COMPLETED
|
|
172
|
+
and directive_result.Result is not None):
|
|
171
173
|
return json.loads(directive_result.Result, object_hook=_deserialize_custom_object)
|
|
172
|
-
if event_type == HistoryEventType.EVENT_RAISED
|
|
174
|
+
if (event_type == HistoryEventType.EVENT_RAISED
|
|
175
|
+
and directive_result.Input is not None):
|
|
173
176
|
# TODO: Investigate why the payload is in "Input" instead of "Result"
|
|
174
177
|
response = json.loads(directive_result.Input,
|
|
175
178
|
object_hook=_deserialize_custom_object)
|
{azure_functions_durable-1.2.7.data → azure_functions_durable-1.2.9.data}/data/_manifest/bsi.json
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"Source":"InternalBuild","Data":{"System.CollectionId":"d1c51fbc-4477-4a0f-b99f-fc9013009a58","System.DefinitionId":"58","System.TeamProjectId":"e6a70c92-4128-439f-8012-382fe78d6396","System.TeamProject":"Azure Functions","Build.BuildId":"
|
|
1
|
+
{"Source":"InternalBuild","Data":{"System.CollectionId":"d1c51fbc-4477-4a0f-b99f-fc9013009a58","System.DefinitionId":"58","System.TeamProjectId":"e6a70c92-4128-439f-8012-382fe78d6396","System.TeamProject":"Azure Functions","Build.BuildId":"161393","Build.BuildNumber":"20240214.1","Build.DefinitionName":"Azure.azure-functions-durable-python","Build.DefinitionRevision":"2","Build.Repository.Name":"Azure/azure-functions-durable-python","Build.Repository.Provider":"GitHub","Build.Repository.Id":"Azure/azure-functions-durable-python","Build.SourceBranch":"refs/tags/v1.2.9","Build.SourceBranchName":"v1.2.9","Build.SourceVersion":"34112b1c6a6100bf602eff0ae3f57918fac61935"},"Feed":null}
|