azure-functions-durable 1.2.9__py3-none-any.whl → 1.3.0__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.
Files changed (104) hide show
  1. azure/durable_functions/__init__.py +81 -81
  2. azure/durable_functions/constants.py +9 -9
  3. azure/durable_functions/decorators/__init__.py +3 -3
  4. azure/durable_functions/decorators/durable_app.py +260 -249
  5. azure/durable_functions/decorators/metadata.py +109 -109
  6. azure/durable_functions/entity.py +129 -125
  7. azure/durable_functions/models/DurableEntityContext.py +201 -201
  8. azure/durable_functions/models/DurableHttpRequest.py +58 -58
  9. azure/durable_functions/models/DurableOrchestrationBindings.py +66 -66
  10. azure/durable_functions/models/DurableOrchestrationClient.py +812 -781
  11. azure/durable_functions/models/DurableOrchestrationContext.py +761 -707
  12. azure/durable_functions/models/DurableOrchestrationStatus.py +156 -156
  13. azure/durable_functions/models/EntityStateResponse.py +23 -23
  14. azure/durable_functions/models/FunctionContext.py +7 -7
  15. azure/durable_functions/models/OrchestrationRuntimeStatus.py +32 -32
  16. azure/durable_functions/models/OrchestratorState.py +117 -116
  17. azure/durable_functions/models/PurgeHistoryResult.py +33 -33
  18. azure/durable_functions/models/ReplaySchema.py +9 -8
  19. azure/durable_functions/models/RetryOptions.py +69 -69
  20. azure/durable_functions/models/RpcManagementOptions.py +86 -86
  21. azure/durable_functions/models/Task.py +540 -426
  22. azure/durable_functions/models/TaskOrchestrationExecutor.py +352 -336
  23. azure/durable_functions/models/TokenSource.py +56 -56
  24. azure/durable_functions/models/__init__.py +26 -24
  25. azure/durable_functions/models/actions/Action.py +23 -23
  26. azure/durable_functions/models/actions/ActionType.py +18 -18
  27. azure/durable_functions/models/actions/CallActivityAction.py +41 -41
  28. azure/durable_functions/models/actions/CallActivityWithRetryAction.py +45 -45
  29. azure/durable_functions/models/actions/CallEntityAction.py +46 -46
  30. azure/durable_functions/models/actions/CallHttpAction.py +35 -35
  31. azure/durable_functions/models/actions/CallSubOrchestratorAction.py +40 -40
  32. azure/durable_functions/models/actions/CallSubOrchestratorWithRetryAction.py +44 -44
  33. azure/durable_functions/models/actions/CompoundAction.py +35 -35
  34. azure/durable_functions/models/actions/ContinueAsNewAction.py +36 -36
  35. azure/durable_functions/models/actions/CreateTimerAction.py +48 -48
  36. azure/durable_functions/models/actions/NoOpAction.py +35 -35
  37. azure/durable_functions/models/actions/SignalEntityAction.py +47 -47
  38. azure/durable_functions/models/actions/WaitForExternalEventAction.py +63 -63
  39. azure/durable_functions/models/actions/WhenAllAction.py +14 -14
  40. azure/durable_functions/models/actions/WhenAnyAction.py +14 -14
  41. azure/durable_functions/models/actions/__init__.py +24 -24
  42. azure/durable_functions/models/entities/EntityState.py +74 -74
  43. azure/durable_functions/models/entities/OperationResult.py +94 -76
  44. azure/durable_functions/models/entities/RequestMessage.py +53 -53
  45. azure/durable_functions/models/entities/ResponseMessage.py +48 -48
  46. azure/durable_functions/models/entities/Signal.py +62 -62
  47. azure/durable_functions/models/entities/__init__.py +17 -17
  48. azure/durable_functions/models/history/HistoryEvent.py +92 -92
  49. azure/durable_functions/models/history/HistoryEventType.py +27 -27
  50. azure/durable_functions/models/history/__init__.py +8 -8
  51. azure/durable_functions/models/utils/__init__.py +7 -7
  52. azure/durable_functions/models/utils/entity_utils.py +103 -91
  53. azure/durable_functions/models/utils/http_utils.py +80 -69
  54. azure/durable_functions/models/utils/json_utils.py +96 -56
  55. azure/durable_functions/orchestrator.py +73 -71
  56. azure/durable_functions/testing/OrchestratorGeneratorWrapper.py +42 -0
  57. azure/durable_functions/testing/__init__.py +6 -0
  58. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/LICENSE +21 -21
  59. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/METADATA +59 -58
  60. azure_functions_durable-1.3.0.dist-info/RECORD +103 -0
  61. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/WHEEL +1 -1
  62. tests/models/test_DecoratorMetadata.py +135 -135
  63. tests/models/test_Decorators.py +107 -107
  64. tests/models/test_DurableOrchestrationBindings.py +68 -68
  65. tests/models/test_DurableOrchestrationClient.py +730 -730
  66. tests/models/test_DurableOrchestrationContext.py +102 -102
  67. tests/models/test_DurableOrchestrationStatus.py +59 -59
  68. tests/models/test_OrchestrationState.py +28 -28
  69. tests/models/test_RpcManagementOptions.py +79 -79
  70. tests/models/test_TokenSource.py +10 -10
  71. tests/orchestrator/models/OrchestrationInstance.py +18 -18
  72. tests/orchestrator/orchestrator_test_utils.py +130 -130
  73. tests/orchestrator/schemas/OrchetrationStateSchema.py +66 -66
  74. tests/orchestrator/test_call_http.py +235 -176
  75. tests/orchestrator/test_continue_as_new.py +67 -67
  76. tests/orchestrator/test_create_timer.py +126 -126
  77. tests/orchestrator/test_entity.py +397 -395
  78. tests/orchestrator/test_external_event.py +53 -53
  79. tests/orchestrator/test_fan_out_fan_in.py +175 -175
  80. tests/orchestrator/test_is_replaying_flag.py +101 -101
  81. tests/orchestrator/test_retries.py +308 -308
  82. tests/orchestrator/test_sequential_orchestrator.py +841 -841
  83. tests/orchestrator/test_sequential_orchestrator_custom_status.py +119 -119
  84. tests/orchestrator/test_sequential_orchestrator_with_retry.py +465 -465
  85. tests/orchestrator/test_serialization.py +30 -30
  86. tests/orchestrator/test_sub_orchestrator.py +95 -95
  87. tests/orchestrator/test_sub_orchestrator_with_retry.py +129 -129
  88. tests/orchestrator/test_task_any.py +60 -60
  89. tests/tasks/tasks_test_utils.py +17 -17
  90. tests/tasks/test_long_timers.py +70 -0
  91. tests/tasks/test_new_uuid.py +34 -34
  92. tests/test_utils/ContextBuilder.py +174 -174
  93. tests/test_utils/EntityContextBuilder.py +56 -56
  94. tests/test_utils/constants.py +1 -1
  95. tests/test_utils/json_utils.py +30 -30
  96. tests/test_utils/testClasses.py +56 -56
  97. tests/utils/__init__.py +1 -0
  98. tests/utils/test_entity_utils.py +24 -0
  99. azure_functions_durable-1.2.9.data/data/_manifest/bsi.json +0 -1
  100. azure_functions_durable-1.2.9.data/data/_manifest/manifest.cat +0 -0
  101. azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json +0 -11985
  102. azure_functions_durable-1.2.9.data/data/_manifest/manifest.spdx.json.sha256 +0 -1
  103. azure_functions_durable-1.2.9.dist-info/RECORD +0 -102
  104. {azure_functions_durable-1.2.9.dist-info → azure_functions_durable-1.3.0.dist-info}/top_level.txt +0 -0
