Commit 8805cdf7 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

add resources grabing from config file

parent 27d9816d
......@@ -39,8 +39,7 @@ class Component(object):
self.output_directory = None
self.config_reader = JFlowConfigReader()
self.version = self.get_version()
self.jflow_config_reader = JFlowConfigReader()
self.batch_options = self.jflow_config_reader.get_component_batch_options(self.__class__.__name__)
self.batch_options = self.config_reader.get_component_batch_options(self.__class__.__name__)
def _longestCommonSubstr(self, data, clean_end=True):
substr = ''
......@@ -127,6 +126,9 @@ class Component(object):
Define the component parameters, has to be implemented by subclasses
"""
raise NotImplementedError
def get_resource(self, resource):
return self.config_reader.get_resource(resource)
def get_exec_path(self, software):
exec_path = self.config_reader.get_exec(software)
......
......@@ -45,6 +45,9 @@ class JFlowConfigReader(object):
except NoOptionError, e:
return None
def get_resource(self, resource):
return self.reader.get("resources", resource)
def get_log_file_path(self):
"""
return the log file path
......
......@@ -103,12 +103,10 @@ class Workflow(threading.Thread):
if line.find("self.add_component") != -1:
prefix = "default"
component_name = line.strip().split("self.add_component")[1][1:-1].split(",")[0][1:-1]
print component_name+"."+prefix
pre = re.search("self.add_component\s*\(\s*\"(\S+)\"\s*(,\s*(args\s*=\s*)?\[.*\]\s*)?((,\s*(kwargs\s*=\s*)?{.*}\s*)?(,\s*(component_prefix\s*=\s*)?\"(\S+)\"\s*\)?)?)", line)
if pre:
if pre.groups()[-1]: prefix = pre.groups()[-1]
if pre.groups()[0]: component_name = pre.groups()[0]
print component_name+"."+prefix
if self._component_is_duplicated(component_name+"."+prefix):
raise ValueError("Component " + component_name + " with prefix " +
prefix + " already exist in this pipeline!")
......@@ -290,6 +288,9 @@ class Workflow(threading.Thread):
self._update_status_from_log()
return self.status
def get_resource(self, resource):
return self.jflow_config_reader.get_resource(resource)
def get_component_status(self, component_nameid):
status = {"time": 0.0,
"tasks": 0,
......
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