Adding a complete
There are cases where a task does not need to run, because a certain condition has been met.
Considering that the condition can be signalled by an event, ecFlow provides the complete expression to handle this case.
From the previous example, suppose that event t2:b indicates that task t2 did not manage to produce an expected result, and in this case there is no need to run task t4.
The complete expression keyword has a similar syntax to the trigger keyword but sets a task complete rather than running it.
When ecflow_server tries to start a task, it evaluates the trigger and the complete expression. If the complete condition evaluates to _true_, the task will be set as complete. This means that the complete evaluation takes precedence over the trigger evaluation.
A complete can be defined between tasks, between families, or both. A complete can be used in conjunction with a trigger, as follows.
Update Suite Definition
Update the suite definition to add a complete expression to task t4.
# Definition of the suite test.
suite test
edit ECF_INCLUDE "{{HOME}}/course" # replace '{{HOME}}' appropriately
edit ECF_HOME "{{HOME}}/course"
family f1
edit SLEEP 20
task t1
task t2
trigger t1 eq complete
event a
event b
task t3
trigger t2:a
task t4
trigger t2 eq complete
complete t2:b
endfamily
endsuite
import os
from ecflow import Defs, Suite, Family, Task, Edit, Trigger, Complete, Event
def create_family_f1():
return Family(
"f1",
Edit(SLEEP=20),
Task("t1"),
Task("t2", Trigger("t1 == complete"), Event("a"), Event("b")),
Task("t3", Trigger("t2:a")),
Task("t4", Trigger("t2 == complete"), Complete("t2:b")),
)
print("Creating suite definition")
home = os.path.join(os.getenv("HOME"), "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("test.def")
What to do:
Update the suite definition, as shown above.
Replace the suite, using:
ecflow_client --suspend /test ecflow_client --replace /test test.def
python3 test.py python3 client.py
Observe the tasks in ecflow_ui.
See the triggers by selecting
t4.See the trigger relation by clicking on the arrow.
See the triggers in the tree, using the Show menu.
Note the icon indicating that the task has not run.
To check the triggers modify task
t2so that eventbis not triggered; taskt4should run whent2completes.