The following example shows how suites, families and tasks are added to a Python definition file.
import ecflow if _name_ == "_main_": defs = ecFlow.Defs() # create an empty definition suite = defs.add_suite("s1"); # create a suite and add it to the defs family = suite.add_family("f1") # create a family and add it to suite for i in [ "a", "b", "c" ]: # create task ta,tb,tc family.add_task( "t" + i) # create a task and add to family defs.save_as_defs("test.def") # save defs to file "test.def"
The following examples show alternative styles of adding suites,families and tasks: They produce exactly the same suite as the first.
from ecflow import * defs = Defs() + Suite("s1", Family("f1", [ Task("t{0}".format(t)) for t in ("a", "b", "c")])) defs.save_as_defs("test.def") | from ecflow import * defs = Defs().add( Suite("s1").add( Family("f1").add( [ Task("t{}".format(t)) for t in ("a", "b", "c")]))) defs.save_as_defs("test.def") | from ecflow import * defs = Defs() defs += Suite("s1") defs.s1 += Family("f1") defs.s1.f1 += [ Task("t{}".format(t)) for t in ("a", "b", "c")] defs.save_as_defs("test.def") |
The following example adds 5 suites, with 5 families with 5 tasks. However care needs to be taken, to ensure that python is readable. It is recommended that you check your results
from ecflow import * defs = Defs().add( [ Suite("s{0}".format(i), [ Family("f{0}".format(i), [ Task("t{0}".format(i)) for i in range(1,6)] ) for i in range(1,6)] ) for i in range(1,6) ] ) assert(len(defs)==5, " expected 5 suites but found " + str(len(defs))) for suite in defs: assert(len(suite)==5, " expected 5 familes but found " + str(len(suite))) for fam in suite: assert(len(fam)==5, " expected 5 tasks but found " + str(len(fam)))