ecFlow's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The python API allows simulation. Simulation has the following benefits:

  • Exercise the suite definition. There is no need for '.ecf' files
  • Can be done on the client side, no need for server
  • Can help in detecting deadlock's
  • Will simulate with both 'real' and 'hybrid' clocks
  • A year's simulation can be done in a few minutes. Small definitions can be simulated in a few seconds

There are however restrictions. If the definition has large loops due to Repeat date attributes, which run indefinitely, then in this case the simulation will never complete, and will timeout after a years worth of run time.

(This can be compensated for by adding start and end clock)

Hence it's best to restrict simulation, to definitions which are known to complete.
If the simulation does not complete it will produce two files, which will help in the analysis:

  • defs.depth: This file shows a depth first view, of why simulation did not complete.
  • defs.flat: This shows a simple flat view, of why simulation did not complete

Both files will show which nodes are holding, and include the state of the holding trigger expressions.
def simulate_deadlock():

This simulation is expected to fail, since we have a deadlock/ race condition

defs = ecflow.Defs() # create a empty defs
suite = defs.add_suite("dead_lock")
fam = suite.add_family("family")
fam.add_task("t1").add_trigger("t2 == complete")
fam.add_task("t2").add_trigger("t1 == complete")
theResult = defs.simulate(); # simulate the definition
assert len(theResult) != 0, "Expected simulation to return errors" 
print theResult
if _name_ == "_main_":
    simulate_deadlock() 
  • No labels