Skip to content

Commit 4760964

Browse files
committed
Make list_workflows return iterator over both activity types
1 parent 519a359 commit 4760964

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

temporalio/client.py

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,13 +2881,17 @@ async def workflow_handle(self) -> WorkflowHandle[SelfType, ReturnType]:
28812881

28822882

28832883
class ActivityExecutionAsyncIterator:
2884-
"""Asynchronous iterator for :py:class:`ActivityExecution` values."""
2884+
"""Asynchronous iterator for activity execution values.
2885+
2886+
Returns either :py:class:`ActivityExecution` (for standalone activities) or
2887+
:py:class:`WorkflowActivityExecution` (for activities started by workflows).
2888+
"""
28852889

28862890
def __aiter__(self) -> ActivityExecutionAsyncIterator:
28872891
"""Return self as the iterator."""
28882892
return self
28892893

2890-
async def __anext__(self) -> ActivityExecution:
2894+
async def __anext__(self) -> Union[ActivityExecution, WorkflowActivityExecution]:
28912895
"""Return the next execution on this iterator.
28922896
28932897
Fetch next page if necessary.
@@ -2899,7 +2903,7 @@ async def __anext__(self) -> ActivityExecution:
28992903
# https://github.com/temporalio/api/pull/640/files
29002904
@dataclass(frozen=True)
29012905
class ActivityExecution:
2902-
"""Info for a single activity execution from list response."""
2906+
"""Info for a standalone activity execution from list response."""
29032907

29042908
activity_id: str
29052909
"""Activity ID."""
@@ -2932,6 +2936,41 @@ class ActivityExecution:
29322936
"""Duration from scheduled to close time, only populated if closed."""
29332937

29342938

2939+
@dataclass(frozen=True)
2940+
class WorkflowActivityExecution:
2941+
"""Info for a workflow activity execution from list response."""
2942+
2943+
activity_id: str
2944+
"""Activity ID."""
2945+
2946+
run_id: str
2947+
"""Run ID of the activity."""
2948+
2949+
activity_type: str
2950+
"""Type name of the activity."""
2951+
2952+
workflow_id: str
2953+
"""ID of the workflow that started this activity."""
2954+
2955+
workflow_run_id: Optional[str]
2956+
"""Run ID of the workflow that started this activity."""
2957+
2958+
scheduled_time: datetime
2959+
"""Time the activity was originally scheduled."""
2960+
2961+
close_time: Optional[datetime]
2962+
"""Time the activity reached a terminal status, if closed."""
2963+
2964+
status: temporalio.common.ActivityExecutionStatus
2965+
"""Current status of the activity."""
2966+
2967+
task_queue: str
2968+
"""Task queue the activity was scheduled on."""
2969+
2970+
execution_duration: Optional[timedelta]
2971+
"""Duration from scheduled to close time, only populated if closed."""
2972+
2973+
29352974
@dataclass(frozen=True)
29362975
class ActivityExecutionDescription:
29372976
"""Detailed information about an activity execution from describe response."""

0 commit comments

Comments
 (0)