@@ -106,7 +106,7 @@ class WorkflowStatus:
106106 updated_at : Optional [int ]
107107 # If this workflow was enqueued, on which queue
108108 queue_name : Optional [str ]
109- # The executor to most recently executed this workflow
109+ # The executor to most recently execute this workflow
110110 executor_id : Optional [str ]
111111 # The application version on which this workflow was started
112112 app_version : Optional [str ]
@@ -122,8 +122,6 @@ class WorkflowStatus:
122122 queue_partition_key : Optional [str ]
123123 # If this workflow was forked from another, that workflow's ID.
124124 forked_from : Optional [str ]
125- # If this workflow was forked to others, those workflows' IDs
126- forked_to : Optional [list [str ]]
127125
128126 # INTERNAL FIELDS
129127
@@ -213,6 +211,8 @@ def __init__(self) -> None:
213211 self .status : Optional [List [str ]] = None
214212 # The application version that ran this workflow.
215213 self .application_version : Optional [str ] = None
214+ # Get workflows forked from this workflow ID.
215+ self .forked_from : Optional [str ] = None
216216 # Return up to this many workflows IDs. IDs are ordered by workflow creation time.
217217 self .limit : Optional [int ] = None
218218 # Offset into the matching records for pagination
@@ -244,9 +244,9 @@ class StepInfo(TypedDict):
244244 error : Optional [Exception ]
245245 # If the step starts or retrieves the result of a workflow, its ID
246246 child_workflow_id : Optional [str ]
247- # The UNIX epoch timestamp at which this step started
247+ # The Unix epoch timestamp at which this step started
248248 started_at_epoch_ms : Optional [int ]
249- # The UNIX epoch timestamp at which this step completed
249+ # The Unix epoch timestamp at which this step completed
250250 completed_at_epoch_ms : Optional [int ]
251251
252252
@@ -931,6 +931,10 @@ def get_workflows(
931931 SystemSchema .workflow_status .c .application_version
932932 == input .application_version
933933 )
934+ if input .forked_from :
935+ query = query .where (
936+ SystemSchema .workflow_status .c .forked_from == input .forked_from
937+ )
934938 if input .workflow_ids :
935939 query = query .where (
936940 SystemSchema .workflow_status .c .workflow_uuid .in_ (input .workflow_ids )
@@ -997,29 +1001,6 @@ def get_workflows(
9971001
9981002 workflow_ids .append (info .workflow_id )
9991003 infos .append (info )
1000-
1001- # Calculate forked_to relationships
1002- if workflow_ids :
1003- with self .engine .begin () as c :
1004- forked_to_query = sa .select (
1005- SystemSchema .workflow_status .c .forked_from ,
1006- SystemSchema .workflow_status .c .workflow_uuid ,
1007- ).where (SystemSchema .workflow_status .c .forked_from .in_ (workflow_ids ))
1008- forked_to_rows = c .execute (forked_to_query ).fetchall ()
1009-
1010- # Build a mapping of fork-parent workflow ID to list of fork-child workflow IDs
1011- forked_to_map : Dict [str , List [str ]] = {}
1012- for row in forked_to_rows :
1013- parent_id = row [0 ]
1014- child_id = row [1 ]
1015- if parent_id not in forked_to_map :
1016- forked_to_map [parent_id ] = []
1017- forked_to_map [parent_id ].append (child_id )
1018-
1019- # Populate the forked_to field for each workflow
1020- for info in infos :
1021- info .forked_to = forked_to_map .get (info .workflow_id , None )
1022-
10231004 return infos
10241005
10251006 def get_pending_workflows (
0 commit comments