Commit bc5edc7d authored by Jerome Mariette's avatar Jerome Mariette
Browse files

handle errors when not adding a loaded component

parent 59a9f93b
...@@ -111,28 +111,32 @@ class Workflow(threading.Thread): ...@@ -111,28 +111,32 @@ class Workflow(threading.Thread):
def add_component(self, component_name, args=[], kwargs={}, component_prefix="default"): def add_component(self, component_name, args=[], kwargs={}, component_prefix="default"):
# first build and check if this component is OK # first build and check if this component is OK
my_pckge = __import__(self.comp_pckg[component_name], globals(), locals(), [component_name], -1) if self.comp_pckg.has_key(component_name):
# build the object and define required field my_pckge = __import__(self.comp_pckg[component_name], globals(), locals(), [component_name], -1)
cmpt_object = getattr(my_pckge, component_name)() # build the object and define required field
cmpt_object.output_directory = self.get_component_output_directory(component_name, component_prefix) cmpt_object = getattr(my_pckge, component_name)()
cmpt_object.prefix = component_prefix cmpt_object.output_directory = self.get_component_output_directory(component_name, component_prefix)
if kwargs: cmpt_object.define_parameters(**kwargs) cmpt_object.prefix = component_prefix
else: cmpt_object.define_parameters(*args) if kwargs: cmpt_object.define_parameters(**kwargs)
else: cmpt_object.define_parameters(*args)
# if already init, add the component to the list and check if weaver should be executed
if self.component_nameids_is_init: # if already init, add the component to the list and check if weaver should be executed
# add the component if self.component_nameids_is_init:
self.components.append(cmpt_object) # add the component
# if this one require a dynamic pipeline, execute the first part self.components.append(cmpt_object)
if cmpt_object.is_dynamic: # if this one require a dynamic pipeline, execute the first part
self._execute_weaver() if cmpt_object.is_dynamic:
else: self._execute_weaver()
if self._component_is_duplicated(cmpt_object): else:
raise ValueError("Component " + cmpt_object.__class__.__name__ + " with prefix " + if self._component_is_duplicated(cmpt_object):
cmpt_object.prefix + " already exist in this pipeline!") raise ValueError("Component " + cmpt_object.__class__.__name__ + " with prefix " +
self.component_nameids[cmpt_object.get_nameid()] = None cmpt_object.prefix + " already exist in this pipeline!")
self.component_nameids[cmpt_object.get_nameid()] = None
return cmpt_object
return cmpt_object else:
sys.exit(component_name + " component cannot be loaded, available components are: " + ", ".join(self.comp_pckg.keys()))
def pre_process(self): def pre_process(self):
pass pass
......
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