Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The complete attribute can be used to force things to a complete state if they are queued and the condition is met.
Here is an example when we have a task that decides that the whole family should not run. As it has repeat in it, it will advance the repeat to the next date and run that:
Conditional complete

Code Block
suite x

...


  family

...

 f
     repeat date YMD 20120601 20200531
     complete ./f/check:nofiles

...


     task check
        event 1 nofiles
     task t1 ; trigger check==complete

...


     task t2 ; trigger t1==complete

...


  endfamily


Here is a python example where we create a simple reusable experimental meteorological suite. There is a configuration section for the dates and synoptic cycles to be selected, and there is a function (add_complete()) to select the contents for the complete statement. This is needed since you can only have one complete statement for any node. The main loop of the suite is pretty straightforward.

Code Block
languagepy
class ExperimentalSuite(object):

...


 def _init_(self,start,end) :

...


    self.start_ = start

...


    self.end_ = end

...


    self.start_cycle_ = 12

...


    self.end_cycle_ =

...

 12

 def generate(self) :

...


    suite = Suite("x")

...


    make_fam = suite.add_family("make")

...


    make_fam.add_task("build")

...


    make_fam.add_task("more_work")

...


    main_fam = suite.add_family("main")

...


    main_fam.add_repeat( RepeatDate("YMD",self.start_,self.end_) )

...


    main_fam.add_trigger( "make == complete" )

...


    previous = 0

...


    for FAM in ( 0, 6, 12, 18 )

...

 :
       fam_fam = suite.add_family(str(FAM))

...


       if FAM > 0 :
          fam_fam.add_trigger( "./" + str(previous) + " == complete "

...

 )
       self.add_complete(fam_fam,FAM)

...


       fam_fam.add_task("run")

...


       fam_fam.add_task("run_more").add_trigger( "run == complete")

...


       previous = FAM
    return suite

 def add_complete(self,family,fam):

...


    if fam < self.start_cycle_ and fam > self.end_cycle_

...

 :
        family.add_complete( "../main:YMD eq " + str(self.start_) + " or ../main:YMD ge " + str(self.end_)

...

 ) 
    elif fam < self.start_cycle_

...

 :
        family.add_complete( "../main:YMD eq " + str(self.start_)

...

 ) 
    elif fam > self.end_cycle_

...

 :
        family.add_complete( "../main:YMD ge " + str(self.end_) )

...


    return

print str( ExperimentalSuite(20120601,20120605).generate() )