Adding a time trigger
This section show an alternative to time-based dependencies, using time triggers. The following suite-based generated variables are available for time-based triggers:
DD: day of the monthDOW: day of the week, 0-6, where 0 is SundayDOY: day of the yearECF_DATE:YYYYMMDDyear, month, day formatMM: month 01-12TIME:HHMMhour, minute formatYYYY: year
Note
Find these variables using the ecflow_ui, by selecting the suite, then opening the Variables tab.
These time-based variables on the suite consider the suite calendar, and can be customised via the suite clock.
The following example maps several time dependencies and the corresponding time triggers:
time 23:00 # trigger :TIME == 2300
date 1.*.* # trigger :DD == 1
day monday # trigger :DOW == 1
Note
The : indicates that the variable is found by searching up the node tree.
Triggers can also use AND/OR logic, and the full range of operators: <, >, <=, >=.
task t # using time attributes
day monday
time 13:00
task t # using time trigger
trigger :DOW == 1 and :TIME >= 1300
task t # combination of time attributes and time trigger
day monday
trigger :TIME >= 1300
Important
Relative time (e.g. time +00:01) are not possible with time-based triggers.
The use of time series with time-based triggers is also problematic.
Update Suite Definition
Update the suite definition file so that family f2 uses several time triggers.
# Definition of the suite test
suite test
edit ECF_INCLUDE "{{HOME}}/course" # replace '$HOME' appropriately
edit ECF_HOME "{{HOME}}/course"
[... previous family f1 omitted for brevity ..]
family f2
edit SLEEP 20
task t1
trigger :ECF_DATE == 20200720 and :TIME >= 1000
task t2
trigger :DOW == 4 and :TIME >= 1300
task t3
trigger :DD == 1 and :TIME >= 1200
task t4
trigger (:DOW == 1 and :TIME >= 1300) or (:DOW == 5 and :TIME >= 1000)
task t5
trigger :TIME == 0002 # 2 minutes past midnight
endfamily
endsuite
import os
from ecflow import (
Defs,
Suite,
Family,
Task,
Edit,
Trigger,
Complete,
Event,
Meter,
Time,
Day,
Date,
Edit,
)
def create_family_f2():
return Family(
"f2",
Edit(SLEEP=20),
Task("t1", Trigger(":ECF_DATE ==20200720 and :TIME >= 1000")),
Task("t2", Trigger(":DOW == 4 and :TIME >= 1300")),
Task("t3", Trigger(":DD == 1 and :TIME >= 1200")),
Task(
"t4",
Trigger("(:DOW == 1 and :TIME >= 1300) or (:DOW == 5 and :TIME >= 1000)"),
),
Task("t5", Trigger(":TIME == 0002")),
)
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_f2()))
print(defs)
print("Checking job creation: .ecf -> .job0")
print(defs.check_job_creation())
print("Checking trigger expressions")
errors = defs.check()
assert len(errors) == 0, errors
print("Saving definition to file 'test.def'")
defs.save_as_defs("test.def")
What to do
Modify the suite definition to update family
f2, as shown above.Replace the suite, using:
ecflow_client --suspend /test ecflow_client --replace /test test.def
python3 test.py python3 client.py
Use ecflow_ui to inspect why a task is queued, by selecting a queued task and clicking on the Why tab.
(Optional) Adjust the time attributes to make all task runs.