dbos 0.17.0a2__py3-none-any.whl → 0.17.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 +6 -4
- dbos/_outcome.py +21 -15
- {dbos-0.17.0a2.dist-info → dbos-0.17.0a3.dist-info}/METADATA +1 -1
- {dbos-0.17.0a2.dist-info → dbos-0.17.0a3.dist-info}/RECORD +7 -7
- {dbos-0.17.0a2.dist-info → dbos-0.17.0a3.dist-info}/WHEEL +0 -0
- {dbos-0.17.0a2.dist-info → dbos-0.17.0a3.dist-info}/entry_points.txt +0 -0
- {dbos-0.17.0a2.dist-info → dbos-0.17.0a3.dist-info}/licenses/LICENSE +0 -0
dbos/_core.py
CHANGED
|
@@ -21,7 +21,7 @@ from typing import (
|
|
|
21
21
|
overload,
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
from dbos._outcome import Immediate, Outcome, Pending
|
|
24
|
+
from dbos._outcome import Immediate, NoResult, Outcome, Pending
|
|
25
25
|
|
|
26
26
|
from ._app_db import ApplicationDatabase, TransactionResultInternal
|
|
27
27
|
|
|
@@ -719,7 +719,7 @@ def decorate_step(
|
|
|
719
719
|
finally:
|
|
720
720
|
dbos._sys_db.record_operation_result(step_output)
|
|
721
721
|
|
|
722
|
-
def check_existing_result() ->
|
|
722
|
+
def check_existing_result() -> Union[NoResult, R]:
|
|
723
723
|
ctx = assert_current_dbos_context()
|
|
724
724
|
recorded_output = dbos._sys_db.check_operation_execution(
|
|
725
725
|
ctx.workflow_id, ctx.function_id
|
|
@@ -734,14 +734,16 @@ def decorate_step(
|
|
|
734
734
|
)
|
|
735
735
|
raise deserialized_error
|
|
736
736
|
elif recorded_output["output"] is not None:
|
|
737
|
-
return
|
|
737
|
+
return cast(
|
|
738
|
+
R, _serialization.deserialize(recorded_output["output"])
|
|
739
|
+
)
|
|
738
740
|
else:
|
|
739
741
|
raise Exception("Output and error are both None")
|
|
740
742
|
else:
|
|
741
743
|
dbos.logger.debug(
|
|
742
744
|
f"Running step, id: {ctx.function_id}, name: {attributes['name']}"
|
|
743
745
|
)
|
|
744
|
-
return
|
|
746
|
+
return NoResult()
|
|
745
747
|
|
|
746
748
|
stepOutcome = Outcome[R].make(functools.partial(func, *args, **kwargs))
|
|
747
749
|
if retries_allowed:
|
dbos/_outcome.py
CHANGED
|
@@ -4,12 +4,20 @@ import inspect
|
|
|
4
4
|
import time
|
|
5
5
|
from typing import Any, Callable, Coroutine, Optional, Protocol, TypeVar, Union, cast
|
|
6
6
|
|
|
7
|
-
from . import _serialization
|
|
8
|
-
|
|
9
7
|
T = TypeVar("T")
|
|
10
8
|
R = TypeVar("R")
|
|
11
9
|
|
|
12
10
|
|
|
11
|
+
class NoResult:
|
|
12
|
+
_instance: Optional["NoResult"] = None
|
|
13
|
+
__slots__ = ()
|
|
14
|
+
|
|
15
|
+
def __new__(cls, *args: Any, **kwargs: Any) -> "NoResult":
|
|
16
|
+
if not cls._instance:
|
|
17
|
+
cls._instance = super(NoResult, cls).__new__(cls, *args, **kwargs)
|
|
18
|
+
return cls._instance
|
|
19
|
+
|
|
20
|
+
|
|
13
21
|
# define Outcome protocol w/ common composition methods
|
|
14
22
|
class Outcome(Protocol[T]):
|
|
15
23
|
|
|
@@ -30,7 +38,9 @@ class Outcome(Protocol[T]):
|
|
|
30
38
|
exceeded_retries: Callable[[int], BaseException],
|
|
31
39
|
) -> "Outcome[T]": ...
|
|
32
40
|
|
|
33
|
-
def intercept(
|
|
41
|
+
def intercept(
|
|
42
|
+
self, interceptor: Callable[[], Union[NoResult, T]]
|
|
43
|
+
) -> "Outcome[T]": ...
|
|
34
44
|
|
|
35
45
|
def __call__(self) -> Union[T, Coroutine[Any, Any, T]]: ...
|
|
36
46
|
|
|
@@ -61,14 +71,14 @@ class Immediate(Outcome[T]):
|
|
|
61
71
|
|
|
62
72
|
@staticmethod
|
|
63
73
|
def _intercept(
|
|
64
|
-
func: Callable[[], T], interceptor: Callable[[],
|
|
74
|
+
func: Callable[[], T], interceptor: Callable[[], Union[NoResult, T]]
|
|
65
75
|
) -> T:
|
|
66
76
|
intercepted = interceptor()
|
|
67
|
-
return (
|
|
68
|
-
cast(T, _serialization.deserialize(intercepted)) if intercepted else func()
|
|
69
|
-
)
|
|
77
|
+
return intercepted if not isinstance(intercepted, NoResult) else func()
|
|
70
78
|
|
|
71
|
-
def intercept(
|
|
79
|
+
def intercept(
|
|
80
|
+
self, interceptor: Callable[[], Union[NoResult, T]]
|
|
81
|
+
) -> "Immediate[T]":
|
|
72
82
|
return Immediate[T](lambda: Immediate._intercept(self._func, interceptor))
|
|
73
83
|
|
|
74
84
|
@staticmethod
|
|
@@ -157,16 +167,12 @@ class Pending(Outcome[T]):
|
|
|
157
167
|
@staticmethod
|
|
158
168
|
async def _intercept(
|
|
159
169
|
func: Callable[[], Coroutine[Any, Any, T]],
|
|
160
|
-
interceptor: Callable[[],
|
|
170
|
+
interceptor: Callable[[], Union[NoResult, T]],
|
|
161
171
|
) -> T:
|
|
162
172
|
intercepted = await asyncio.to_thread(interceptor)
|
|
163
|
-
return (
|
|
164
|
-
cast(T, _serialization.deserialize(intercepted))
|
|
165
|
-
if intercepted
|
|
166
|
-
else await func()
|
|
167
|
-
)
|
|
173
|
+
return intercepted if not isinstance(intercepted, NoResult) else await func()
|
|
168
174
|
|
|
169
|
-
def intercept(self, interceptor: Callable[[],
|
|
175
|
+
def intercept(self, interceptor: Callable[[], Union[NoResult, T]]) -> "Pending[T]":
|
|
170
176
|
return Pending[T](lambda: Pending._intercept(self._func, interceptor))
|
|
171
177
|
|
|
172
178
|
@staticmethod
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
dbos-0.17.
|
|
2
|
-
dbos-0.17.
|
|
3
|
-
dbos-0.17.
|
|
4
|
-
dbos-0.17.
|
|
1
|
+
dbos-0.17.0a3.dist-info/METADATA,sha256=4ipySeA1lNrYu6gB5gKhxviyyakdlxPVVErVltArttA,5022
|
|
2
|
+
dbos-0.17.0a3.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
|
|
3
|
+
dbos-0.17.0a3.dist-info/entry_points.txt,sha256=z6GcVANQV7Uw_82H9Ob2axJX6V3imftyZsljdh-M1HU,54
|
|
4
|
+
dbos-0.17.0a3.dist-info/licenses/LICENSE,sha256=VGZit_a5-kdw9WT6fY5jxAWVwGQzgLFyPWrcVVUhVNU,1067
|
|
5
5
|
dbos/__init__.py,sha256=CxRHBHEthPL4PZoLbZhp3rdm44-KkRTT2-7DkK9d4QQ,724
|
|
6
6
|
dbos/_admin_server.py,sha256=DOgzVp9kmwiebQqmJB1LcrZnGTxSMbZiGXdenc1wZDg,3163
|
|
7
7
|
dbos/_app_db.py,sha256=_tv2vmPjjiaikwgxH3mqxgJ4nUUcG2-0uMXKWCqVu1c,5509
|
|
8
8
|
dbos/_classproperty.py,sha256=f0X-_BySzn3yFDRKB2JpCbLYQ9tLwt1XftfshvY7CBs,626
|
|
9
9
|
dbos/_context.py,sha256=KV3fd3-Rv6EWrYDUdHARxltSlNZGNtQtNSqeQ-gkXE8,18049
|
|
10
|
-
dbos/_core.py,sha256=
|
|
10
|
+
dbos/_core.py,sha256=NWJFQX5bECBvKlYH9pVmNJgmqFGYPnkHnOGjOlOQ3Ag,33504
|
|
11
11
|
dbos/_croniter.py,sha256=hbhgfsHBqclUS8VeLnJ9PSE9Z54z6mi4nnrr1aUXn0k,47561
|
|
12
12
|
dbos/_dbos.py,sha256=riYx_dkYFzqeVDYpmcA5ABdAYQFhwyDi4AwxIihDNKA,34809
|
|
13
13
|
dbos/_dbos_config.py,sha256=f37eccN3JpCA32kRdQ4UsERjhYGcdLWv-N21ijnDZmY,6406
|
|
@@ -25,7 +25,7 @@ dbos/_migrations/versions/a3b18ad34abe_added_triggers.py,sha256=Rv0ZsZYZ_WdgGEUL
|
|
|
25
25
|
dbos/_migrations/versions/d76646551a6b_job_queue_limiter.py,sha256=8PyFi8rd6CN-mUro43wGhsg5wcQWKZPRHD6jw8R5pVc,986
|
|
26
26
|
dbos/_migrations/versions/d76646551a6c_workflow_queue.py,sha256=G942nophZ2uC2vc4hGBC02Ptng1715roTjY3xiyzZU4,729
|
|
27
27
|
dbos/_migrations/versions/eab0cc1d9a14_job_queue.py,sha256=uvhFOtqbBreCePhAxZfIT0qCAI7BiZTou9wt6QnbY7c,1412
|
|
28
|
-
dbos/_outcome.py,sha256=
|
|
28
|
+
dbos/_outcome.py,sha256=FDMgWVjZ06vm9xO-38H17mTqBImUYQxgKs_bDCSIAhE,6648
|
|
29
29
|
dbos/_queue.py,sha256=5NZ6RfKQd8LQD8EeUXgrwu86r0AadKEqPIMmL_1ORuw,1956
|
|
30
30
|
dbos/_recovery.py,sha256=jbzGYxICA2drzyzlBSy2UiXhKV_16tBVacKQdTkqf-w,2008
|
|
31
31
|
dbos/_registrations.py,sha256=mei6q6_3R5uei8i_Wo_TqGZs85s10shOekDX41sFYD0,6642
|
|
@@ -52,4 +52,4 @@ dbos/cli.py,sha256=em1uAxrp5yyg53V7ZpmHFtqD6OJp2cMJkG9vGJPoFTA,10904
|
|
|
52
52
|
dbos/dbos-config.schema.json,sha256=tS7x-bdFbFvpobcs3pIOhwun3yr_ndvTEYOn4BJjTzs,5889
|
|
53
53
|
dbos/py.typed,sha256=QfzXT1Ktfk3Rj84akygc7_42z0lRpCq0Ilh8OXI6Zas,44
|
|
54
54
|
version/__init__.py,sha256=L4sNxecRuqdtSFdpUGX3TtBi9KL3k7YsZVIvv-fv9-A,1678
|
|
55
|
-
dbos-0.17.
|
|
55
|
+
dbos-0.17.0a3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|