Debian Codegraph @

cylc/flow/etc/examples/cycle-over-irregular-dates/index.rst

raw
1 Irregular Cycling
2 -----------------
3
4 We typically schedule tasks on regular intervals, e.g. ``P1D`` (every day) or
5 ``PT1H`` (every hour), however, sometimes our intervals are irregular.
6
7 :ref:`user_guide.scheduling.exclusions` can be used to "subtract" dates or
8 entire recurrences e.g:
9
10 ``PT1H!PT6H``
11 Every hour, except every six hours.
12 ``PT1H!(T00, T12)``
13 Every hour, except at 00:00 and 12:00.
14
15 However, sometimes we want to schedule tasks on completely irregular intervals
16 or at arbitrary dates. E.g, when working on case studies, you might have a list
17 or range of arbitrary dates to work with.
18
19
20 .. rubric:: Simple Example
21
22 .. admonition:: Get a copy of this example
23 :class: hint
24
25 .. code-block:: console
26
27 $ cylc get-resources examples/cycle-over-irregular-dates/simple
28
29 This example uses :ref:`Jinja` to define the list of dates and write out a
30 scheduling section for each.
31
32 .. literalinclude:: simple/flow.cylc
33 :language: cylc
34
35 .. tip::
36
37 You can see the result of this Jinja2 code by running the ``cylc view -p``
38 command.
39
40
41 .. rubric:: Example with inter-cycle dependencies
42
43 .. admonition:: Get a copy of this example
44 :class: hint
45
46 .. code-block:: console
47
48 $ cylc get-resources examples/cycle-over-irregular-dates/inter-dependent
49
50 .. _Jinja2 loop variable: https://jinja.palletsprojects.com/en/3.0.x/templates/#list-of-control-structures
51
52 If you have dependencies between the cycles, you can make this work by using the
53 `Jinja2 loop variable`_.
54
55 For example, the previous iteration of the ``{% for date in DATES %}`` loop is
56 available as ``loop.previtem`` and the next as ``loop.nextitem``.
57
58 If you need to make the tasks which cycle on *irregular* intervals dependent on
59 tasks which cycle on *regular* intervals, then you might find the
60 :py:func:`strftime <cylc.flow.jinja.filters.strftime.strftime>` function
61 helpful as a way of determining the nearest matching cycle.
62
63 .. literalinclude:: inter-dependent/flow.cylc
64 :language: cylc
65
66 You can see how the cycles are linked together using the ``cylc graph``
67 command:
68
69 .. NOTE: use "cylc graph . -o foo.dot --cycles 2000 2001" to generate this code
70
71 .. digraph:: Example
72 :align: center
73
74 size = "7,15"
75
76 graph [fontname="sans" fontsize="25"]
77 node [fontname="sans"]
78
79 subgraph "cluster_20000101T0000Z" {
80 label="20000101T0000Z"
81 style="dashed"
82 "20000101T0000Z/install" [label="install\n20000101T0000Z"]
83 "20000101T0000Z/prep" [label="prep\n20000101T0000Z"]
84 }
85
86 subgraph "cluster_20000105T0600Z" {
87 label="20000105T0600Z"
88 style="dashed"
89 "20000105T0600Z/plot" [label="plot\n20000105T0600Z"]
90 "20000105T0600Z/run_model" [label="run_model\n20000105T0600Z"]
91 }
92
93 subgraph "cluster_20000305T1200Z" {
94 label="20000305T1200Z"
95 style="dashed"
96 "20000305T1200Z/plot" [label="plot\n20000305T1200Z"]
97 "20000305T1200Z/run_model" [label="run_model\n20000305T1200Z"]
98 }
99
100 subgraph "cluster_20000528T1336Z" {
101 label="20000528T1336Z"
102 style="dashed"
103 "20000528T1336Z/plot" [label="plot\n20000528T1336Z"]
104 "20000528T1336Z/run_model" [label="run_model\n20000528T1336Z"]
105 }
106
107 subgraph "cluster_20010101T0000Z" {
108 label="20010101T0000Z"
109 style="dashed"
110 "20010101T0000Z/prep" [label="prep\n20010101T0000Z"]
111 }
112
113 subgraph "cluster_20010105T2324Z" {
114 label="20010105T2324Z"
115 style="dashed"
116 "20010105T2324Z/plot" [label="plot\n20010105T2324Z"]
117 "20010105T2324Z/run_model" [label="run_model\n20010105T2324Z"]
118 }
119
120 "20000101T0000Z/install" -> "20000101T0000Z/prep"
121 "20000101T0000Z/install" -> "20010101T0000Z/prep"
122 "20000101T0000Z/prep" -> "20000105T0600Z/run_model"
123 "20000101T0000Z/prep" -> "20000305T1200Z/run_model"
124 "20000101T0000Z/prep" -> "20000528T1336Z/run_model"
125 "20000105T0600Z/run_model" -> "20000105T0600Z/plot"
126 "20000105T0600Z/run_model" -> "20000305T1200Z/run_model"
127 "20000305T1200Z/run_model" -> "20000305T1200Z/plot"
128 "20000305T1200Z/run_model" -> "20000528T1336Z/run_model"
129 "20000528T1336Z/run_model" -> "20000528T1336Z/plot"
130 "20000528T1336Z/run_model" -> "20010105T2324Z/run_model"
131 "20010101T0000Z/prep" -> "20010105T2324Z/run_model"
132 "20010105T2324Z/run_model" -> "20010105T2324Z/plot"