durabletask 0.3.0__py3-none-any.whl → 0.4.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.
Potentially problematic release.
This version of durabletask might be problematic. Click here for more details.
- durabletask/__init__.py +2 -2
- durabletask/client.py +8 -3
- durabletask/internal/exceptions.py +7 -0
- durabletask/internal/helpers.py +12 -6
- durabletask/internal/orchestrator_service_pb2.py +243 -186
- durabletask/internal/orchestrator_service_pb2.pyi +305 -51
- durabletask/internal/orchestrator_service_pb2_grpc.py +510 -88
- durabletask/task.py +21 -2
- durabletask/worker.py +158 -7
- {durabletask-0.3.0.dist-info → durabletask-0.4.0.dist-info}/METADATA +5 -3
- durabletask-0.4.0.dist-info/RECORD +16 -0
- durabletask-0.3.0.dist-info/RECORD +0 -15
- {durabletask-0.3.0.dist-info → durabletask-0.4.0.dist-info}/WHEEL +0 -0
- {durabletask-0.3.0.dist-info → durabletask-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {durabletask-0.3.0.dist-info → durabletask-0.4.0.dist-info}/top_level.txt +0 -0
durabletask/__init__.py
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
"""Durable Task SDK for Python"""
|
|
5
5
|
|
|
6
|
-
from durabletask.worker import ConcurrencyOptions
|
|
6
|
+
from durabletask.worker import ConcurrencyOptions, VersioningOptions
|
|
7
7
|
|
|
8
|
-
__all__ = ["ConcurrencyOptions"]
|
|
8
|
+
__all__ = ["ConcurrencyOptions", "VersioningOptions"]
|
|
9
9
|
|
|
10
10
|
PACKAGE_NAME = "durabletask"
|
durabletask/client.py
CHANGED
|
@@ -98,7 +98,8 @@ class TaskHubGrpcClient:
|
|
|
98
98
|
log_handler: Optional[logging.Handler] = None,
|
|
99
99
|
log_formatter: Optional[logging.Formatter] = None,
|
|
100
100
|
secure_channel: bool = False,
|
|
101
|
-
interceptors: Optional[Sequence[shared.ClientInterceptor]] = None
|
|
101
|
+
interceptors: Optional[Sequence[shared.ClientInterceptor]] = None,
|
|
102
|
+
default_version: Optional[str] = None):
|
|
102
103
|
|
|
103
104
|
# If the caller provided metadata, we need to create a new interceptor for it and
|
|
104
105
|
# add it to the list of interceptors.
|
|
@@ -118,12 +119,15 @@ class TaskHubGrpcClient:
|
|
|
118
119
|
)
|
|
119
120
|
self._stub = stubs.TaskHubSidecarServiceStub(channel)
|
|
120
121
|
self._logger = shared.get_logger("client", log_handler, log_formatter)
|
|
122
|
+
self.default_version = default_version
|
|
121
123
|
|
|
122
124
|
def schedule_new_orchestration(self, orchestrator: Union[task.Orchestrator[TInput, TOutput], str], *,
|
|
123
125
|
input: Optional[TInput] = None,
|
|
124
126
|
instance_id: Optional[str] = None,
|
|
125
127
|
start_at: Optional[datetime] = None,
|
|
126
|
-
reuse_id_policy: Optional[pb.OrchestrationIdReusePolicy] = None
|
|
128
|
+
reuse_id_policy: Optional[pb.OrchestrationIdReusePolicy] = None,
|
|
129
|
+
tags: Optional[dict[str, str]] = None,
|
|
130
|
+
version: Optional[str] = None) -> str:
|
|
127
131
|
|
|
128
132
|
name = orchestrator if isinstance(orchestrator, str) else task.get_name(orchestrator)
|
|
129
133
|
|
|
@@ -132,8 +136,9 @@ class TaskHubGrpcClient:
|
|
|
132
136
|
instanceId=instance_id if instance_id else uuid.uuid4().hex,
|
|
133
137
|
input=wrappers_pb2.StringValue(value=shared.to_json(input)) if input is not None else None,
|
|
134
138
|
scheduledStartTimestamp=helpers.new_timestamp(start_at) if start_at else None,
|
|
135
|
-
version=
|
|
139
|
+
version=helpers.get_string_value(version if version else self.default_version),
|
|
136
140
|
orchestrationIdReusePolicy=reuse_id_policy,
|
|
141
|
+
tags=tags
|
|
137
142
|
)
|
|
138
143
|
|
|
139
144
|
self._logger.info(f"Starting new '{name}' instance with ID = '{req.instanceId}'.")
|
durabletask/internal/helpers.py
CHANGED
|
@@ -19,14 +19,16 @@ def new_orchestrator_started_event(timestamp: Optional[datetime] = None) -> pb.H
|
|
|
19
19
|
return pb.HistoryEvent(eventId=-1, timestamp=ts, orchestratorStarted=pb.OrchestratorStartedEvent())
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def new_execution_started_event(name: str, instance_id: str, encoded_input: Optional[str] = None
|
|
22
|
+
def new_execution_started_event(name: str, instance_id: str, encoded_input: Optional[str] = None,
|
|
23
|
+
tags: Optional[dict[str, str]] = None) -> pb.HistoryEvent:
|
|
23
24
|
return pb.HistoryEvent(
|
|
24
25
|
eventId=-1,
|
|
25
26
|
timestamp=timestamp_pb2.Timestamp(),
|
|
26
27
|
executionStarted=pb.ExecutionStartedEvent(
|
|
27
28
|
name=name,
|
|
28
29
|
input=get_string_value(encoded_input),
|
|
29
|
-
orchestrationInstance=pb.OrchestrationInstance(instanceId=instance_id)
|
|
30
|
+
orchestrationInstance=pb.OrchestrationInstance(instanceId=instance_id),
|
|
31
|
+
tags=tags))
|
|
30
32
|
|
|
31
33
|
|
|
32
34
|
def new_timer_created_event(timer_id: int, fire_at: datetime) -> pb.HistoryEvent:
|
|
@@ -178,10 +180,12 @@ def new_create_timer_action(id: int, fire_at: datetime) -> pb.OrchestratorAction
|
|
|
178
180
|
return pb.OrchestratorAction(id=id, createTimer=pb.CreateTimerAction(fireAt=timestamp))
|
|
179
181
|
|
|
180
182
|
|
|
181
|
-
def new_schedule_task_action(id: int, name: str, encoded_input: Optional[str]
|
|
183
|
+
def new_schedule_task_action(id: int, name: str, encoded_input: Optional[str],
|
|
184
|
+
tags: Optional[dict[str, str]]) -> pb.OrchestratorAction:
|
|
182
185
|
return pb.OrchestratorAction(id=id, scheduleTask=pb.ScheduleTaskAction(
|
|
183
186
|
name=name,
|
|
184
|
-
input=get_string_value(encoded_input)
|
|
187
|
+
input=get_string_value(encoded_input),
|
|
188
|
+
tags=tags
|
|
185
189
|
))
|
|
186
190
|
|
|
187
191
|
|
|
@@ -195,11 +199,13 @@ def new_create_sub_orchestration_action(
|
|
|
195
199
|
id: int,
|
|
196
200
|
name: str,
|
|
197
201
|
instance_id: Optional[str],
|
|
198
|
-
encoded_input: Optional[str]
|
|
202
|
+
encoded_input: Optional[str],
|
|
203
|
+
version: Optional[str]) -> pb.OrchestratorAction:
|
|
199
204
|
return pb.OrchestratorAction(id=id, createSubOrchestration=pb.CreateSubOrchestrationAction(
|
|
200
205
|
name=name,
|
|
201
206
|
instanceId=instance_id,
|
|
202
|
-
input=get_string_value(encoded_input)
|
|
207
|
+
input=get_string_value(encoded_input),
|
|
208
|
+
version=get_string_value(version)
|
|
203
209
|
))
|
|
204
210
|
|
|
205
211
|
|