Adding another task
To add another task to the existing suite test perform the following steps:
Modify the suite definition file to include the new task.
Create a new ecf script for the new task.
Reload and begin the modified suite definition into the ecflow_server.
The following shows the two methods of reloading the modified suite definition into the ecflow_server. The options presented are:
manually updating the text definition, and loading it via the CLI ecflow_client
to use the Python API to programmatically update and load the suite definition
It is good practice to suspend a suite before starting to update any part of it.
This avoids the suite automatically starting before the complete set of changes is complete.
Use the ecFlowUI to suspend the test suite, or run the following command
to do the same using the CLI ecflow_client:
ecflow_client --suspend /test
Update the suite definition file to add the new task t2.
# Definition of the suite test
suite test
edit ECF_HOME "{{HOME}}/course"
task t1
task t2
endsuite
Note
As before, replace {{HOME}}/course to point at the tutorial directory.
Load the modified suite definition into the ecflow_server using the CLI ecflow_client:
# Ensure suite 'test' doesn't exist by deleting all suites
ecflow_client --delete _all_
# Load the modified suite definition
ecflow_client --load test.def
# or, equivalently, replace the suite if it already exists
ecflow_client --replace /test test.def # replace the whole suite
After loading the updated suite definition, begin the suite:
# Begin the suite
ecflow_client --begin test
The following script updates on the previous test.py to add the new task t2:
#!/usr/bin/env python3
import pathlib
from ecflow import Defs, Suite, Task, Edit
if __name__ == '__main__':
base = pathlib.Path.home() / "course"
print("[1] Creating suite definition")
defs = Defs(Suite("test", Edit(ECF_HOME=str(base)), Task("t1"), Task("t2")))
print(defs)
print("[2] Checking job creation: .ecf -> .job0")
print(defs.check_job_creation())
print("[3] Saving definition to file 'test.def'")
defs.save_as_defs(str(base / "test.def"))
The following script deletes all suites in the server and reload modified test.def, we could update client.py
#!/usr/bin/env python3
import pathlib
from ecflow import Client
if __name__ == '__main__':
base = pathlib.Path.home() / "course"
try:
ci = Client()
print("[1] Delete all suites from the server")
ci.delete_all() # clear out the server
print("[2] Load suite definition in 'test.def' into the server")
ci.load(str(base / "test.def"))
# line above reads suite definition from disk and loads into the server
print("[3] Begin the 'test' suite")
ci.begin_suite("test")
### An alternative to deleting all suites before reloading
### is to simply replace the existing suite
print("[1] Suspend the 'test' suite")
ci.suspend("/test")
print("[2] Replace the 'test' suite")
ci.replace( "/test", "test.def")
except RuntimeError as e:
print("Failed:", e)
An alternative to deleting, loading and beginning the suite every time, the following script replaces the existing suite with the modified one. Notice that to avoid starting the suite straight away, the script suspends the suite using the Python API.
#!/usr/bin/env python3
import pathlib
from ecflow import Client
if __name__ == '__main__':
base = pathlib.Path.home() / "course"
try:
ci = Client()
print("[1] Suspend the 'test' suite")
ci.suspend("/test")
print("[2] Replace the 'test' suite")
ci.replace( "/test", str(base / "test.def"))
except RuntimeError as e:
print("Failed:", e)
Note
For the sake of brevity the examples that follow will not show the step of loading the suite.
What to do
Suspend the
testsuite, either using the ecFlowUI or the CLI ecflow_client.Update the suite definition file by adding a new task
t2.Create ecf script file, named
t2.ecfby copyingt1.ecf.(Optional) Update the Python scripts
test.pyandclient.py(as shown above).Replace the
testsuite using the CLI ecflow_client.Resume the the suite using ecFlowUI or the CLI ecflow_client.
Observe the parallel execution of the tasks in ecFlowUI.