Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort cylc show task proxies #6270

Merged
merged 3 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes.d/6266.feat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'cylc show' task output is now sorted by the task id
8 changes: 5 additions & 3 deletions cylc/flow/scripts/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"<red>No matching active tasks found: {', '.join(ids_list)}",
file=sys.stderr)
Expand Down
43 changes: 43 additions & 0 deletions tests/integration/scripts/test_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,46 @@ async def test_task_meta_query(mod_my_schd, capsys):
'URL': 'http://hasthelargehadroncolliderdestroyedtheworldyet.com/',
}
}


async def test_task_instance_query(
flow, scheduler, start, capsys
):
"""It should fetch task instance data, sorted by task name."""

colour_init(strip=True, autoreset=True)
opts = SimpleNamespace(
comms_timeout=5,
json=False,
task_defs=None,
list_prereqs=False,
)
schd = scheduler(
flow(
{
'scheduling': {
'graph': {'R1': 'zed & dog & cat & ant'},
},
}
),
paused_start=False
)
async with start(schd):
await schd.update_data_structure()
ret = await show(
schd.workflow,
[Tokens('//1/*')],
opts,
)
assert ret == 0

out, _ = capsys.readouterr()
assert [
line for line in out.splitlines()
if line.startswith("Task ID")
] == [ # results should be sorted
'Task ID: 1/ant',
'Task ID: 1/cat',
'Task ID: 1/dog',
'Task ID: 1/zed',
]
Loading