From 2a4401c49de52d5300e26bde682e02496879d39c Mon Sep 17 00:00:00 2001 From: Tom Coleman <15375218+ColemanTom@users.noreply.github.com> Date: Fri, 2 Aug 2024 15:10:37 +1000 Subject: [PATCH] Sort taskProxies in cylc show It was possible for taskProxies when doing 'cylc show' to be in an odd order: Task ID: 20240728T0000Z/b Task ID: 20240727T0000Z/b Task ID: 20240729T0000Z/b After this change, they are always sorted by the ID of the task: Task ID: 20240727T0000Z/b Task ID: 20240728T0000Z/b Task ID: 20240729T0000Z/b --- cylc/flow/scripts/show.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cylc/flow/scripts/show.py b/cylc/flow/scripts/show.py index b146f339e10..9713ed78fac 100755 --- a/cylc/flow/scripts/show.py +++ b/cylc/flow/scripts/show.py @@ -288,8 +288,10 @@ async def prereqs_and_outputs_query( } } results = await pclient.async_request('graphql', tp_kwargs) - multi = len(results['taskProxies']) > 1 - for t_proxy in results['taskProxies']: + task_proxies = sorted(results['taskProxies'], + key=lambda proxy: proxy['id']) + multi = len(task_proxies) > 1 + for t_proxy in task_proxies: task_id = Tokens(t_proxy['id']).relative_id state = t_proxy['state'] if options.json: @@ -379,7 +381,7 @@ async def prereqs_and_outputs_query( print_completion_state(t_proxy) - if not results['taskProxies']: + if not task_proxies: ansiprint( f"No matching active tasks found: {', '.join(ids_list)}", file=sys.stderr)