Debian Codegraph @

tests/i/test_taskdef.py

raw
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
18 from cylc.flow.config import WorkflowConfig
19 from cylc.flow.pathutil import get_workflow_run_dir
20 from cylc.flow.scheduler_cli import RunOptions
21 from cylc.flow.task_outputs import TASK_OUTPUT_SUCCEEDED
22 from cylc.flow.workflow_files import WorkflowFiles
23
24
25 async def test_almost_self_suicide(flow, scheduler, start):
26 """Suicide triggers should not count as upstream tasks when looking
27 to spawn parentless tasks.
28
29 https://github.com/cylc/cylc-flow/issues/6594
30
31 For the example under test, pre-requisites for ``!a`` should not be
32 considered the same as pre-requisites for ``a``. If the are then then
33 is parentless return false for all cases of ``a`` not in the inital cycle
34 and subsequent cycles never run.
35 """
36 wid = flow({
37 'scheduler': {'cycle point format': '%Y'},
38 'scheduling': {
39 'initial cycle point': 1990,
40 'final cycle point': 1992,
41 'graph': {
42 'R1': 'install_cold',
43 'P1Y': 'install_cold[^] => a? => b?\nb:fail? => !a?'
44 }
45 }
46 })
47 schd = scheduler(wid)
48 async with start(schd):
49 tasks = [str(t) for t in schd.pool.get_tasks()]
50 for task in ['1990/a:waiting', '1991/a:waiting', '1992/a:waiting']:
51 assert task in tasks
52
53
54 def test_graph_children(flow):
55 """TaskDef.graph_children should not include duplicates.
56
57 https://github.com/cylc/cylc-flow/issues/6619#issuecomment-2668932069
58 """
59 wid = flow({
60 'scheduling': {
61 'graph': {
62 'R1': 'foo | bar<n> => fin',
63 },
64 },
65 'task parameters': {
66 'n': '1..3',
67 },
68 })
69 config = WorkflowConfig(
70 wid, get_workflow_run_dir(wid, WorkflowFiles.FLOW_FILE), RunOptions()
71 )
72 foo = config.taskdefs['foo']
73 graph_children = list(foo.graph_children.values())[0]
74 assert [name for name, _ in graph_children[TASK_OUTPUT_SUCCEEDED]] == [
75 'fin'
76 ]