| 1 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 2 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 3 |
# |
| 4 |
# This program is free software: you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
"""Tests for Cylc 7 compatibility mode.""" |
| 18 |
|
| 19 |
from typing import TYPE_CHECKING |
| 20 |
|
| 21 |
from cylc.flow.cycling.integer import IntegerPoint |
| 22 |
from cylc.flow.data_store_mgr import TASK_PROXIES |
| 23 |
|
| 24 |
if TYPE_CHECKING: |
| 25 |
from cylc.flow.scheduler import Scheduler |
| 26 |
|
| 27 |
|
| 28 |
async def test_blocked_tasks_in_n0(flow, scheduler, run, complete): |
| 29 |
"""Ensure that tasks with no satisfied dependencies remain in the pool. |
| 30 |
|
| 31 |
In this example, the "recover" task is not satisfiable because its upstream |
| 32 |
dependency "foo:failed" will never be satisfied. The unsatisfiable |
| 33 |
"recover" task should remain in n=0 until removed/completed. |
| 34 |
|
| 35 |
See https://github.com/cylc/cylc-flow/issues/4983 |
| 36 |
""" |
| 37 |
id_ = flow( |
| 38 |
{ |
| 39 |
'scheduling': { |
| 40 |
'initial cycle point': '1', |
| 41 |
'cycling mode': 'integer', |
| 42 |
'runahead limit': 'P2', |
| 43 |
'dependencies': { |
| 44 |
'P1': { |
| 45 |
'graph': ''' |
| 46 |
foo:fail => recover |
| 47 |
foo | recover => bar |
| 48 |
''', |
| 49 |
}, |
| 50 |
}, |
| 51 |
}, |
| 52 |
}, |
| 53 |
filename='suite.rc', |
| 54 |
) |
| 55 |
schd: 'Scheduler' = scheduler(id_, paused_start=False, debug=True) |
| 56 |
async with run(schd): |
| 57 |
# the workflow should run for three cycles, then runahead stall |
| 58 |
await complete(schd, *(f'{cycle}/bar' for cycle in range(1, 4))) |
| 59 |
|
| 60 |
# (complete happens before stall test) |
| 61 |
await schd._main_loop() |
| 62 |
assert schd.is_stalled |
| 63 |
|
| 64 |
# the "blocked" recover tasks should remain in the pool |
| 65 |
assert schd.pool.get_task_ids() == { |
| 66 |
'1/recover', |
| 67 |
'2/recover', |
| 68 |
'3/recover', |
| 69 |
'4/foo', |
| 70 |
} |
| 71 |
|
| 72 |
# the "blocked" tasks should remain visible in the data store |
| 73 |
assert { |
| 74 |
(x.cycle_point, x.graph_depth, x.name) |
| 75 |
for x in schd.data_store_mgr.data[schd.tokens.id][ |
| 76 |
TASK_PROXIES |
| 77 |
].values() |
| 78 |
} == { |
| 79 |
('1', 1, 'foo'), |
| 80 |
('1', 0, 'recover'), |
| 81 |
('1', 1, 'bar'), |
| 82 |
('2', 1, 'foo'), |
| 83 |
('2', 0, 'recover'), |
| 84 |
('2', 1, 'bar'), |
| 85 |
('3', 1, 'foo'), |
| 86 |
('3', 0, 'recover'), |
| 87 |
('3', 1, 'bar'), |
| 88 |
('4', 0, 'foo'), |
| 89 |
('4', 1, 'recover'), |
| 90 |
('4', 1, 'bar'), |
| 91 |
} |
| 92 |
|
| 93 |
# remove the unsatisfiable tasks |
| 94 |
# (i.e. manually implement a suicide trigger) |
| 95 |
for cycle in range(1, 4): |
| 96 |
itask = schd.pool.get_task(IntegerPoint(str(cycle)), 'recover') |
| 97 |
schd.pool.remove(itask, 'suicide-trigger') |
| 98 |
|
| 99 |
assert schd.pool.get_task_ids() == { |
| 100 |
'4/foo', |
| 101 |
} |
| 102 |
|
| 103 |
# the workflow continue into the next three cycles, then stall again |
| 104 |
# (i.e. the runahead limit should move forward after the removes) |
| 105 |
await complete(schd, *(f'{cycle}/bar' for cycle in range(4, 7))) |
| 106 |
await schd._main_loop() |
| 107 |
assert schd.is_stalled |
| 108 |
|
| 109 |
assert { |
| 110 |
(x.cycle_point, x.graph_depth, x.name) |
| 111 |
for x in schd.data_store_mgr.data[schd.tokens.id][ |
| 112 |
TASK_PROXIES |
| 113 |
].values() |
| 114 |
} == { |
| 115 |
('4', 1, 'foo'), |
| 116 |
('4', 0, 'recover'), |
| 117 |
('4', 1, 'bar'), |
| 118 |
('5', 1, 'foo'), |
| 119 |
('5', 0, 'recover'), |
| 120 |
('5', 1, 'bar'), |
| 121 |
('6', 1, 'foo'), |
| 122 |
('6', 0, 'recover'), |
| 123 |
('6', 1, 'bar'), |
| 124 |
('7', 0, 'foo'), |
| 125 |
('7', 1, 'recover'), |
| 126 |
('7', 1, 'bar'), |
| 127 |
} |