rappel 0.4.1__py3-none-win_amd64.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 rappel might be problematic. Click here for more details.
- proto/ast_pb2.py +117 -0
- proto/ast_pb2.pyi +1609 -0
- proto/ast_pb2_grpc.py +24 -0
- proto/ast_pb2_grpc.pyi +22 -0
- proto/messages_pb2.py +106 -0
- proto/messages_pb2.pyi +1170 -0
- proto/messages_pb2_grpc.py +406 -0
- proto/messages_pb2_grpc.pyi +380 -0
- rappel/__init__.py +56 -0
- rappel/actions.py +81 -0
- rappel/bin/boot-rappel-singleton.exe +0 -0
- rappel/bin/rappel-bridge.exe +0 -0
- rappel/bin/start-workers.exe +0 -0
- rappel/bridge.py +228 -0
- rappel/dependencies.py +135 -0
- rappel/exceptions.py +11 -0
- rappel/formatter.py +110 -0
- rappel/ir_builder.py +3146 -0
- rappel/logger.py +39 -0
- rappel/registry.py +75 -0
- rappel/schedule.py +294 -0
- rappel/serialization.py +205 -0
- rappel/worker.py +191 -0
- rappel/workflow.py +236 -0
- rappel/workflow_runtime.py +137 -0
- rappel-0.4.1.data/scripts/boot-rappel-singleton.exe +0 -0
- rappel-0.4.1.data/scripts/rappel-bridge.exe +0 -0
- rappel-0.4.1.data/scripts/start-workers.exe +0 -0
- rappel-0.4.1.dist-info/METADATA +292 -0
- rappel-0.4.1.dist-info/RECORD +32 -0
- rappel-0.4.1.dist-info/WHEEL +4 -0
- rappel-0.4.1.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"""
|
|
2
|
+
@generated by mypy-protobuf. Do not edit manually!
|
|
3
|
+
isort:skip_file
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import abc
|
|
7
|
+
import collections.abc
|
|
8
|
+
import sys
|
|
9
|
+
import typing
|
|
10
|
+
|
|
11
|
+
import grpc
|
|
12
|
+
import grpc.aio
|
|
13
|
+
|
|
14
|
+
from proto import messages_pb2
|
|
15
|
+
|
|
16
|
+
if sys.version_info >= (3, 13):
|
|
17
|
+
import typing as typing_extensions
|
|
18
|
+
else:
|
|
19
|
+
import typing_extensions
|
|
20
|
+
|
|
21
|
+
_T = typing.TypeVar("_T")
|
|
22
|
+
|
|
23
|
+
class _MaybeAsyncIterator(
|
|
24
|
+
collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta
|
|
25
|
+
): ...
|
|
26
|
+
class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg]
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
GRPC_GENERATED_VERSION: str
|
|
30
|
+
GRPC_VERSION: str
|
|
31
|
+
_WorkerBridgeAttachType = typing_extensions.TypeVar(
|
|
32
|
+
"_WorkerBridgeAttachType",
|
|
33
|
+
grpc.StreamStreamMultiCallable[
|
|
34
|
+
messages_pb2.Envelope,
|
|
35
|
+
messages_pb2.Envelope,
|
|
36
|
+
],
|
|
37
|
+
grpc.aio.StreamStreamMultiCallable[
|
|
38
|
+
messages_pb2.Envelope,
|
|
39
|
+
messages_pb2.Envelope,
|
|
40
|
+
],
|
|
41
|
+
default=grpc.StreamStreamMultiCallable[
|
|
42
|
+
messages_pb2.Envelope,
|
|
43
|
+
messages_pb2.Envelope,
|
|
44
|
+
],
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
class WorkerBridgeStub(typing.Generic[_WorkerBridgeAttachType]):
|
|
48
|
+
"""=============================================================================
|
|
49
|
+
gRPC Service Definitions
|
|
50
|
+
=============================================================================
|
|
51
|
+
|
|
52
|
+
Bidirectional streaming service for worker communication.
|
|
53
|
+
Workers connect and maintain a persistent stream for action dispatch/results.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
@typing.overload
|
|
57
|
+
def __init__(
|
|
58
|
+
self: WorkerBridgeStub[
|
|
59
|
+
grpc.StreamStreamMultiCallable[
|
|
60
|
+
messages_pb2.Envelope,
|
|
61
|
+
messages_pb2.Envelope,
|
|
62
|
+
],
|
|
63
|
+
],
|
|
64
|
+
channel: grpc.Channel,
|
|
65
|
+
) -> None: ...
|
|
66
|
+
@typing.overload
|
|
67
|
+
def __init__(
|
|
68
|
+
self: WorkerBridgeStub[
|
|
69
|
+
grpc.aio.StreamStreamMultiCallable[
|
|
70
|
+
messages_pb2.Envelope,
|
|
71
|
+
messages_pb2.Envelope,
|
|
72
|
+
],
|
|
73
|
+
],
|
|
74
|
+
channel: grpc.aio.Channel,
|
|
75
|
+
) -> None: ...
|
|
76
|
+
|
|
77
|
+
Attach: _WorkerBridgeAttachType
|
|
78
|
+
|
|
79
|
+
WorkerBridgeAsyncStub: typing_extensions.TypeAlias = WorkerBridgeStub[
|
|
80
|
+
grpc.aio.StreamStreamMultiCallable[
|
|
81
|
+
messages_pb2.Envelope,
|
|
82
|
+
messages_pb2.Envelope,
|
|
83
|
+
],
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
class WorkerBridgeServicer(metaclass=abc.ABCMeta):
|
|
87
|
+
"""=============================================================================
|
|
88
|
+
gRPC Service Definitions
|
|
89
|
+
=============================================================================
|
|
90
|
+
|
|
91
|
+
Bidirectional streaming service for worker communication.
|
|
92
|
+
Workers connect and maintain a persistent stream for action dispatch/results.
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
@abc.abstractmethod
|
|
96
|
+
def Attach(
|
|
97
|
+
self,
|
|
98
|
+
request_iterator: _MaybeAsyncIterator[messages_pb2.Envelope],
|
|
99
|
+
context: _ServicerContext,
|
|
100
|
+
) -> typing.Union[
|
|
101
|
+
collections.abc.Iterator[messages_pb2.Envelope],
|
|
102
|
+
collections.abc.AsyncIterator[messages_pb2.Envelope],
|
|
103
|
+
]: ...
|
|
104
|
+
|
|
105
|
+
def add_WorkerBridgeServicer_to_server(
|
|
106
|
+
servicer: WorkerBridgeServicer, server: typing.Union[grpc.Server, grpc.aio.Server]
|
|
107
|
+
) -> None: ...
|
|
108
|
+
|
|
109
|
+
_WorkflowServiceRegisterWorkflowType = typing_extensions.TypeVar(
|
|
110
|
+
"_WorkflowServiceRegisterWorkflowType",
|
|
111
|
+
grpc.UnaryUnaryMultiCallable[
|
|
112
|
+
messages_pb2.RegisterWorkflowRequest,
|
|
113
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
114
|
+
],
|
|
115
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
116
|
+
messages_pb2.RegisterWorkflowRequest,
|
|
117
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
118
|
+
],
|
|
119
|
+
default=grpc.UnaryUnaryMultiCallable[
|
|
120
|
+
messages_pb2.RegisterWorkflowRequest,
|
|
121
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
122
|
+
],
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
_WorkflowServiceWaitForInstanceType = typing_extensions.TypeVar(
|
|
126
|
+
"_WorkflowServiceWaitForInstanceType",
|
|
127
|
+
grpc.UnaryUnaryMultiCallable[
|
|
128
|
+
messages_pb2.WaitForInstanceRequest,
|
|
129
|
+
messages_pb2.WaitForInstanceResponse,
|
|
130
|
+
],
|
|
131
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
132
|
+
messages_pb2.WaitForInstanceRequest,
|
|
133
|
+
messages_pb2.WaitForInstanceResponse,
|
|
134
|
+
],
|
|
135
|
+
default=grpc.UnaryUnaryMultiCallable[
|
|
136
|
+
messages_pb2.WaitForInstanceRequest,
|
|
137
|
+
messages_pb2.WaitForInstanceResponse,
|
|
138
|
+
],
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
_WorkflowServiceRegisterScheduleType = typing_extensions.TypeVar(
|
|
142
|
+
"_WorkflowServiceRegisterScheduleType",
|
|
143
|
+
grpc.UnaryUnaryMultiCallable[
|
|
144
|
+
messages_pb2.RegisterScheduleRequest,
|
|
145
|
+
messages_pb2.RegisterScheduleResponse,
|
|
146
|
+
],
|
|
147
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
148
|
+
messages_pb2.RegisterScheduleRequest,
|
|
149
|
+
messages_pb2.RegisterScheduleResponse,
|
|
150
|
+
],
|
|
151
|
+
default=grpc.UnaryUnaryMultiCallable[
|
|
152
|
+
messages_pb2.RegisterScheduleRequest,
|
|
153
|
+
messages_pb2.RegisterScheduleResponse,
|
|
154
|
+
],
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
_WorkflowServiceUpdateScheduleStatusType = typing_extensions.TypeVar(
|
|
158
|
+
"_WorkflowServiceUpdateScheduleStatusType",
|
|
159
|
+
grpc.UnaryUnaryMultiCallable[
|
|
160
|
+
messages_pb2.UpdateScheduleStatusRequest,
|
|
161
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
162
|
+
],
|
|
163
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
164
|
+
messages_pb2.UpdateScheduleStatusRequest,
|
|
165
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
166
|
+
],
|
|
167
|
+
default=grpc.UnaryUnaryMultiCallable[
|
|
168
|
+
messages_pb2.UpdateScheduleStatusRequest,
|
|
169
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
170
|
+
],
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
_WorkflowServiceDeleteScheduleType = typing_extensions.TypeVar(
|
|
174
|
+
"_WorkflowServiceDeleteScheduleType",
|
|
175
|
+
grpc.UnaryUnaryMultiCallable[
|
|
176
|
+
messages_pb2.DeleteScheduleRequest,
|
|
177
|
+
messages_pb2.DeleteScheduleResponse,
|
|
178
|
+
],
|
|
179
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
180
|
+
messages_pb2.DeleteScheduleRequest,
|
|
181
|
+
messages_pb2.DeleteScheduleResponse,
|
|
182
|
+
],
|
|
183
|
+
default=grpc.UnaryUnaryMultiCallable[
|
|
184
|
+
messages_pb2.DeleteScheduleRequest,
|
|
185
|
+
messages_pb2.DeleteScheduleResponse,
|
|
186
|
+
],
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
_WorkflowServiceListSchedulesType = typing_extensions.TypeVar(
|
|
190
|
+
"_WorkflowServiceListSchedulesType",
|
|
191
|
+
grpc.UnaryUnaryMultiCallable[
|
|
192
|
+
messages_pb2.ListSchedulesRequest,
|
|
193
|
+
messages_pb2.ListSchedulesResponse,
|
|
194
|
+
],
|
|
195
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
196
|
+
messages_pb2.ListSchedulesRequest,
|
|
197
|
+
messages_pb2.ListSchedulesResponse,
|
|
198
|
+
],
|
|
199
|
+
default=grpc.UnaryUnaryMultiCallable[
|
|
200
|
+
messages_pb2.ListSchedulesRequest,
|
|
201
|
+
messages_pb2.ListSchedulesResponse,
|
|
202
|
+
],
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
class WorkflowServiceStub(
|
|
206
|
+
typing.Generic[
|
|
207
|
+
_WorkflowServiceRegisterWorkflowType,
|
|
208
|
+
_WorkflowServiceWaitForInstanceType,
|
|
209
|
+
_WorkflowServiceRegisterScheduleType,
|
|
210
|
+
_WorkflowServiceUpdateScheduleStatusType,
|
|
211
|
+
_WorkflowServiceDeleteScheduleType,
|
|
212
|
+
_WorkflowServiceListSchedulesType,
|
|
213
|
+
]
|
|
214
|
+
):
|
|
215
|
+
"""Workflow management service for client operations."""
|
|
216
|
+
|
|
217
|
+
@typing.overload
|
|
218
|
+
def __init__(
|
|
219
|
+
self: WorkflowServiceStub[
|
|
220
|
+
grpc.UnaryUnaryMultiCallable[
|
|
221
|
+
messages_pb2.RegisterWorkflowRequest,
|
|
222
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
223
|
+
],
|
|
224
|
+
grpc.UnaryUnaryMultiCallable[
|
|
225
|
+
messages_pb2.WaitForInstanceRequest,
|
|
226
|
+
messages_pb2.WaitForInstanceResponse,
|
|
227
|
+
],
|
|
228
|
+
grpc.UnaryUnaryMultiCallable[
|
|
229
|
+
messages_pb2.RegisterScheduleRequest,
|
|
230
|
+
messages_pb2.RegisterScheduleResponse,
|
|
231
|
+
],
|
|
232
|
+
grpc.UnaryUnaryMultiCallable[
|
|
233
|
+
messages_pb2.UpdateScheduleStatusRequest,
|
|
234
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
235
|
+
],
|
|
236
|
+
grpc.UnaryUnaryMultiCallable[
|
|
237
|
+
messages_pb2.DeleteScheduleRequest,
|
|
238
|
+
messages_pb2.DeleteScheduleResponse,
|
|
239
|
+
],
|
|
240
|
+
grpc.UnaryUnaryMultiCallable[
|
|
241
|
+
messages_pb2.ListSchedulesRequest,
|
|
242
|
+
messages_pb2.ListSchedulesResponse,
|
|
243
|
+
],
|
|
244
|
+
],
|
|
245
|
+
channel: grpc.Channel,
|
|
246
|
+
) -> None: ...
|
|
247
|
+
@typing.overload
|
|
248
|
+
def __init__(
|
|
249
|
+
self: WorkflowServiceStub[
|
|
250
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
251
|
+
messages_pb2.RegisterWorkflowRequest,
|
|
252
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
253
|
+
],
|
|
254
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
255
|
+
messages_pb2.WaitForInstanceRequest,
|
|
256
|
+
messages_pb2.WaitForInstanceResponse,
|
|
257
|
+
],
|
|
258
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
259
|
+
messages_pb2.RegisterScheduleRequest,
|
|
260
|
+
messages_pb2.RegisterScheduleResponse,
|
|
261
|
+
],
|
|
262
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
263
|
+
messages_pb2.UpdateScheduleStatusRequest,
|
|
264
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
265
|
+
],
|
|
266
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
267
|
+
messages_pb2.DeleteScheduleRequest,
|
|
268
|
+
messages_pb2.DeleteScheduleResponse,
|
|
269
|
+
],
|
|
270
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
271
|
+
messages_pb2.ListSchedulesRequest,
|
|
272
|
+
messages_pb2.ListSchedulesResponse,
|
|
273
|
+
],
|
|
274
|
+
],
|
|
275
|
+
channel: grpc.aio.Channel,
|
|
276
|
+
) -> None: ...
|
|
277
|
+
|
|
278
|
+
RegisterWorkflow: _WorkflowServiceRegisterWorkflowType
|
|
279
|
+
|
|
280
|
+
WaitForInstance: _WorkflowServiceWaitForInstanceType
|
|
281
|
+
|
|
282
|
+
RegisterSchedule: _WorkflowServiceRegisterScheduleType
|
|
283
|
+
"""Schedule management"""
|
|
284
|
+
|
|
285
|
+
UpdateScheduleStatus: _WorkflowServiceUpdateScheduleStatusType
|
|
286
|
+
|
|
287
|
+
DeleteSchedule: _WorkflowServiceDeleteScheduleType
|
|
288
|
+
|
|
289
|
+
ListSchedules: _WorkflowServiceListSchedulesType
|
|
290
|
+
|
|
291
|
+
WorkflowServiceAsyncStub: typing_extensions.TypeAlias = WorkflowServiceStub[
|
|
292
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
293
|
+
messages_pb2.RegisterWorkflowRequest,
|
|
294
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
295
|
+
],
|
|
296
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
297
|
+
messages_pb2.WaitForInstanceRequest,
|
|
298
|
+
messages_pb2.WaitForInstanceResponse,
|
|
299
|
+
],
|
|
300
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
301
|
+
messages_pb2.RegisterScheduleRequest,
|
|
302
|
+
messages_pb2.RegisterScheduleResponse,
|
|
303
|
+
],
|
|
304
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
305
|
+
messages_pb2.UpdateScheduleStatusRequest,
|
|
306
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
307
|
+
],
|
|
308
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
309
|
+
messages_pb2.DeleteScheduleRequest,
|
|
310
|
+
messages_pb2.DeleteScheduleResponse,
|
|
311
|
+
],
|
|
312
|
+
grpc.aio.UnaryUnaryMultiCallable[
|
|
313
|
+
messages_pb2.ListSchedulesRequest,
|
|
314
|
+
messages_pb2.ListSchedulesResponse,
|
|
315
|
+
],
|
|
316
|
+
]
|
|
317
|
+
|
|
318
|
+
class WorkflowServiceServicer(metaclass=abc.ABCMeta):
|
|
319
|
+
"""Workflow management service for client operations."""
|
|
320
|
+
|
|
321
|
+
@abc.abstractmethod
|
|
322
|
+
def RegisterWorkflow(
|
|
323
|
+
self,
|
|
324
|
+
request: messages_pb2.RegisterWorkflowRequest,
|
|
325
|
+
context: _ServicerContext,
|
|
326
|
+
) -> typing.Union[
|
|
327
|
+
messages_pb2.RegisterWorkflowResponse,
|
|
328
|
+
collections.abc.Awaitable[messages_pb2.RegisterWorkflowResponse],
|
|
329
|
+
]: ...
|
|
330
|
+
@abc.abstractmethod
|
|
331
|
+
def WaitForInstance(
|
|
332
|
+
self,
|
|
333
|
+
request: messages_pb2.WaitForInstanceRequest,
|
|
334
|
+
context: _ServicerContext,
|
|
335
|
+
) -> typing.Union[
|
|
336
|
+
messages_pb2.WaitForInstanceResponse,
|
|
337
|
+
collections.abc.Awaitable[messages_pb2.WaitForInstanceResponse],
|
|
338
|
+
]: ...
|
|
339
|
+
@abc.abstractmethod
|
|
340
|
+
def RegisterSchedule(
|
|
341
|
+
self,
|
|
342
|
+
request: messages_pb2.RegisterScheduleRequest,
|
|
343
|
+
context: _ServicerContext,
|
|
344
|
+
) -> typing.Union[
|
|
345
|
+
messages_pb2.RegisterScheduleResponse,
|
|
346
|
+
collections.abc.Awaitable[messages_pb2.RegisterScheduleResponse],
|
|
347
|
+
]:
|
|
348
|
+
"""Schedule management"""
|
|
349
|
+
|
|
350
|
+
@abc.abstractmethod
|
|
351
|
+
def UpdateScheduleStatus(
|
|
352
|
+
self,
|
|
353
|
+
request: messages_pb2.UpdateScheduleStatusRequest,
|
|
354
|
+
context: _ServicerContext,
|
|
355
|
+
) -> typing.Union[
|
|
356
|
+
messages_pb2.UpdateScheduleStatusResponse,
|
|
357
|
+
collections.abc.Awaitable[messages_pb2.UpdateScheduleStatusResponse],
|
|
358
|
+
]: ...
|
|
359
|
+
@abc.abstractmethod
|
|
360
|
+
def DeleteSchedule(
|
|
361
|
+
self,
|
|
362
|
+
request: messages_pb2.DeleteScheduleRequest,
|
|
363
|
+
context: _ServicerContext,
|
|
364
|
+
) -> typing.Union[
|
|
365
|
+
messages_pb2.DeleteScheduleResponse,
|
|
366
|
+
collections.abc.Awaitable[messages_pb2.DeleteScheduleResponse],
|
|
367
|
+
]: ...
|
|
368
|
+
@abc.abstractmethod
|
|
369
|
+
def ListSchedules(
|
|
370
|
+
self,
|
|
371
|
+
request: messages_pb2.ListSchedulesRequest,
|
|
372
|
+
context: _ServicerContext,
|
|
373
|
+
) -> typing.Union[
|
|
374
|
+
messages_pb2.ListSchedulesResponse,
|
|
375
|
+
collections.abc.Awaitable[messages_pb2.ListSchedulesResponse],
|
|
376
|
+
]: ...
|
|
377
|
+
|
|
378
|
+
def add_WorkflowServiceServicer_to_server(
|
|
379
|
+
servicer: WorkflowServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]
|
|
380
|
+
) -> None: ...
|
rappel/__init__.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Public API for user-defined rappel actions."""
|
|
2
|
+
|
|
3
|
+
from . import bridge # noqa: F401
|
|
4
|
+
from . import workflow_runtime as _workflow_runtime # noqa: F401
|
|
5
|
+
from .actions import (
|
|
6
|
+
ActionResultPayload,
|
|
7
|
+
action,
|
|
8
|
+
deserialize_result_payload,
|
|
9
|
+
serialize_error_payload,
|
|
10
|
+
serialize_result_payload,
|
|
11
|
+
)
|
|
12
|
+
from .dependencies import Depend, provide_dependencies
|
|
13
|
+
from .exceptions import ExhaustedRetries, ExhaustedRetriesError
|
|
14
|
+
from .ir_builder import UnsupportedPatternError, build_workflow_ir
|
|
15
|
+
from .registry import registry
|
|
16
|
+
from .schedule import (
|
|
17
|
+
ScheduleInfo,
|
|
18
|
+
delete_schedule,
|
|
19
|
+
list_schedules,
|
|
20
|
+
pause_schedule,
|
|
21
|
+
resume_schedule,
|
|
22
|
+
schedule_workflow,
|
|
23
|
+
)
|
|
24
|
+
from .workflow import (
|
|
25
|
+
RetryPolicy,
|
|
26
|
+
Workflow,
|
|
27
|
+
workflow,
|
|
28
|
+
workflow_registry,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"action",
|
|
33
|
+
"registry",
|
|
34
|
+
"ActionResultPayload",
|
|
35
|
+
"Workflow",
|
|
36
|
+
"workflow",
|
|
37
|
+
"workflow_registry",
|
|
38
|
+
"RetryPolicy",
|
|
39
|
+
"build_workflow_ir",
|
|
40
|
+
"serialize_result_payload",
|
|
41
|
+
"deserialize_result_payload",
|
|
42
|
+
"serialize_error_payload",
|
|
43
|
+
"Depend",
|
|
44
|
+
"provide_dependencies",
|
|
45
|
+
"bridge",
|
|
46
|
+
"ExhaustedRetries",
|
|
47
|
+
"ExhaustedRetriesError",
|
|
48
|
+
"UnsupportedPatternError",
|
|
49
|
+
# Schedule functions
|
|
50
|
+
"schedule_workflow",
|
|
51
|
+
"pause_schedule",
|
|
52
|
+
"resume_schedule",
|
|
53
|
+
"delete_schedule",
|
|
54
|
+
"list_schedules",
|
|
55
|
+
"ScheduleInfo",
|
|
56
|
+
]
|
rappel/actions.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import inspect
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from typing import Any, Callable, Optional, TypeVar, overload
|
|
4
|
+
|
|
5
|
+
from proto import messages_pb2 as pb2
|
|
6
|
+
|
|
7
|
+
from .registry import AsyncAction, registry
|
|
8
|
+
from .serialization import dumps, loads
|
|
9
|
+
|
|
10
|
+
TAsync = TypeVar("TAsync", bound=AsyncAction)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@dataclass
|
|
14
|
+
class ActionResultPayload:
|
|
15
|
+
result: Any | None
|
|
16
|
+
error: dict[str, str] | None
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def serialize_result_payload(value: Any) -> pb2.WorkflowArguments:
|
|
20
|
+
"""Serialize a successful action result."""
|
|
21
|
+
arguments = pb2.WorkflowArguments()
|
|
22
|
+
entry = arguments.arguments.add()
|
|
23
|
+
entry.key = "result"
|
|
24
|
+
entry.value.CopyFrom(dumps(value))
|
|
25
|
+
return arguments
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def serialize_error_payload(_action: str, exc: BaseException) -> pb2.WorkflowArguments:
|
|
29
|
+
"""Serialize an error raised during action execution."""
|
|
30
|
+
arguments = pb2.WorkflowArguments()
|
|
31
|
+
entry = arguments.arguments.add()
|
|
32
|
+
entry.key = "error"
|
|
33
|
+
entry.value.CopyFrom(dumps(exc))
|
|
34
|
+
return arguments
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def deserialize_result_payload(payload: pb2.WorkflowArguments | None) -> ActionResultPayload:
|
|
38
|
+
"""Deserialize WorkflowArguments produced by serialize_result_payload/error."""
|
|
39
|
+
if payload is None:
|
|
40
|
+
return ActionResultPayload(result=None, error=None)
|
|
41
|
+
values = {entry.key: entry.value for entry in payload.arguments}
|
|
42
|
+
if "error" in values:
|
|
43
|
+
error_value = values["error"]
|
|
44
|
+
data = loads(error_value)
|
|
45
|
+
if not isinstance(data, dict):
|
|
46
|
+
raise ValueError("error payload must deserialize to a mapping")
|
|
47
|
+
return ActionResultPayload(result=None, error=data)
|
|
48
|
+
result_value = values.get("result")
|
|
49
|
+
if result_value is None:
|
|
50
|
+
raise ValueError("result payload missing 'result' field")
|
|
51
|
+
return ActionResultPayload(result=loads(result_value), error=None)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@overload
|
|
55
|
+
def action(func: TAsync, /) -> TAsync: ...
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@overload
|
|
59
|
+
def action(*, name: Optional[str] = None) -> Callable[[TAsync], TAsync]: ...
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def action(
|
|
63
|
+
func: Optional[TAsync] = None,
|
|
64
|
+
*,
|
|
65
|
+
name: Optional[str] = None,
|
|
66
|
+
) -> Callable[[TAsync], TAsync] | TAsync:
|
|
67
|
+
"""Decorator for registering async actions."""
|
|
68
|
+
|
|
69
|
+
def decorator(target: TAsync) -> TAsync:
|
|
70
|
+
if not inspect.iscoroutinefunction(target):
|
|
71
|
+
raise TypeError(f"action '{target.__name__}' must be defined with 'async def'")
|
|
72
|
+
action_name = name or target.__name__
|
|
73
|
+
action_module = target.__module__
|
|
74
|
+
registry.register(action_module, action_name, target)
|
|
75
|
+
target.__rappel_action_name__ = action_name
|
|
76
|
+
target.__rappel_action_module__ = action_module
|
|
77
|
+
return target
|
|
78
|
+
|
|
79
|
+
if func is not None:
|
|
80
|
+
return decorator(func)
|
|
81
|
+
return decorator
|
|
Binary file
|
|
Binary file
|
|
Binary file
|