Skip to content

Commit 2bc375b

Browse files
committed
remove historyHelper
Signed-off-by: Tim Li <[email protected]>
1 parent 29bdadc commit 2bc375b

File tree

2 files changed

+4
-89
lines changed

2 files changed

+4
-89
lines changed

cadence/_internal/workflow/decision_events_iterator.py

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -240,56 +240,6 @@ async def __anext__(self) -> DecisionEvents:
240240
return await self.next_decision_events()
241241

242242

243-
class HistoryHelper:
244-
"""
245-
Main helper class for processing workflow history events.
246-
247-
Provides the primary interface for iterating through decision events
248-
and managing workflow history processing.
249-
"""
250-
251-
def __init__(self, decision_task: PollForDecisionTaskResponse, client: Client):
252-
self._decision_task = decision_task
253-
self._client = client
254-
self._decision_events_iterator: Optional[DecisionEventsIterator] = None
255-
256-
async def get_decision_events_iterator(self) -> DecisionEventsIterator:
257-
"""Get the decision events iterator for this history."""
258-
if self._decision_events_iterator is None:
259-
self._decision_events_iterator = DecisionEventsIterator(
260-
self._decision_task, self._client
261-
)
262-
await self._decision_events_iterator._ensure_initialized()
263-
264-
return self._decision_events_iterator
265-
266-
async def get_all_decision_events(self) -> List[DecisionEvents]:
267-
"""Get all decision events as a list."""
268-
iterator = await self.get_decision_events_iterator()
269-
all_decision_events = []
270-
271-
while await iterator.has_next_decision_events():
272-
decision_events = await iterator.next_decision_events()
273-
all_decision_events.append(decision_events)
274-
275-
return all_decision_events
276-
277-
def get_workflow_execution(self):
278-
"""Get the workflow execution from the decision task."""
279-
return self._decision_task.workflow_execution
280-
281-
def get_workflow_type(self):
282-
"""Get the workflow type from the decision task."""
283-
return self._decision_task.workflow_type
284-
285-
286-
# Factory function for easy creation
287-
async def create_history_helper(
288-
decision_task: PollForDecisionTaskResponse,
289-
client: Client
290-
) -> HistoryHelper:
291-
"""Create a HistoryHelper instance."""
292-
return HistoryHelper(decision_task, client)
293243

294244

295245
# Utility functions

tests/cadence/_internal/workflow/test_decision_events_iterator.py

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from cadence._internal.workflow.decision_events_iterator import (
1818
DecisionEvents,
1919
DecisionEventsIterator,
20-
HistoryHelper,
2120
is_decision_event,
2221
is_marker_event,
2322
extract_event_timestamp_millis
@@ -247,42 +246,6 @@ async def test_iterator_protocol(self, mock_client):
247246
assert len(decision_events_list) == 2
248247

249248

250-
class TestHistoryHelper:
251-
"""Test the HistoryHelper class."""
252-
253-
@pytest.mark.asyncio
254-
async def test_history_helper_creation(self, mock_client):
255-
"""Test HistoryHelper creation and basic functionality."""
256-
events = [
257-
create_mock_history_event(1, "decision_task_started"),
258-
create_mock_history_event(2, "decision_task_completed")
259-
]
260-
261-
decision_task = create_mock_decision_task(events)
262-
helper = HistoryHelper(decision_task, mock_client)
263-
264-
assert helper.get_workflow_execution() == decision_task.workflow_execution
265-
assert helper.get_workflow_type() == decision_task.workflow_type
266-
267-
@pytest.mark.asyncio
268-
async def test_get_all_decision_events(self, mock_client):
269-
"""Test getting all decision events as a list."""
270-
events = [
271-
create_mock_history_event(1, "decision_task_started"),
272-
create_mock_history_event(2, "decision_task_completed"),
273-
create_mock_history_event(3, "decision_task_started"),
274-
create_mock_history_event(4, "decision_task_completed")
275-
]
276-
277-
decision_task = create_mock_decision_task(events)
278-
helper = HistoryHelper(decision_task, mock_client)
279-
280-
all_decision_events = await helper.get_all_decision_events()
281-
282-
assert len(all_decision_events) == 2
283-
for decision_events in all_decision_events:
284-
assert isinstance(decision_events, DecisionEvents)
285-
assert len(decision_events.get_events()) == 2
286249

287250

288251
class TestUtilityFunctions:
@@ -360,9 +323,11 @@ async def test_complex_workflow_scenario(self, mock_client):
360323
]
361324

362325
decision_task = create_mock_decision_task(events)
363-
helper = HistoryHelper(decision_task, mock_client)
326+
iterator = DecisionEventsIterator(decision_task, mock_client)
364327

365-
all_decisions = await helper.get_all_decision_events()
328+
all_decisions = []
329+
async for decision_events in iterator:
330+
all_decisions.append(decision_events)
366331

367332
assert len(all_decisions) == 2
368333

0 commit comments

Comments
 (0)