Skip to content

Commit

Permalink
workflow-state: disable implcit triggers on the CLI
Browse files Browse the repository at this point in the history
* Polling a trigger (rather than a state) on the CLI now
  requires the `--triggers` option to be specified.
  • Loading branch information
oliver-sanders committed Aug 20, 2024
1 parent a3a87df commit 7e5544a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
13 changes: 2 additions & 11 deletions cylc/flow/scripts/workflow_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def __init__(
self.alt_cylc_run_dir = alt_cylc_run_dir
self.old_format = old_format
self.pretty_print = pretty_print
self.is_message = is_message
self.is_trigger = is_trigger

try:
tokens = Tokens(self.id_)
Expand All @@ -200,17 +202,6 @@ def __init__(
self.result: Optional[List[List[str]]] = None
self._db_checker: Optional[CylcWorkflowDBChecker] = None

self.is_message = is_message
if is_message:
self.is_trigger = False
else:
self.is_trigger = (
is_trigger or
(
self.selector is not None and
self.selector not in TASK_STATUSES_ORDERED
)
)
super().__init__(**kwargs)

def _find_workflow(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/workflow-state/05-output.t
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ workflow_run_ok "${TEST_NAME}" \
cylc play --reference-test --debug --no-detach "${WORKFLOW_NAME}"

TEST_NAME=${TEST_NAME_BASE}-cli-check
run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}//20100101T0000Z/t1:out1" --max-polls=1
run_ok "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}//20100101T0000Z/t1:out1" --triggers --max-polls=1

purge
2 changes: 1 addition & 1 deletion tests/functional/workflow-state/07-message2.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ workflow_run_ok "${TEST_NAME_BASE}-run" \
cylc play --debug --no-detach "${WORKFLOW_NAME}"

TEST_NAME=${TEST_NAME_BASE}-query
run_fail "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}//2013/foo:x" --max-polls=1
run_fail "${TEST_NAME}" cylc workflow-state "${WORKFLOW_NAME}//2013/foo:x" --triggers --max-polls=1

grep_ok "failed after 1 polls" "${TEST_NAME}.stderr"

Expand Down
6 changes: 3 additions & 3 deletions tests/functional/workflow-state/11-multi.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ CMD="cylc workflow-state --run-dir=$DBDIR --max-polls=1"
# foo|1|[1]|2024-06-05T16:34:02+12:00|2024-06-05T16:34:04+12:00|1|succeeded|0|0

#---------------
# Test the new-format command line (pre-8.3.0).
# Test the new-format command line (8.3.0+).
T=${TEST_NAME_BASE}-cli-c8b
run_ok "${T}-1" $CMD c8b
run_ok "${T}-2" $CMD c8b//1
run_ok "${T}-3" $CMD c8b//1/foo
run_fail "${T}-4" $CMD c8b//1/foo:waiting
run_ok "${T}-4" $CMD c8b//1/foo:succeeded
run_ok "${T}-5" $CMD "c8b//1/foo:the quick brown" --messages
run_ok "${T}-6" $CMD "c8b//1/foo:x" --triggers
run_ok "${T}-7" $CMD "c8b//1/foo:x" # default to trigger if not a status
run_ok "${T}-8" $CMD c8b//1
run_ok "${T}-9" $CMD c8b//1:succeeded

Expand All @@ -86,7 +86,7 @@ run_fail "${T}-2" $CMD "c7//1/foo:the quick brown" --triggers
run_ok "${T}-3" $CMD "c7//1/foo:x" --triggers

#---------------
# Test the old-format command line (8.3.0+).
# Test the old-format command line (pre-8.3.0).
T=${TEST_NAME_BASE}-cli-8b-compat
run_ok "${T}-1" $CMD c8b
run_ok "${T}-2" $CMD c8b --point=1
Expand Down
8 changes: 5 additions & 3 deletions tests/unit/xtriggers/test_workflow_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import pytest

from cylc.flow.dbstatecheck import output_fallback_msg
from cylc.flow.exceptions import WorkflowConfigError
from cylc.flow.exceptions import WorkflowConfigError, InputError
from cylc.flow.rundb import CylcWorkflowDAO
from cylc.flow.workflow_files import WorkflowFiles
from cylc.flow.xtriggers.workflow_state import (
Expand Down Expand Up @@ -125,8 +125,10 @@ def test_c7_db_back_compat(tmp_run_dir: 'Callable'):
f'{id_}//2012/mithril:"bag end"', is_message=True
)
assert satisfied
satisfied, _ = workflow_state(f'{id_}//2012/mithril:pippin')
assert not satisfied

with pytest.raises(InputError, match='No such task state "pippin"'):
workflow_state(f'{id_}//2012/mithril:pippin')

satisfied, _ = workflow_state(id_ + '//2012/arkenstone')
assert not satisfied

Expand Down

0 comments on commit 7e5544a

Please sign in to comment.