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

Back-compat: fix self-suicide: a:fail => !a #4970

Merged
merged 8 commits into from
Jul 7, 2022
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
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ default job runner directives for platforms.

### Fixes

[#4970](https://github.com/cylc/cylc-flow/pull/4970) - Fix handling of suicide
triggers in back-compat mode.

[#4887](https://github.com/cylc/cylc-flow/pull/4887) - Disallow relative paths
in `global.cylc[install]source dirs`.

Expand Down
12 changes: 10 additions & 2 deletions cylc/flow/task_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,9 @@ def spawn_on_output(self, itask, output, forced=False):
self._get_hidden_task_by_id(c_taskid)
or self._get_main_task_by_id(c_taskid)
)
if c_task is not None:
if c_task is not None and c_task != itask:
# Child already exists, update it.
# (unless trying to remove itself: a:fail => !a)
self.merge_flows(c_task, itask.flow_nums)
self.workflow_db_mgr.put_insert_task_states(
c_task,
Expand All @@ -1181,7 +1182,14 @@ def spawn_on_output(self, itask, output, forced=False):
)
# self.workflow_db_mgr.process_queued_ops()

elif (itask.flow_nums or forced) and not itask.flow_wait:
elif (
wxtim marked this conversation as resolved.
Show resolved Hide resolved
c_task is None
and (itask.flow_nums or forced)
and not itask.flow_wait
):
# If child is not in the pool already, and parent belongs to a
# flow (so it can spawn children), and parent is not waiting
# for an upcoming flow merge before spawning ... then spawn it.
c_task = self.spawn_task(
c_name, c_point, itask.flow_nums,
)
Expand Down
4 changes: 3 additions & 1 deletion cylc/flow/taskdef.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ def has_only_abs_triggers(self, point):
for trig in dep.task_triggers:
if (
trig.offset_is_absolute or
trig.offset_is_from_icp
trig.offset_is_from_icp or
# Don't count self-suicide as a normal trigger.
dep.suicide and trig.task_name == self.name
):
has_abs = True
else:
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/spawn-on-demand/16-c7backcompat-self-suicide.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Cylc 8 back-compat mode.
# Test self-induced suicide.

. "$(dirname "$0")/test_header"
set_test_number 2
reftest
exit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1/foo -triggered off [] in flow 1
1/baz -triggered off ['1/foo'] in flow 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# suite.rc: Cylc 8 back-compat mode.

# GitHub cylc-flow #4968: self-induced suicide should not retrigger foo below.
[scheduler]
[[events]]
stall timeout = PT0S
abort on stall timeout = True
expected task failures = 1/foo
[scheduling]
[[dependencies]]
graph = """
foo => bar
foo:fail => !foo & !bar
foo:fail | bar => baz
"""
[runtime]
[[foo]]
script = false
[[bar, baz]]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-------------------------------------------------------------------------------
# Cylc 8 back-compat mode.
# Test self-induced suicide (cycling workflow, absolute triggers).

. "$(dirname "$0")/test_header"
set_test_number 2
reftest
exit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1/init -triggered off [] in flow 1
1/bad -triggered off ['1/init'] in flow 1
2/bad -triggered off ['1/init'] in flow 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# suite.rc: Cylc 8 back compat mode.

# GitHub cylc-flow #4968: self-induced suicide in the example below should not
# cause shutdown after the initial cycle point.

[scheduler]
[[events]]
stall timeout = PT0S
abort on stall timeout = True
expected task failures = 1/bad, 2/bad
[scheduling]
cycling mode = integer
initial cycle point = 1
final cycle point = 2
[[dependencies]]
[[[R1]]]
graph = init
[[[P1]]]
graph = """
init[^] => bad => good
bad:fail => !bad & !good
"""
[runtime]
[[init, good]]
script = true
[[bad]]
script = false