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

Modernise 'cylc dump -t' print format. #6440

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
24 changes: 23 additions & 1 deletion cylc/flow/scripts/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@
parser.add_option(
"-t", "--tasks", help="Task states only.",
action="store_const", const="tasks", dest="disp_form")
parser.add_option(
"-l", "--legacy", help="Tasks states only; use legacy format.",
action="store_true", default=False, dest="legacy_format")
parser.add_option(
"-f", "--flows", help="Print flow numbers with tasks.",
action="store_true", default=False, dest="show_flows")
Expand Down Expand Up @@ -274,7 +277,7 @@
for key, value in sorted(summary.items()):
write(
f'{to_snake_case(key).replace("_", " ")}={value}')
else:
elif options.legacy_format:
for item in summary['taskProxies']:
if options.sort_by_cycle:
values = [
Expand All @@ -294,6 +297,25 @@
if options.show_flows:
values.append(item['flowNums'])
write(', '.join(values))
else:
for item in summary['taskProxies']:
result = (

Check warning on line 302 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L302

Added line #L302 was not covered by tests
f"{item['cyclePoint']}/{item['name']}"
f":{item['state']}"
)
attrs = []

Check warning on line 306 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L306

Added line #L306 was not covered by tests
if item['isHeld']:
attrs.append("held")

Check warning on line 308 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L308

Added line #L308 was not covered by tests
if item['isQueued']:
attrs.append("queued")

Check warning on line 310 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L310

Added line #L310 was not covered by tests
if item['isRunahead']:
attrs.append("runahead")

Check warning on line 312 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L312

Added line #L312 was not covered by tests
if attrs:
result += " (" + ",".join(attrs) + ")"

Check warning on line 314 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L314

Added line #L314 was not covered by tests
if options.show_flows:
result += f" flows={item['flowNums']}"
write(result)

Check warning on line 317 in cylc/flow/scripts/dump.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/dump.py#L316-L317

Added lines #L316 - L317 were not covered by tests

except Exception as exc:
raise CylcError(
json.dumps(workflows, indent=4) + '\n' + str(exc) + '\n'
Expand Down
2 changes: 1 addition & 1 deletion tests/flakyfunctional/hold-release/14-hold-kill/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'1/sleeper:waiting\(held\).* job killed'

sleep 10 # sleep, should still be held after 10 seconds
cylc dump -s -t "${CYLC_WORKFLOW_ID}" >'cylc-dump.out'
cylc dump -l -s -t "${CYLC_WORKFLOW_ID}" >'cylc-dump.out'
diff -u 'cylc-dump.out' - <<'__OUT__'
1, killer, running, not-held, not-queued, not-runahead
1, sleeper, waiting, held, not-queued, not-runahead
Expand Down
2 changes: 1 addition & 1 deletion tests/flakyfunctional/restart/21-task-elapsed.t
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ cylc workflow-state "${WORKFLOW_NAME}" \
--status=running \
--interval=1 \
--max-polls=10 1>'/dev/null' 2>&1
cylc dump -r "${WORKFLOW_NAME}" >'cylc-dump.out'
cylc dump -l -r "${WORKFLOW_NAME}" >'cylc-dump.out'

test_dump 'cylc-dump.out'

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/queues/qsize/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
N_SUCCEEDED=0
while ((N_SUCCEEDED < 12)); do
sleep 1
N_RUNNING=$(cylc dump -t $CYLC_WORKFLOW_ID | grep running | wc -l)
N_RUNNING=$(cylc dump -l -t $CYLC_WORKFLOW_ID | grep running | wc -l)
((N_RUNNING <= {{q_size}})) # check
N_SUCCEEDED=$(cylc workflow-state "${CYLC_WORKFLOW_ID}//*/*:succeeded" | wc -l)
done
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/reload/03-queues/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cylc__job__poll_grep_workflow_log 'Reload completed'
script = """
cylc__job__wait_cylc_message_started
while true; do
RUNNING=$(cylc dump -t "${CYLC_WORKFLOW_ID}" | grep running | wc -l)
RUNNING=$(cylc dump -l -t "${CYLC_WORKFLOW_ID}" | grep running | wc -l)
# Should be max of: monitor plus 3 members of q1
echo "RUNNING $RUNNING"
if ((RUNNING > 4)); then
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/runahead/06-release-update.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ poll_grep_workflow_log -E "${NEXT1}/bar.* added to active task pool"
sleep 10

# (gratuitous use of --flows for test coverage)
cylc dump --flows -t "${WORKFLOW_NAME}" | awk '{print $1 $2 $3 $7}' >'log'
cylc dump -l --flows -t "${WORKFLOW_NAME}" | awk '{print $1 $2 $3 $7}' >'log'

# The scheduler task pool should contain:
# NEXT1/foo - waiting on clock trigger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if ((CYLC_TASK_CYCLE_POINT == 1)); then
expected="foo, 1, running, not-held, not-queued, not-runahead
foo, 2, waiting, not-held, not-queued, runahead"
diff <(cylc dump -t "${CYLC_WORKFLOW_ID}") <(echo "$expected")
diff <(cylc dump -l -t "${CYLC_WORKFLOW_ID}") <(echo "$expected")
# Force trigger next instance while it is runahead limited.
cylc trigger $CYLC_WORKFLOW_ID//2/foo
fi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
if ((CYLC_TASK_CYCLE_POINT == 1)); then
# Force trigger 3/foo while 2/foo is runahead limited.
expected="foo, 2, waiting, not-held, not-queued, runahead"
diff <(cylc dump -t "${CYLC_WORKFLOW_ID}" | grep 'foo, 2') \
diff <(cylc dump -l -t "${CYLC_WORKFLOW_ID}" | grep 'foo, 2') \
<(echo "$expected")
cylc trigger --flow=none $CYLC_WORKFLOW_ID//3/foo
elif ((CYLC_TASK_CYCLE_POINT == 3)); then
Expand Down
6 changes: 5 additions & 1 deletion tests/integration/scripts/test_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,9 @@ async def test_dump_tasks(flow, scheduler, start):
# schd.release_queued_tasks()
await schd.update_data_structure()
ret = []
await dump(id_, DumpOptions(disp_form='tasks'), write=ret.append)
await dump(
id_,
DumpOptions(disp_form='tasks', legacy_format=True),
write=ret.append
)
assert ret == ['a, 1, waiting, not-held, queued, not-runahead']
Loading