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

set CYLC_DEBUG env var when set-verbosity DEBUG #5854

Merged
merged 3 commits into from
Jan 4, 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
4 changes: 2 additions & 2 deletions cylc/flow/option_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ def log_level_to_verbosity(lvl: int) -> int:
>>> log_level_to_verbosity(logging.NOTSET)
2
>>> log_level_to_verbosity(logging.DEBUG)
1
2
>>> log_level_to_verbosity(logging.INFO)
0
>>> log_level_to_verbosity(logging.WARNING)
-1
>>> log_level_to_verbosity(logging.ERROR)
-1
"""
if lvl < logging.DEBUG:
if lvl <= logging.DEBUG:
return 2
if lvl < logging.INFO:
return 1
Expand Down
34 changes: 24 additions & 10 deletions tests/functional/cli/03-set-verbosity.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#-------------------------------------------------------------------------------
# Test "cylc set-verbosity"
. "$(dirname "$0")/test_header"
set_test_number 6
set_test_number 4

# Test illegal log level
TEST_NAME="${TEST_NAME_BASE}-bad"
Expand All @@ -28,18 +28,32 @@ grep_ok 'InputError: Illegal logging level, duck' "${TEST_NAME}.stderr"
TEST_NAME="${TEST_NAME_BASE}-good"
init_workflow "${TEST_NAME_BASE}" << '__FLOW__'
[scheduler]
allow implicit tasks = True
[[events]]
abort on stall timeout = True
stall timeout = PT0S
[scheduling]
[[graph]]
R1 = andor
R1 = setter => getter
[runtime]
[[setter]]
script = """
echo "CYLC_VERBOSE: $CYLC_VERBOSE"
[[ "$CYLC_VERBOSE" != 'true' ]]
echo "CYLC_DEBUG: $CYLC_DEBUG"
[[ "$CYLC_DEBUG" != 'true' ]]

cylc set-verbosity DEBUG "$CYLC_WORKFLOW_ID"
cylc__job__poll_grep_workflow_log 'Command actioned: set_verbosity'
"""
[[getter]]
script = """
echo "CYLC_VERBOSE: $CYLC_VERBOSE"
[[ "$CYLC_VERBOSE" == 'true' ]]
echo "CYLC_DEBUG: $CYLC_DEBUG"
[[ "$CYLC_DEBUG" == 'true' ]]
"""
__FLOW__

run_ok "${TEST_NAME}-validate" cylc validate "$WORKFLOW_NAME"
workflow_run_ok "${TEST_NAME}-run" cylc play --pause "$WORKFLOW_NAME"

run_ok "$TEST_NAME" cylc set-verbosity DEBUG "$WORKFLOW_NAME"
log_scan "${TEST_NAME}-grep" "${WORKFLOW_RUN_DIR}/log/scheduler/log" 5 1 \
'Command actioned: set_verbosity'

cylc stop "$WORKFLOW_NAME"
workflow_run_ok "${TEST_NAME}-run" cylc play --no-detach "$WORKFLOW_NAME"
purge
Loading