The Defs, Suite, Family, and Task from form a node hierarchy: Every Suite, Family, and Task must have a name. This name must be unique between the peers.
The following example show shows different ways of adding node hierarchy.(they produce identical definitions)
Code Block |
---|
| import ecflow
defs = ecflow.Defs()
s = ecflow.Suite('s1')
f = ecflow.Family('f1')
t = ecflow.Task('t1')
defs.add_suite(s)
s.add_family(f)
f.add_task(t) |
Code Block |
---|
language | py |
---|
title | Using Addfunctional style |
---|
| from ecflow import *
defs = Defs()
defs.add_suite('s1').add_family('f1').add_task('t1') |
|
Code Block |
---|
language | py |
---|
title | Constructor(Preferred) |
---|
| from ecflow import *
defs = Defs(
Suite('s1').add(,
Family('f1').add(,
Task('t1')))) |
Code Block |
---|
language | py |
---|
title | Using ConstructorAdd |
---|
| from ecflow import *
defs = Defs( ).add(
Suite('s1',).add(
Family('f1',).add(
Task('t1')))) |
|
Code Block |
---|
language | py |
---|
title | Using + with parenthesis |
---|
| from ecflow import *
defs = Defs() + (Suite('s1') + (Family('f1') + Task('t1')))
|
Code Block |
---|
language | py |
---|
title | Hybrid. mix and match. Uses += and + |
---|
| from ecflow import *
defs = Defs(Suite('s1'))
defs.s1 += Family('f1') + Task('t1') |
|
...
The following examples show alternative styles of adding suites, families, and tasks: They produce exactly the same suite as the firstabove.
Code Block |
---|
| 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") |
|
Code Block |
---|
| 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") |
|
Code Block |
---|
| 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") |
|
Warning |
---|
In the third example above we use 'defs.s1.f1' to reference a node by name. This is useful in small designs but will produce maintenance issues in large designs IF the node names are changed. |
...
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
Code Block |
---|
from ecflow import *
defs = Defs(
[ 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 familesfamilies but found " + str(len(suite)))
for fam in suite:
assert(len(fam)==5, " expected 5 tasks but found " + str(len(fam))) |
...