Commit 458622cc authored by Georgios Dagkakis's avatar Georgios Dagkakis

methods moved to generic plugin object

parent 51adee60
...@@ -11,6 +11,26 @@ class Plugin(object): ...@@ -11,6 +11,26 @@ class Plugin(object):
def __init__(self, logger, configuration_dict): def __init__(self, logger, configuration_dict):
self.logger = logger self.logger = logger
self.configuration_dict = configuration_dict self.configuration_dict = configuration_dict
# returns the predecessors of a node
def getPredecessors(self, data, node_id):
predecessors=[]
from copy import copy
edges=copy(data['graph']['edge'])
for edge_id,edge in edges.iteritems():
if edge['destination']==node_id:
predecessors.append(edge['source'])
return predecessors
# returns the successors of a node
def getSuccessors(self, data, node_id):
successors=[]
from copy import copy
edges=copy(data['graph']['edge'])
for edge_id,edge in edges.iteritems():
if edge['source']==node_id:
successors.append(edge['destination'])
return successors
class ExecutionPlugin(Plugin): class ExecutionPlugin(Plugin):
"""Plugin to handle the execution of multiple simulation runs. """Plugin to handle the execution of multiple simulation runs.
...@@ -41,26 +61,6 @@ class InputPreparationPlugin(Plugin): ...@@ -41,26 +61,6 @@ class InputPreparationPlugin(Plugin):
} }
return data return data
# returns the predecessors of a node
def getPredecessors(self, data, node_id):
predecessors=[]
from copy import copy
edges=copy(data['graph']['edge'])
for edge_id,edge in edges.iteritems():
if edge['destination']==node_id:
predecessors.append(edge['source'])
return predecessors
# returns the successors of a node
def getSuccessors(self, data, node_id):
successors=[]
from copy import copy
edges=copy(data['graph']['edge'])
for edge_id,edge in edges.iteritems():
if edge['source']==node_id:
successors.append(edge['destination'])
return successors
class OutputPreparationPlugin(Plugin): class OutputPreparationPlugin(Plugin):
def postprocess(self, data): def postprocess(self, data):
"""Postprocess the data after simulation run. """Postprocess the data after simulation run.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment