Debian Codegraph @

docs/ug/user_manual/text_based_suite_definition/attributes/complete.rst

raw
1 .. _complete:
2
3 complete
4 //////////
5
6 Force a node to be complete if the trigger evaluates, without running any of the nodes.
7
8 This allows the user to have tasks in the suite which run only in case others
9 fail. In practice the node would need to also have a trigger. A complete
10 enables making nodes **standby** depending on the success of other nodes.
11
12 Here is an example where task **tt** does not run if task **t** meter is more than 120. If task **t** however completes, but the meter **step** is less that 120 the **standby** job will run.
13
14 .. code-block:: shell
15
16 family f
17 task t
18 meter step 0 240 120
19 task tt
20 complete t:step ge 120
21 trigger t==complete
22 endfamily
23
24
25 Using complete
26 ================
27
28 The **complete** attribute can be used to **force** things to a complete
29 state if they are queued and the condition is met.
30
31 Here is an example when we have a task that decides that the whole
32 family should not run. As it has **repeat** in it, it will advance the
33 repeat to the next date and run that.
34
35 .. code-block:: shell
36 :caption: Conditional complete
37
38 suite x
39 family f
40 repeat date YMD 20120601 20200531
41 complete ./f/check:nofiles
42 task check
43 event 1 nofiles
44 task t1 ; trigger check==complete
45 task t2 ; trigger t1==complete
46 endfamily
47
48 Here is a python example where we create a simple reusable experimental
49 meteorological suite. There is a **configuration section** for the dates
50 and synoptic cycles to be selected, and there is a **function**
51 (add_complete()) to select the contents for the complete statement. This
52 is needed since you can only have one **complete** statement for any node. The main loop of the
53 suite is pretty straightforward.
54
55 .. code-block:: python
56
57 class ExperimentalSuite(object):
58 def _init_(self,start,end) :
59 self.start_ = start
60 self.end_ = end
61 self.start_cycle_ = 12
62 self.end_cycle_ = 12
63
64 def generate(self) :
65 suite = Suite("x")
66 make_fam = suite.add_family("make")
67 make_fam.add_task("build")
68 make_fam.add_task("more_work")
69 main_fam = suite.add_family("main")
70 main_fam.add_repeat( RepeatDate("YMD",self.start_,self.end_) )
71 main_fam.add_trigger( "make == complete" )
72 previous = 0
73 for FAM in ( 0, 6, 12, 18 ) :
74 fam_fam = suite.add_family(str(FAM))
75 if FAM > 0 :
76 fam_fam.add_trigger( "./" + str(previous) + " == complete " )
77 self.add_complete(fam_fam,FAM)
78 fam_fam.add_task("run")
79 fam_fam.add_task("run_more").add_trigger( "run == complete")
80 previous = FAM
81 return suite
82
83 def add_complete(self,family,fam):
84 if fam < self.start_cycle_ and fam > self.end_cycle_ :
85 family.add_complete( "../main:YMD eq " + str(self.start_) + " or ../main:YMD ge " + str(self.end_) )
86 elif fam < self.start_cycle_ :
87 family.add_complete( "../main:YMD eq " + str(self.start_) )
88 elif fam > self.end_cycle_ :
89 family.add_complete( "../main:YMD ge " + str(self.end_) )
90 return
91
92 print str( ExperimentalSuite(20120601,20120605).generate() )