@@ -1,156 +1,156 @@
1
- from datetime import datetime
2
- from dateutil.parser import parse as dt_parse
3
- from typing import Any, List, Dict, Optional, Union
4
- from .OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
5
- from .utils.json_utils import add_attrib, add_datetime_attrib
6
-
7
-
8
- class DurableOrchestrationStatus:
9
- """Represents the status of a durable orchestration instance.
10
-
11
- Can be fetched using [[DurableOrchestrationClient]].[[get_status]].
12
- """
13
-
14
- # parameter names are as defined by JSON schema and do not conform to PEP8 naming conventions
15
- def __init__(self, name: Optional[str] = None, instanceId: Optional[str] = None,
16
- createdTime: Optional[str] = None, lastUpdatedTime: Optional[str] = None,
17
- input: Optional[Any] = None, output: Optional[Any] = None,
18
- runtimeStatus: Optional[OrchestrationRuntimeStatus] = None,
19
- customStatus: Optional[Any] = None,
20
- history: Optional[List[Any]] = None,
21
- **kwargs):
22
- self._name: Optional[str] = name
23
- self._instance_id: Optional[str] = instanceId
24
- self._created_time: Optional[datetime] = \
25
- dt_parse(createdTime) if createdTime is not None else None
26
- self._last_updated_time: Optional[datetime] = dt_parse(lastUpdatedTime) \
27
- if lastUpdatedTime is not None else None
28
- self._input: Any = input
29
- self._output: Any = output
30
- self._runtime_status: Optional[OrchestrationRuntimeStatus] = runtimeStatus
31
- if runtimeStatus is not None:
32
- self._runtime_status = OrchestrationRuntimeStatus(runtimeStatus)
33
- self._custom_status: Any = customStatus
34
- self._history: Optional[List[Any]] = history
35
- if kwargs is not None:
36
- for key, value in kwargs.items():
37
- self.__setattr__(key, value)
38
-
39
- def __bool__(self):
40
- """Determine if a class resolves to True or False.
41
-
42
- We say that a DurableOrchestrationStatus if False if it has a value
43
- `None` for its `_created_time` value, which should be empty if it
44
- refers to a non-existent orchestration. This facilitates a clean
45
- implementation of the Singleton pattern
46
-
47
- Returns
48
- -------
49
- bool
50
- True if self._created_time is not None. False otherwise.
51
- """
52
- return self._created_time is not None
53
-
54
- @classmethod
55
- def from_json(cls, json_obj: Any):
56
- """Convert the value passed into a new instance of the class.
57
-
58
- Parameters
59
- ----------
60
- json_obj: any
61
- JSON object to be converted into an instance of the class
62
-
63
- Returns
64
- -------
65
- DurableOrchestrationStatus
66
- New instance of the durable orchestration status class
67
- """
68
- if isinstance(json_obj, str):
69
- return cls(message=json_obj)
70
- else:
71
- return cls(**json_obj)
72
-
73
- def to_json(self) -> Dict[str, Union[int, str]]:
74
- """Convert object into a json dictionary.
75
-
76
- Returns
77
- -------
78
- Dict[str, Union[int, str]]
79
- The instance of the class converted into a json dictionary
80
- """
81
- json: Dict[str, Union[int, str]] = {}
82
- add_attrib(json, self, 'name')
83
- add_attrib(json, self, 'instance_id', 'instanceId')
84
- add_datetime_attrib(json, self, 'created_time', 'createdTime')
85
- add_datetime_attrib(json, self, 'last_updated_time', 'lastUpdatedTime')
86
- add_attrib(json, self, 'output')
87
- add_attrib(json, self, 'input_', 'input')
88
- if self.runtime_status is not None:
89
- json["runtimeStatus"] = self.runtime_status.name
90
- add_attrib(json, self, 'custom_status', 'customStatus')
91
- add_attrib(json, self, 'history')
92
- return json
93
-
94
- @property
95
- def name(self) -> Optional[str]:
96
- """Get the orchestrator function name."""
97
- return self._name
98
-
99
- @property
100
- def instance_id(self) -> Optional[str]:
101
- """Get the unique ID of the instance.
102
-
103
- The instance ID is generated and fixed when the orchestrator
104
- function is scheduled. It can either auto-generated, in which case
105
- it is formatted as a UUID, or it can be user-specified with any
106
- format.
107
- """
108
- return self._instance_id
109
-
110
- @property
111
- def created_time(self) -> Optional[datetime]:
112
- """Get the time at which the orchestration instance was created.
113
-
114
- If the orchestration instance is in the [[Pending]] status, this
115
- time represents the time at which the orchestration instance was
116
- scheduled.
117
- """
118
- return self._created_time
119
-
120
- @property
121
- def last_updated_time(self) -> Optional[datetime]:
122
- """Get the time at which the orchestration instance last updated its execution history."""
123
- return self._last_updated_time
124
-
125
- @property
126
- def input_(self) -> Any:
127
- """Get the input of the orchestration instance."""
128
- return self._input
129
-
130
- @property
131
- def output(self) -> Any:
132
- """Get the output of the orchestration instance."""
133
- return self._output
134
-
135
- @property
136
- def runtime_status(self) -> Optional[OrchestrationRuntimeStatus]:
137
- """Get the runtime status of the orchestration instance."""
138
- return self._runtime_status
139
-
140
- @property
141
- def custom_status(self) -> Any:
142
- """Get the custom status payload (if any).
143
-
144
- Set by [[DurableOrchestrationContext]].[[set_custom_status]].
145
- """
146
- return self._custom_status
147
-
148
- @property
149
- def history(self) -> Optional[List[Any]]:
150
- """Get the execution history of the orchestration instance.
151
-
152
- The history log can be large and is therefore `undefined` by
153
- default. It is populated only when explicitly requested in the call
154
- to [[DurableOrchestrationClient]].[[get_status]].
155
- """
156
- return self._history
1
+ from datetime import datetime
2
+ from dateutil.parser import parse as dt_parse
3
+ from typing import Any, List, Dict, Optional, Union
4
+ from .OrchestrationRuntimeStatus import OrchestrationRuntimeStatus
5
+ from .utils.json_utils import add_attrib, add_datetime_attrib
6
+
7
+
8
+ class DurableOrchestrationStatus:
9
+ """Represents the status of a durable orchestration instance.
10
+
11
+ Can be fetched using [[DurableOrchestrationClient]].[[get_status]].
12
+ """
13
+
14
+ # parameter names are as defined by JSON schema and do not conform to PEP8 naming conventions
15
+ def __init__(self, name: Optional[str] = None, instanceId: Optional[str] = None,
16
+ createdTime: Optional[str] = None, lastUpdatedTime: Optional[str] = None,
17
+ input: Optional[Any] = None, output: Optional[Any] = None,
18
+ runtimeStatus: Optional[OrchestrationRuntimeStatus] = None,
19
+ customStatus: Optional[Any] = None,
20
+ history: Optional[List[Any]] = None,
21
+ **kwargs):
22
+ self._name: Optional[str] = name
23
+ self._instance_id: Optional[str] = instanceId
24
+ self._created_time: Optional[datetime] = \
25
+ dt_parse(createdTime) if createdTime is not None else None
26
+ self._last_updated_time: Optional[datetime] = dt_parse(lastUpdatedTime) \
27
+ if lastUpdatedTime is not None else None
28
+ self._input: Any = input
29
+ self._output: Any = output
30
+ self._runtime_status: Optional[OrchestrationRuntimeStatus] = runtimeStatus
31
+ if runtimeStatus is not None:
32
+ self._runtime_status = OrchestrationRuntimeStatus(runtimeStatus)
33
+ self._custom_status: Any = customStatus
34
+ self._history: Optional[List[Any]] = history
35
+ if kwargs is not None:
36
+ for key, value in kwargs.items():
37
+ self.__setattr__(key, value)
38
+
39
+ def __bool__(self):
40
+ """Determine if a class resolves to True or False.
41
+
42
+ We say that a DurableOrchestrationStatus if False if it has a value
43
+ `None` for its `_created_time` value, which should be empty if it
44
+ refers to a non-existent orchestration. This facilitates a clean
45
+ implementation of the Singleton pattern
46
+
47
+ Returns
48
+ -------
49
+ bool
50
+ True if self._created_time is not None. False otherwise.
51
+ """
52
+ return self._created_time is not None
53
+
54
+ @classmethod
55
+ def from_json(cls, json_obj: Any):
56
+ """Convert the value passed into a new instance of the class.
57
+
58
+ Parameters
59
+ ----------
60
+ json_obj: any
61
+ JSON object to be converted into an instance of the class
62
+
63
+ Returns
64
+ -------
65
+ DurableOrchestrationStatus
66
+ New instance of the durable orchestration status class
67
+ """
68
+ if isinstance(json_obj, str):
69
+ return cls(message=json_obj)
70
+ else:
71
+ return cls(**json_obj)
72
+
73
+ def to_json(self) -> Dict[str, Union[int, str]]:
74
+ """Convert object into a json dictionary.
75
+
76
+ Returns
77
+ -------
78
+ Dict[str, Union[int, str]]
79
+ The instance of the class converted into a json dictionary
80
+ """
81
+ json: Dict[str, Union[int, str]] = {}
82
+ add_attrib(json, self, 'name')
83
+ add_attrib(json, self, 'instance_id', 'instanceId')
84
+ add_datetime_attrib(json, self, 'created_time', 'createdTime')
85
+ add_datetime_attrib(json, self, 'last_updated_time', 'lastUpdatedTime')
86
+ add_attrib(json, self, 'output')
87
+ add_attrib(json, self, 'input_', 'input')
88
+ if self.runtime_status is not None:
89
+ json["runtimeStatus"] = self.runtime_status.name
90
+ add_attrib(json, self, 'custom_status', 'customStatus')
91
+ add_attrib(json, self, 'history')
92
+ return json
93
+
94
+ @property
95
+ def name(self) -> Optional[str]:
96
+ """Get the orchestrator function name."""
97
+ return self._name
98
+
99
+ @property
100
+ def instance_id(self) -> Optional[str]:
101
+ """Get the unique ID of the instance.
102
+
103
+ The instance ID is generated and fixed when the orchestrator
104
+ function is scheduled. It can either auto-generated, in which case
105
+ it is formatted as a UUID, or it can be user-specified with any
106
+ format.
107
+ """
108
+ return self._instance_id
109
+
110
+ @property
111
+ def created_time(self) -> Optional[datetime]:
112
+ """Get the time at which the orchestration instance was created.
113
+
114
+ If the orchestration instance is in the [[Pending]] status, this
115
+ time represents the time at which the orchestration instance was
116
+ scheduled.
117
+ """
118
+ return self._created_time
119
+
120
+ @property
121
+ def last_updated_time(self) -> Optional[datetime]:
122
+ """Get the time at which the orchestration instance last updated its execution history."""
123
+ return self._last_updated_time
124
+
125
+ @property
126
+ def input_(self) -> Any:
127
+ """Get the input of the orchestration instance."""
128
+ return self._input
129
+
130
+ @property
131
+ def output(self) -> Any:
132
+ """Get the output of the orchestration instance."""
133
+ return self._output
134
+
135
+ @property
136
+ def runtime_status(self) -> Optional[OrchestrationRuntimeStatus]:
137
+ """Get the runtime status of the orchestration instance."""
138
+ return self._runtime_status
139
+
140
+ @property
141
+ def custom_status(self) -> Any:
142
+ """Get the custom status payload (if any).
143
+
144
+ Set by [[DurableOrchestrationContext]].[[set_custom_status]].
145
+ """
146
+ return self._custom_status
147
+
148
+ @property
149
+ def history(self) -> Optional[List[Any]]:
150
+ """Get the execution history of the orchestration instance.
151
+
152
+ The history log can be large and is therefore `undefined` by
153
+ default. It is populated only when explicitly requested in the call
154
+ to [[DurableOrchestrationClient]].[[get_status]].
155
+ """
156
+ return self._history
@@ -1,23 +1,23 @@
1
- from typing import Any
2
-
3
-
4
- class EntityStateResponse:
5
- """Entity state response object for [read_entity_state]."""
6
-
7
- def __init__(self, entity_exists: bool, entity_state: Any = None) -> None:
8
- self._entity_exists = entity_exists
9
- self._entity_state = entity_state
10
-
11
- @property
12
- def entity_exists(self) -> bool:
13
- """Get the bool representing whether entity exists."""
14
- return self._entity_exists
15
-
16
- @property
17
- def entity_state(self) -> Any:
18
- """Get the state of the entity.
19
-
20
- When [entity_exists] is False, this value will be None.
21
- Optional.
22
- """
23
- return self._entity_state
1
+ from typing import Any
2
+
3
+
4
+ class EntityStateResponse:
5
+ """Entity state response object for [read_entity_state]."""
6
+
7
+ def __init__(self, entity_exists: bool, entity_state: Any = None) -> None:
8
+ self._entity_exists = entity_exists
9
+ self._entity_state = entity_state
10
+
11
+ @property
12
+ def entity_exists(self) -> bool:
13
+ """Get the bool representing whether entity exists."""
14
+ return self._entity_exists
15
+
16
+ @property
17
+ def entity_state(self) -> Any:
18
+ """Get the state of the entity.
19
+
20
+ When [entity_exists] is False, this value will be None.
21
+ Optional.
22
+ """
23
+ return self._entity_state
@@ -1,7 +1,7 @@
1
- class FunctionContext:
2
- """Object to hold any additional function level attributes not used by Durable."""
3
-
4
- def __init__(self, **kwargs):
5
- if kwargs is not None:
6
- for key, value in kwargs.items():
7
- self.__setattr__(key, value)
1
+ class FunctionContext:
2
+ """Object to hold any additional function level attributes not used by Durable."""
3
+
4
+ def __init__(self, **kwargs):
5
+ if kwargs is not None:
6
+ for key, value in kwargs.items():
7
+ self.__setattr__(key, value)
@@ -1,32 +1,32 @@
1
- from enum import Enum
2
-
3
-
4
- class OrchestrationRuntimeStatus(Enum):
5
- """The status of an orchestration instance."""
6
-
7
- Running = 'Running'
8
- """The orchestration instance has started running."""
9
-
10
- Completed = 'Completed'
11
- """The orchestration instance has completed normally."""
12
-
13
- ContinuedAsNew = 'ContinuedAsNew'
14
- """The orchestration instance has restarted itself with a new history.
15
-
16
- This is a transient state.
17
- """
18
-
19
- Failed = 'Failed'
20
- """The orchestration instance failed with an error."""
21
-
22
- Canceled = 'Canceled'
23
- """The orchestration was canceled gracefully."""
24
-
25
- Terminated = 'Terminated'
26
- """The orchestration instance was stopped abruptly."""
27
-
28
- Pending = 'Pending'
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."""
1
+ from enum import Enum
2
+
3
+
4
+ class OrchestrationRuntimeStatus(Enum):
5
+ """The status of an orchestration instance."""
6
+
7
+ Running = 'Running'
8
+ """The orchestration instance has started running."""
9
+
10
+ Completed = 'Completed'
11
+ """The orchestration instance has completed normally."""
12
+
13
+ ContinuedAsNew = 'ContinuedAsNew'
14
+ """The orchestration instance has restarted itself with a new history.
15
+
16
+ This is a transient state.
17
+ """
18
+
19
+ Failed = 'Failed'
20
+ """The orchestration instance failed with an error."""
21
+
22
+ Canceled = 'Canceled'
23
+ """The orchestration was canceled gracefully."""
24
+
25
+ Terminated = 'Terminated'
26
+ """The orchestration instance was stopped abruptly."""
27
+
28
+ Pending = 'Pending'
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."""