Skip to content

Commit 49e71de

Browse files
committed
Merge upstream/main into signal_decorator
Resolved conflicts: - Kept signal decorator functionality from signal_decorator branch - Adopted frozen=True convention for WorkflowInfo from upstream - Removed test_workflow_engine_integration.py as upstream reorganized tests
2 parents 0bd5e04 + 890fe83 commit 49e71de

20 files changed

+959
-810
lines changed

cadence/_internal/workflow/context.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from contextlib import contextmanager
12
from datetime import timedelta
23
from math import ceil
3-
from typing import Optional, Any, Unpack, Type, cast
4+
from typing import Iterator, Optional, Any, Unpack, Type, cast
45

56
from cadence._internal.workflow.statemachine.decision_manager import DecisionManager
67
from cadence._internal.workflow.decisions_helper import DecisionsHelper
@@ -15,13 +16,12 @@ class Context(WorkflowContext):
1516
def __init__(
1617
self,
1718
info: WorkflowInfo,
18-
decision_helper: DecisionsHelper,
1919
decision_manager: DecisionManager,
2020
):
2121
self._info = info
2222
self._replay_mode = True
2323
self._replay_current_time_milliseconds: Optional[int] = None
24-
self._decision_helper = decision_helper
24+
self._decision_helper = DecisionsHelper()
2525
self._decision_manager = decision_manager
2626

2727
def info(self) -> WorkflowInfo:
@@ -110,6 +110,12 @@ def get_replay_current_time_milliseconds(self) -> Optional[int]:
110110
"""Get the current replay time in milliseconds."""
111111
return self._replay_current_time_milliseconds
112112

113+
@contextmanager
114+
def _activate(self) -> Iterator["Context"]:
115+
token = WorkflowContext._var.set(self)
116+
yield self
117+
WorkflowContext._var.reset(token)
118+
113119

114120
def _round_to_nearest_second(delta: timedelta) -> timedelta:
115121
return timedelta(seconds=ceil(delta.total_seconds()))

cadence/_internal/workflow/decision_events_iterator.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
from cadence._internal.workflow.history_event_iterator import HistoryEventsIterator
1313
from cadence.api.v1.history_pb2 import HistoryEvent
14-
from cadence.api.v1.service_worker_pb2 import PollForDecisionTaskResponse
1514

1615

1716
@dataclass
@@ -44,10 +43,8 @@ class DecisionEventsIterator(Iterator[DecisionEvents]):
4443

4544
def __init__(
4645
self,
47-
decision_task: PollForDecisionTaskResponse,
4846
events: List[HistoryEvent],
4947
):
50-
self._decision_task = decision_task
5148
self._events: HistoryEventsIterator = HistoryEventsIterator(events)
5249
self._next_decision_event_id: Optional[int] = None
5350
self._replay_current_time_milliseconds: Optional[int] = None

0 commit comments

Comments
 (0)