Leave the execution_graph as none until compiled

Instead of forcing a compile when accessing the
execution_graph property just leave it as none until
compiling occurs.

It seems awkward to have the side-effect of automatically
compiling occur when a engine property is accessed.

Change-Id: I2760c369bc5926c6293199cb7e500e98d6c3eeb9
This commit is contained in:
Joshua Harlow
2014-03-30 17:17:44 -07:00
parent 5048dfc2a9
commit cdf829ac82
2 changed files with 10 additions and 2 deletions

View File

@@ -76,8 +76,14 @@ class ActionEngine(base.EngineBase):
@property
def execution_graph(self):
self.compile()
return self._analyzer.execution_graph
"""The graph of nodes to be executed.
NOTE(harlowja): Only accessible after compilation has completed.
"""
g = None
if self._compiled and self._analyzer:
g = self._analyzer.execution_graph
return g
@lock_utils.locked
def run(self):

View File

@@ -464,6 +464,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
utils.TaskNoRequiresNoReturns(name='task2'))
engine = self._make_engine(flow)
engine.compile()
graph = engine.execution_graph
self.assertIsInstance(graph, networkx.DiGraph)
@@ -471,6 +472,7 @@ class EngineGraphFlowTest(utils.EngineTestBase):
flow = utils.TaskNoRequiresNoReturns(name='task1')
engine = self._make_engine(flow)
engine.compile()
graph = engine.execution_graph
self.assertIsInstance(graph, networkx.DiGraph)