变量继承
之前的章节中,我们看到如何为 task 定义变量(variable)。 当同一 family 下的所有 task 都共享同一个变量值时, 该值可以定义在 family 层。这就是变量继承(variable inheritance)。
下面的例子中,也可将变量定义在 suite 层,得到相同的结果。
变量从父节点继承。子节点(node)可以重新定义变量,这种情况下使用新的变量值。 生成的变量(generated variables)也可以重新定义,但不推荐这么做,除非你很清楚可能出现的后果。
Suite Definition
Text
# Definition of the suite test.suite testedit ECF_INCLUDE "$ECF_HOME" # replace '$ECF_HOME' with the path to your ECF_HOME directoryedit ECF_HOME "$ECF_HOME"family f1edit SLEEP 20task t1task t2endfamilyendsuite
Python
import osfrom pathlib import Pathfrom ecflow import Defs, Suite, Task, Family, Editdef create_family_f1():return Family("f1",Edit(SLEEP=20),Task("t1"),Task("t2"))print("Creating suite definition")home = os.path.abspath(Path(Path(__file__).parent, "../../../build/course"))defs = Defs(Suite('test',Edit(ECF_INCLUDE=home, ECF_HOME=home),create_family_f1()))print(defs)print("Checking job creation: .ecf -> .job0")print(defs.check_job_creation())print("Saving definition to file 'test.def'")defs.save_as_defs(str(Path(home, "test.def")))# To restore the definition from file 'test.def' we can use:# restored_defs = ecflow.Defs("test.def")
生成的 def 文件
$python test.pyCreating suite definition# 4.8.0suite testedit ECF_INCLUDE '/g3/wangdp/project/study/ecflow/ecflow-tutorial-code/build/course'edit ECF_HOME '/g3/wangdp/project/study/ecflow/ecflow-tutorial-code/build/course'family f1edit SLEEP '20'task t1task t2endfamilyendsuiteChecking job creation: .ecf -> .job0Saving definition to file 'test.def'

测试
如下的 suite definition
suite testedit SLEEP 100family f1edit SLEEP 80task t1task t2edit SLEEP 9family g1edit SLEEP 89task x1edit SLEEP 10task x2endfamilyendfamilyfamily f2task t1task t2edit SLEEP 77family g2task x1edit SLEEP 12task x2endfamilyendfamilyendsuite
上面 suite 的 SLEEP 值
| node | SLEEP |
|---|---|
| /test/f1/t1 | 80 |
| /test/f1/t2 | 9 |
| /test/f1/g1/x1 | 10 |
| /test/f1/g1/x2 | 89 |
| /test/f2/t1 | 100 |
| /test/f2/t2 | 77 |
| /test/f2/g2/x1 | 12 |
| /test/f2/g2/x2 | 100 |

任务
- 修改
- 替换 suite
- 在 ecflow_ui 中查看修改后的 suite test
