dbos 1.14.0a2__py3-none-any.whl → 1.14.0a3__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.
- dbos/_core.py +3 -5
- dbos/_outcome.py +67 -13
- {dbos-1.14.0a2.dist-info → dbos-1.14.0a3.dist-info}/METADATA +1 -1
- {dbos-1.14.0a2.dist-info → dbos-1.14.0a3.dist-info}/RECORD +7 -7
- {dbos-1.14.0a2.dist-info → dbos-1.14.0a3.dist-info}/WHEEL +0 -0
- {dbos-1.14.0a2.dist-info → dbos-1.14.0a3.dist-info}/entry_points.txt +0 -0
- {dbos-1.14.0a2.dist-info → dbos-1.14.0a3.dist-info}/licenses/LICENSE +0 -0
dbos/_core.py
CHANGED
@@ -19,8 +19,6 @@ from typing import (
|
|
19
19
|
cast,
|
20
20
|
)
|
21
21
|
|
22
|
-
import psycopg
|
23
|
-
|
24
22
|
from dbos._outcome import Immediate, NoResult, Outcome, Pending
|
25
23
|
from dbos._utils import GlobalParams, retriable_postgres_exception
|
26
24
|
|
@@ -831,10 +829,10 @@ def workflow_wrapper(
|
|
831
829
|
return r
|
832
830
|
|
833
831
|
outcome = (
|
834
|
-
wfOutcome.wrap(init_wf)
|
832
|
+
wfOutcome.wrap(init_wf, dbos=dbos)
|
835
833
|
.also(DBOSAssumeRole(rr))
|
836
834
|
.also(enterWorkflowCtxMgr(attributes))
|
837
|
-
.then(record_get_result)
|
835
|
+
.then(record_get_result, dbos=dbos)
|
838
836
|
)
|
839
837
|
return outcome() # type: ignore
|
840
838
|
|
@@ -1146,7 +1144,7 @@ def decorate_step(
|
|
1146
1144
|
|
1147
1145
|
outcome = (
|
1148
1146
|
stepOutcome.then(record_step_result)
|
1149
|
-
.intercept(check_existing_result)
|
1147
|
+
.intercept(check_existing_result, dbos=dbos)
|
1150
1148
|
.also(EnterDBOSStep(attributes))
|
1151
1149
|
)
|
1152
1150
|
return outcome()
|
dbos/_outcome.py
CHANGED
@@ -2,9 +2,24 @@ import asyncio
|
|
2
2
|
import contextlib
|
3
3
|
import inspect
|
4
4
|
import time
|
5
|
-
from typing import
|
5
|
+
from typing import (
|
6
|
+
TYPE_CHECKING,
|
7
|
+
Any,
|
8
|
+
Callable,
|
9
|
+
Coroutine,
|
10
|
+
Optional,
|
11
|
+
Protocol,
|
12
|
+
TypeVar,
|
13
|
+
Union,
|
14
|
+
cast,
|
15
|
+
)
|
6
16
|
|
7
17
|
from dbos._context import EnterDBOSStepRetry
|
18
|
+
from dbos._error import DBOSException
|
19
|
+
from dbos._registrations import get_dbos_func_name
|
20
|
+
|
21
|
+
if TYPE_CHECKING:
|
22
|
+
from ._dbos import DBOS
|
8
23
|
|
9
24
|
T = TypeVar("T")
|
10
25
|
R = TypeVar("R")
|
@@ -24,10 +39,15 @@ class NoResult:
|
|
24
39
|
class Outcome(Protocol[T]):
|
25
40
|
|
26
41
|
def wrap(
|
27
|
-
self,
|
42
|
+
self,
|
43
|
+
before: Callable[[], Callable[[Callable[[], T]], R]],
|
44
|
+
*,
|
45
|
+
dbos: Optional["DBOS"] = None,
|
28
46
|
) -> "Outcome[R]": ...
|
29
47
|
|
30
|
-
def then(
|
48
|
+
def then(
|
49
|
+
self, next: Callable[[Callable[[], T]], R], *, dbos: Optional["DBOS"] = None
|
50
|
+
) -> "Outcome[R]": ...
|
31
51
|
|
32
52
|
def also(
|
33
53
|
self, cm: contextlib.AbstractContextManager[Any, bool]
|
@@ -41,7 +61,10 @@ class Outcome(Protocol[T]):
|
|
41
61
|
) -> "Outcome[T]": ...
|
42
62
|
|
43
63
|
def intercept(
|
44
|
-
self,
|
64
|
+
self,
|
65
|
+
interceptor: Callable[[], Union[NoResult, T]],
|
66
|
+
*,
|
67
|
+
dbos: Optional["DBOS"] = None,
|
45
68
|
) -> "Outcome[T]": ...
|
46
69
|
|
47
70
|
def __call__(self) -> Union[T, Coroutine[Any, Any, T]]: ...
|
@@ -63,11 +86,17 @@ class Immediate(Outcome[T]):
|
|
63
86
|
def __init__(self, func: Callable[[], T]):
|
64
87
|
self._func = func
|
65
88
|
|
66
|
-
def then(
|
89
|
+
def then(
|
90
|
+
self,
|
91
|
+
next: Callable[[Callable[[], T]], R],
|
92
|
+
dbos: Optional["DBOS"] = None,
|
93
|
+
) -> "Immediate[R]":
|
67
94
|
return Immediate(lambda: next(self._func))
|
68
95
|
|
69
96
|
def wrap(
|
70
|
-
self,
|
97
|
+
self,
|
98
|
+
before: Callable[[], Callable[[Callable[[], T]], R]],
|
99
|
+
dbos: Optional["DBOS"] = None,
|
71
100
|
) -> "Immediate[R]":
|
72
101
|
return Immediate(lambda: before()(self._func))
|
73
102
|
|
@@ -79,7 +108,10 @@ class Immediate(Outcome[T]):
|
|
79
108
|
return intercepted if not isinstance(intercepted, NoResult) else func()
|
80
109
|
|
81
110
|
def intercept(
|
82
|
-
self,
|
111
|
+
self,
|
112
|
+
interceptor: Callable[[], Union[NoResult, T]],
|
113
|
+
*,
|
114
|
+
dbos: Optional["DBOS"] = None,
|
83
115
|
) -> "Immediate[T]":
|
84
116
|
return Immediate[T](lambda: Immediate._intercept(self._func, interceptor))
|
85
117
|
|
@@ -142,7 +174,12 @@ class Pending(Outcome[T]):
|
|
142
174
|
async def _wrap(
|
143
175
|
func: Callable[[], Coroutine[Any, Any, T]],
|
144
176
|
before: Callable[[], Callable[[Callable[[], T]], R]],
|
177
|
+
*,
|
178
|
+
dbos: Optional["DBOS"] = None,
|
145
179
|
) -> R:
|
180
|
+
# Make sure the executor pool is configured correctly
|
181
|
+
if dbos is not None:
|
182
|
+
await dbos._configure_asyncio_thread_pool()
|
146
183
|
after = await asyncio.to_thread(before)
|
147
184
|
try:
|
148
185
|
value = await func()
|
@@ -151,12 +188,17 @@ class Pending(Outcome[T]):
|
|
151
188
|
return await asyncio.to_thread(after, lambda: Pending._raise(exp))
|
152
189
|
|
153
190
|
def wrap(
|
154
|
-
self,
|
191
|
+
self,
|
192
|
+
before: Callable[[], Callable[[Callable[[], T]], R]],
|
193
|
+
*,
|
194
|
+
dbos: Optional["DBOS"] = None,
|
155
195
|
) -> "Pending[R]":
|
156
|
-
return Pending[R](lambda: Pending._wrap(self._func, before))
|
196
|
+
return Pending[R](lambda: Pending._wrap(self._func, before, dbos=dbos))
|
157
197
|
|
158
|
-
def then(
|
159
|
-
|
198
|
+
def then(
|
199
|
+
self, next: Callable[[Callable[[], T]], R], *, dbos: Optional["DBOS"] = None
|
200
|
+
) -> "Pending[R]":
|
201
|
+
return Pending[R](lambda: Pending._wrap(self._func, lambda: next, dbos=dbos))
|
160
202
|
|
161
203
|
@staticmethod
|
162
204
|
async def _also( # type: ignore
|
@@ -173,12 +215,24 @@ class Pending(Outcome[T]):
|
|
173
215
|
async def _intercept(
|
174
216
|
func: Callable[[], Coroutine[Any, Any, T]],
|
175
217
|
interceptor: Callable[[], Union[NoResult, T]],
|
218
|
+
*,
|
219
|
+
dbos: Optional["DBOS"] = None,
|
176
220
|
) -> T:
|
221
|
+
# Make sure the executor pool is configured correctly
|
222
|
+
if dbos is not None:
|
223
|
+
await dbos._configure_asyncio_thread_pool()
|
177
224
|
intercepted = await asyncio.to_thread(interceptor)
|
178
225
|
return intercepted if not isinstance(intercepted, NoResult) else await func()
|
179
226
|
|
180
|
-
def intercept(
|
181
|
-
|
227
|
+
def intercept(
|
228
|
+
self,
|
229
|
+
interceptor: Callable[[], Union[NoResult, T]],
|
230
|
+
*,
|
231
|
+
dbos: Optional["DBOS"] = None,
|
232
|
+
) -> "Pending[T]":
|
233
|
+
return Pending[T](
|
234
|
+
lambda: Pending._intercept(self._func, interceptor, dbos=dbos)
|
235
|
+
)
|
182
236
|
|
183
237
|
@staticmethod
|
184
238
|
async def _retry(
|
@@ -1,7 +1,7 @@
|
|
1
|
-
dbos-1.14.
|
2
|
-
dbos-1.14.
|
3
|
-
dbos-1.14.
|
4
|
-
dbos-1.14.
|
1
|
+
dbos-1.14.0a3.dist-info/METADATA,sha256=ZOKRfAWkrYZnIaDxG7NDi3ALPULMzpnSeXKMTMowA8E,13268
|
2
|
+
dbos-1.14.0a3.dist-info/WHEEL,sha256=9P2ygRxDrTJz3gsagc0Z96ukrxjr-LFBGOgv3AuKlCA,90
|
3
|
+
dbos-1.14.0a3.dist-info/entry_points.txt,sha256=_QOQ3tVfEjtjBlr1jS4sHqHya9lI2aIEIWkz8dqYp14,58
|
4
|
+
dbos-1.14.0a3.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
|
5
5
|
dbos/__init__.py,sha256=NssPCubaBxdiKarOWa-wViz1hdJSkmBGcpLX_gQ4NeA,891
|
6
6
|
dbos/__main__.py,sha256=G7Exn-MhGrVJVDbgNlpzhfh8WMX_72t3_oJaFT9Lmt8,653
|
7
7
|
dbos/_admin_server.py,sha256=e8ELhcDWqR3_PNobnNgUvLGh5lzZq0yFSF6dvtzoQRI,16267
|
@@ -28,7 +28,7 @@ dbos/_client.py,sha256=_3Wc2QQc5VDcBuJ3cNb-lWg439OuITo2ex4Y7qb9l44,18800
|
|
28
28
|
dbos/_conductor/conductor.py,sha256=3E_hL3c9g9yWqKZkvI6KA0-ZzPMPRo06TOzT1esMiek,24114
|
29
29
|
dbos/_conductor/protocol.py,sha256=q3rgLxINFtWFigdOONc-4gX4vn66UmMlJQD6Kj8LnL4,7420
|
30
30
|
dbos/_context.py,sha256=IMboNgbCqTxfIORqeifE3da-Ce5siMz7MYMLPk5M-AQ,26851
|
31
|
-
dbos/_core.py,sha256=
|
31
|
+
dbos/_core.py,sha256=CG2z5V0xZ-5_2E4NXqGIVdb5bWoN_l_cGswk7diB6RU,48805
|
32
32
|
dbos/_croniter.py,sha256=XHAyUyibs_59sJQfSNWkP7rqQY6_XrlfuuCxk4jYqek,47559
|
33
33
|
dbos/_dbos.py,sha256=wKLN7W1ej6cyEOHnCtt3-awnU6SR6MQAlOvTTt5_N-E,58219
|
34
34
|
dbos/_dbos_config.py,sha256=_26ktif8qAZW4Ujg6dZfLkYO7dE4CI8b3IQbw_5YkpA,25710
|
@@ -42,7 +42,7 @@ dbos/_kafka.py,sha256=Gm4fHWl7gYb-i5BMvwNwm5Km3z8zQpseqdMgqgFjlGI,4252
|
|
42
42
|
dbos/_kafka_message.py,sha256=NYvOXNG3Qn7bghn1pv3fg4Pbs86ILZGcK4IB-MLUNu0,409
|
43
43
|
dbos/_logger.py,sha256=vvBL4kzJWBPtfcHIuL0nJAq5cgpeo_D3IiIUDicWLOg,4732
|
44
44
|
dbos/_migration.py,sha256=wJrSTYerlkYDFYmkTqo4a7n4WaKmqXh8BdkUEzgSEQQ,10898
|
45
|
-
dbos/_outcome.py,sha256=
|
45
|
+
dbos/_outcome.py,sha256=7HvosMfEHTh1U5P6xok7kFTGLwa2lPaul0YApb3UnN4,8191
|
46
46
|
dbos/_queue.py,sha256=0kJTPwXy3nZ4Epzt-lHky9M9S4L31645drPGFR8fIJY,4854
|
47
47
|
dbos/_recovery.py,sha256=K-wlFhdf4yGRm6cUzyhcTjQUS0xp2T5rdNMLiiBErYg,2882
|
48
48
|
dbos/_registrations.py,sha256=bEOntObnWaBylnebr5ZpcX2hk7OVLDd1z4BvW4_y3zA,7380
|
@@ -75,4 +75,4 @@ dbos/cli/migration.py,sha256=5GiyagLZkyVvDz3StYxtFdkFoKFCmh6eSXjzsIGhZ_A,3330
|
|
75
75
|
dbos/dbos-config.schema.json,sha256=LyUT1DOTaAwOP6suxQGS5KemVIqXGPyu_q7Hbo0neA8,6192
|
76
76
|
dbos/py.typed,sha256=QfzXT1Ktfk3Rj84akygc7_42z0lRpCq0Ilh8OXI6Zas,44
|
77
77
|
version/__init__.py,sha256=L4sNxecRuqdtSFdpUGX3TtBi9KL3k7YsZVIvv-fv9-A,1678
|
78
|
-
dbos-1.14.
|
78
|
+
dbos-1.14.0a3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|