Debian Codegraph @

tests/flakyfunctional/integer-cycling/00-satellite/flow.cylc

raw
1 #!Jinja2
2 [meta]
3 title = Test workflow based on the satellite data processing example
4 description = """
5 Each successive integer cycle retrieves and processes the next
6 arbitrarily timed and arbitrarily labelled dataset, in parallel
7 with previous cycles if the data comes in quickly.
8 """
9
10 # you can monitor output processing with:
11 # $ watch -n 1 \
12 # "find ~/cylc-run/<WORKFLOW>/share; find ~/cylc-run/<WORKFLOW>/work"
13
14 {% set N_DATASETS = 3 %}
15
16 # define shared directories (could use runtime namespaces for this)
17 {% set DATA_IN_DIR = "$CYLC_WORKFLOW_SHARE_DIR/incoming" %}
18 {% set PRODUCT_DIR = "$CYLC_WORKFLOW_SHARE_DIR/products" %}
19
20 [scheduling]
21 cycling mode = integer
22 initial cycle point = 1
23 final cycle point = {{N_DATASETS}}
24 runahead limit = P2
25 [[graph]]
26 R1 = prep => satsim & get_data
27 P1 = """
28 # Processing chain for each dataset
29 get_data => proc1 => proc2 => products
30 # As one dataset is retrieved, start waiting on another.
31 get_data[-P1] => get_data
32 """
33 R1//{{N_DATASETS}} = products => collate
34
35 [runtime]
36 [[prep]]
37 script = rm -rf $CYLC_WORKFLOW_SHARE_DIR $CYLC_WORKFLOW_WORK_DIR
38 [[[meta]]]
39 title = clean the workflow output directories
40
41 [[satsim]]
42 pre-script = mkdir -p {{DATA_IN_DIR}}
43 script = """
44 COUNT=0
45 while true; do
46 (( COUNT == {{N_DATASETS}} )) && break
47 sleep $(( 1 + RANDOM % 5 ))
48 touch {{DATA_IN_DIR}}/dataset-$(date +%s).raw
49 (( COUNT += 1 ))
50 done
51 """
52 [[[meta]]]
53 title = simulate a satellite data feed
54 description = """
55 Generates {{N_DATASETS}} arbitrarily labelled
56 datasets after random durations.
57 """
58
59 [[WORKDIR]]
60 # Define a common cycle-point-specific work-directory for all
61 # processing tasks so that they all work on the same dataset.
62 work sub-directory = proc-$CYLC_TASK_CYCLE_POINT
63 #pre-script = sleep 10
64
65 [[get_data]]
66 inherit = WORKDIR
67
68 script = """
69 while ! DATASET=$(ls {{DATA_IN_DIR}}/dataset-*.raw 2>/dev/null \
70 | head -n 1)
71 do
72 sleep 1
73 done
74 mv "$DATASET" "$PWD"
75 """
76 [[[meta]]]
77 title = grab one new dataset, waiting if necessary
78
79 [[proc1]]
80 inherit = WORKDIR
81 script = """
82 DATASET=$(ls dataset-*.raw)
83 mv $DATASET ${DATASET%raw}proc1
84 """
85 [[[meta]]]
86 title = convert .raw dataset to .proc1 form
87
88 [[proc2]]
89 inherit = WORKDIR
90 script = """
91 DATASET=$(ls dataset-*.proc1)
92 mv $DATASET ${DATASET%proc1}proc2
93 """
94 [[[meta]]]
95 title = convert .proc1 dataset to .proc2 form
96
97 [[products]]
98 inherit = WORKDIR
99 pre-script = mkdir -p {{PRODUCT_DIR}}
100 script = """
101 DATASET=$( ls dataset-*.proc2 )
102 mv $DATASET {{PRODUCT_DIR}}/${DATASET%proc2}prod
103 """
104 [[[meta]]]
105 title = generate products from .proc2 processed dataset
106
107 [[collate]]
108 # Note you might want to use "cylc workflow-state" to check that
109 # _all_ product tasks have finished before collating results.
110 script = ls {{PRODUCT_DIR}}
111 [[[meta]]]
112 title = collate all products from the workflow run