| 1 |
#!/usr/bin/env bash |
| 2 |
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. |
| 3 |
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. |
| 4 |
# |
| 5 |
# This program is free software: you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation, either version 3 of the License, or |
| 8 |
# (at your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
#------------------------------------------------------------------------------- |
| 18 |
# Test cat-view with a Jinja2 variable defined in a single cylc include-file |
| 19 |
# TODO - another test for nested file inclusion |
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
#------------------------------------------------------------------------------- |
| 22 |
set_test_number 5 |
| 23 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 24 |
#------------------------------------------------------------------------------- |
| 25 |
TEST_NAME="${TEST_NAME_BASE}-validate" |
| 26 |
run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}" |
| 27 |
#------------------------------------------------------------------------------- |
| 28 |
# Just inline |
| 29 |
TEST_NAME=${TEST_NAME_BASE}-inline |
| 30 |
cylc view -i "${WORKFLOW_NAME}" > tmp.stdout |
| 31 |
cmp_ok tmp.stdout << EOF |
| 32 |
#!jinja2 |
| 33 |
[meta] |
| 34 |
title = "Jinja2 simple ensemble example" |
| 35 |
description = "Auto-generation of dependencies for related tasks." |
| 36 |
|
| 37 |
[scheduler] |
| 38 |
allow implicit tasks = True |
| 39 |
|
| 40 |
# Note that depending on the structure of the workflow you may be able to |
| 41 |
# SIMPLY use a task family name in the graph to represent the entire |
| 42 |
# ensemble (which would be defined by inheritance under [runtime]). |
| 43 |
|
| 44 |
{% set N_MEMBERS = 4 %} |
| 45 |
|
| 46 |
# line \\ |
| 47 |
continuation |
| 48 |
|
| 49 |
[scheduling] |
| 50 |
[[graph]] |
| 51 |
R1 = """ {# generate ensemble dependencies #} |
| 52 |
{% for I in range( 0, N_MEMBERS ) %} |
| 53 |
foo => mem_{{ I }} => post_{{ I }} => bar |
| 54 |
{% endfor %}""" |
| 55 |
EOF |
| 56 |
#------------------------------------------------------------------------------- |
| 57 |
# "cylc view -j/--jinja2" should imply "-i/inline" too: |
| 58 |
TEST_NAME=${TEST_NAME_BASE}-jinja2 |
| 59 |
cylc view -j "${WORKFLOW_NAME}" > tmp.stdout |
| 60 |
cmp_ok tmp.stdout << EOF |
| 61 |
[meta] |
| 62 |
title = "Jinja2 simple ensemble example" |
| 63 |
description = "Auto-generation of dependencies for related tasks." |
| 64 |
[scheduler] |
| 65 |
allow implicit tasks = True |
| 66 |
# Note that depending on the structure of the workflow you may be able to |
| 67 |
# SIMPLY use a task family name in the graph to represent the entire |
| 68 |
# ensemble (which would be defined by inheritance under [runtime]). |
| 69 |
# line \\ |
| 70 |
continuation |
| 71 |
[scheduling] |
| 72 |
[[graph]] |
| 73 |
R1 = """ |
| 74 |
foo => mem_0 => post_0 => bar |
| 75 |
foo => mem_1 => post_1 => bar |
| 76 |
foo => mem_2 => post_2 => bar |
| 77 |
foo => mem_3 => post_3 => bar |
| 78 |
""" |
| 79 |
EOF |
| 80 |
#------------------------------------------------------------------------------- |
| 81 |
# line continuation joining |
| 82 |
TEST_NAME=${TEST_NAME_BASE}-continuation |
| 83 |
cylc view -c "${WORKFLOW_NAME}" > tmp.stdout |
| 84 |
cmp_ok tmp.stdout << EOF |
| 85 |
#!jinja2 |
| 86 |
[meta] |
| 87 |
title = "Jinja2 simple ensemble example" |
| 88 |
description = "Auto-generation of dependencies for related tasks." |
| 89 |
|
| 90 |
[scheduler] |
| 91 |
allow implicit tasks = True |
| 92 |
|
| 93 |
# Note that depending on the structure of the workflow you may be able to |
| 94 |
# SIMPLY use a task family name in the graph to represent the entire |
| 95 |
# ensemble (which would be defined by inheritance under [runtime]). |
| 96 |
|
| 97 |
%include inc/default.jinja2 |
| 98 |
|
| 99 |
# line continuation |
| 100 |
|
| 101 |
[scheduling] |
| 102 |
[[graph]] |
| 103 |
R1 = """ {# generate ensemble dependencies #} |
| 104 |
{% for I in range( 0, N_MEMBERS ) %} |
| 105 |
foo => mem_{{ I }} => post_{{ I }} => bar |
| 106 |
{% endfor %}""" |
| 107 |
EOF |
| 108 |
#------------------------------------------------------------------------------- |
| 109 |
# all processing |
| 110 |
TEST_NAME=${TEST_NAME_BASE}-process |
| 111 |
cylc view -p "${WORKFLOW_NAME}" > tmp.stdout |
| 112 |
cmp_ok tmp.stdout << EOF |
| 113 |
[meta] |
| 114 |
title = "Jinja2 simple ensemble example" |
| 115 |
description = "Auto-generation of dependencies for related tasks." |
| 116 |
[scheduler] |
| 117 |
allow implicit tasks = True |
| 118 |
# Note that depending on the structure of the workflow you may be able to |
| 119 |
# SIMPLY use a task family name in the graph to represent the entire |
| 120 |
# ensemble (which would be defined by inheritance under [runtime]). |
| 121 |
# line continuation |
| 122 |
[scheduling] |
| 123 |
[[graph]] |
| 124 |
R1 = """ |
| 125 |
foo => mem_0 => post_0 => bar |
| 126 |
foo => mem_1 => post_1 => bar |
| 127 |
foo => mem_2 => post_2 => bar |
| 128 |
foo => mem_3 => post_3 => bar |
| 129 |
""" |
| 130 |
EOF |
| 131 |
#------------------------------------------------------------------------------- |
| 132 |
purge |
| 133 |
exit |