1+ from flytekit .models .admin import common
2+
3+ DEFAULT_SORT_ASC = common .Sort (key = "created_at" , direction = common .Sort .Direction .ASCENDING )
4+
5+
16def iterate_node_executions (
27 client ,
38 workflow_execution_identifier = None ,
49 task_execution_identifier = None ,
510 limit = None ,
611 filters = None ,
12+ sort_by = DEFAULT_SORT_ASC ,
713 unique_parent_id = None ,
814):
915 """
@@ -13,6 +19,7 @@ def iterate_node_executions(
1319 :param flytekit.models.core.identifier.TaskExecutionIdentifier task_execution_identifier:
1420 :param int limit: The maximum number of elements to retrieve
1521 :param list[flytekit.models.filters.Filter] filters:
22+ :param flytekit.models.admin.common.Sort sort_by: [Optional] Defaults to created_at field in ASC order.
1623 :rtype: Iterator[flytekit.models.node_execution.NodeExecution]
1724 """
1825 token = ""
@@ -27,6 +34,7 @@ def iterate_node_executions(
2734 limit = num_to_fetch ,
2835 token = token ,
2936 filters = filters ,
37+ sort_by = sort_by ,
3038 unique_parent_id = unique_parent_id ,
3139 )
3240 else :
@@ -35,6 +43,7 @@ def iterate_node_executions(
3543 limit = num_to_fetch ,
3644 token = token ,
3745 filters = filters ,
46+ sort_by = sort_by ,
3847 )
3948 for n in node_execs :
4049 counter += 1
@@ -46,13 +55,14 @@ def iterate_node_executions(
4655 token = next_token
4756
4857
49- def iterate_task_executions (client , node_execution_identifier , limit = None , filters = None ):
58+ def iterate_task_executions (client , node_execution_identifier , limit = None , filters = None , sort_by = DEFAULT_SORT_ASC ):
5059 """
5160 This returns a generator for task executions, given a node execution identifier
5261 :param flytekit.clients.friendly.SynchronousFlyteClient client:
5362 :param flytekit.models.core.identifier.NodeExecutionIdentifier node_execution_identifier:
5463 :param int limit: The maximum number of elements to retrieve
5564 :param list[flytekit.models.filters.Filter] filters:
65+ :param flytekit.models.admin.common.Sort sort_by: [Optional] Defaults to created_at field in ASC order.
5666 :rtype: Iterator[flytekit.models.admin.task_execution.TaskExecution]
5767 """
5868 token = ""
@@ -66,6 +76,7 @@ def iterate_task_executions(client, node_execution_identifier, limit=None, filte
6676 limit = num_to_fetch ,
6777 token = token ,
6878 filters = filters ,
79+ sort_by = sort_by ,
6980 )
7081 for t in task_execs :
7182 counter += 1
0 commit comments