Commit d465346d authored by Frédéric Escudié's avatar Frédéric Escudié
Browse files

No commit message

No commit message
parent ac7821ab
...@@ -67,10 +67,10 @@ class Component(object): ...@@ -67,10 +67,10 @@ class Component(object):
required=False, flag=None, group="default", display_name=None, add_to=None): required=False, flag=None, group="default", display_name=None, add_to=None):
new_param = InputFile(name, help, flag=flag, file_format=file_format, default=default, new_param = InputFile(name, help, flag=flag, file_format=file_format, default=default,
type=type, required=required, group=group, display_name=display_name) type=type, required=required, group=group, display_name=display_name)
new_param.component_nameid = self.get_nameid()
# store where the parameter is coming from # store where the parameter is coming from
if hasattr(default, "component_nameid"): new_param.component_nameid = self.get_nameid()
if issubclass( default.__class__, LinkTraceback ):
new_param.parent_component_nameid = default.component_nameid new_param.parent_component_nameid = default.component_nameid
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
...@@ -92,18 +92,24 @@ class Component(object): ...@@ -92,18 +92,24 @@ class Component(object):
if default == None: if default == None:
inputs = [] inputs = []
else: else:
inputs = [IOFile(file, self.get_nameid(), None, file_format) for file in default] inputs = [IOFile(file, file_format, self.get_nameid(), None) for file in default]
new_param = InputFileList(name, help, flag=flag, file_format=file_format, default=inputs, new_param = InputFileList(name, help, flag=flag, file_format=file_format, default=inputs,
type=type, required=required, group=group, display_name=display_name) type=type, required=required, group=group, display_name=display_name)
# store where the parameter is coming from # store where the parameter is coming from
new_param.component_nameid = self.get_nameid()
if issubclass( default.__class__, list ): if issubclass( default.__class__, list ):
for idx, val in enumerate(default): for idx, val in enumerate(default):
if hasattr( val, "component_nameid" ): if issubclass( val.__class__, LinkTraceback ):
new_param[idx].parent_component_nameid = val.component_nameid new_param[idx].parent_component_nameid = val.component_nameid
elif hasattr( default, "component_nameid" ): new_param.parent_component_nameid.append( val.component_nameid )
new_param.parent_component_nameid = default.component_nameid else:
new_param.parent_component_nameid.append( None )
else:
if issubclass( default.__class__, LinkTraceback ):
new_param[0].parent_component_nameid = default.component_nameid
new_param.parent_component_nameid.append( default.component_nameid )
else:
new_param.parent_component_nameid.append( None )
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
if add_to: if add_to:
try: try:
...@@ -147,6 +153,7 @@ class Component(object): ...@@ -147,6 +153,7 @@ class Component(object):
filename = os.path.basename(filename) filename = os.path.basename(filename)
new_param = OutputFile(name, help, default=os.path.join(self.output_directory, filename), new_param = OutputFile(name, help, default=os.path.join(self.output_directory, filename),
file_format=file_format, group=group, display_name=display_name) file_format=file_format, group=group, display_name=display_name)
# store where the parameter is coming from
new_param.component_nameid = self.get_nameid() new_param.component_nameid = self.get_nameid()
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
if add_to: if add_to:
...@@ -160,8 +167,10 @@ class Component(object): ...@@ -160,8 +167,10 @@ class Component(object):
def add_output_file_list(self, name, help, file_format="any", pattern='{basename_woext}.out', def add_output_file_list(self, name, help, file_format="any", pattern='{basename_woext}.out',
items=None, group="default", display_name=None, add_to=None): items=None, group="default", display_name=None, add_to=None):
default = [IOFile(file, self.get_nameid(), None, file_format) for file in self.get_outputs(pattern, items)] default = [IOFile(file, file_format, self.get_nameid(), None) for file in self.get_outputs(pattern, items)]
new_param = OutputFileList(name, help, default=default, file_format=file_format, group=group, display_name=display_name) new_param = OutputFileList(name, help, default=default, file_format=file_format, group=group, display_name=display_name)
# store where the parameter is coming from
new_param.component_nameid = self.get_nameid()
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
if add_to: if add_to:
try: try:
...@@ -176,6 +185,8 @@ class Component(object): ...@@ -176,6 +185,8 @@ class Component(object):
group="default", display_name=None, add_to=None): group="default", display_name=None, add_to=None):
new_param = OutputFilesEndsWith(name, help, self.output_directory, pattern, include=(behaviour == "include"), new_param = OutputFilesEndsWith(name, help, self.output_directory, pattern, include=(behaviour == "include"),
file_format=file_format, group=group, display_name=display_name) file_format=file_format, group=group, display_name=display_name)
# store where the parameter is coming from
new_param.component_nameid = self.get_nameid()
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
if add_to: if add_to:
try: try:
...@@ -190,6 +201,8 @@ class Component(object): ...@@ -190,6 +201,8 @@ class Component(object):
group="default", display_name=None, add_to=None): group="default", display_name=None, add_to=None):
new_param = OutputFilesPattern(name, help, self.output_directory, pattern, include=(behaviour == "exclude"), new_param = OutputFilesPattern(name, help, self.output_directory, pattern, include=(behaviour == "exclude"),
file_format=file_format, group=group, display_name=display_name) file_format=file_format, group=group, display_name=display_name)
# store where the parameter is coming from
new_param.component_nameid = self.get_nameid()
# if this input should be added to a particular parameter # if this input should be added to a particular parameter
if add_to: if add_to:
try: try:
......
...@@ -372,23 +372,27 @@ class AbstractParameter(object): ...@@ -372,23 +372,27 @@ class AbstractParameter(object):
return create_test_function(self.type) return create_test_function(self.type)
class AbstractIOFile(object): class LinkTraceback(object):
def __init__(self, file_format="any"): def __init__(self, component_nameid=None, parent_component_nameid=[]):
self.component_nameid = component_nameid
self.parent_component_nameid = parent_component_nameid
class AbstractIOFile(LinkTraceback):
def __init__(self, file_format="any", component_nameid=None, parent_component_nameid=[]):
LinkTraceback.__init__(self, component_nameid, parent_component_nameid)
self.file_format = file_format self.file_format = file_format
self.component_nameid = None
self.parent_component_nameid = None
class IOFile(str): class IOFile(str, AbstractIOFile):
def __new__(self, val="", component_nameid=None, parent_component_nameid=[], file_format="any"): def __new__(self, val="", file_format="any", component_nameid=None, parent_component_nameid=None):
return str.__new__(self, val) return str.__new__(self, val)
def __init__(self, val, component_nameid=None, parent_component_nameid=[], file_format="any"): def __init__(self, val="", file_format="any", component_nameid=None, parent_component_nameid=None):
self.component_nameid = component_nameid AbstractIOFile.__init__(self, file_format, component_nameid, parent_component_nameid)
self.parent_component_nameid = parent_component_nameid
self.file_format = file_format
class MultiParameter(dict, AbstractParameter): class MultiParameter(dict, AbstractParameter):
...@@ -985,9 +989,11 @@ class OutputFilesEndsWith(DynamicOutput): ...@@ -985,9 +989,11 @@ class OutputFilesEndsWith(DynamicOutput):
output_files = list() output_files = list()
for file in os.listdir( self.output_directory ): for file in os.listdir( self.output_directory ):
if file.endswith( self.end_str ) and self.include : if file.endswith( self.end_str ) and self.include :
output_files.append( IOFile(os.path.join(self.output_directory, file), None, None, self.file_format) ) output_files.append( IOFile(os.path.join(self.output_directory, file), self.file_format, self.component_nameid, None) )
self.component_parent_nameid.append(None)
elif not file.endswith( self.end_str ) and not self.include: elif not file.endswith( self.end_str ) and not self.include:
output_files.append( IOFile(os.path.join(self.output_directory, file), None, None, self.file_format) ) output_files.append( IOFile(os.path.join(self.output_directory, file), self.file_format, self.component_nameid, None) )
self.component_parent_nameid.append(None)
list.__init__(self, output_files) list.__init__(self, output_files)
...@@ -1015,7 +1021,9 @@ class OutputFilesPattern(DynamicOutput): ...@@ -1015,7 +1021,9 @@ class OutputFilesPattern(DynamicOutput):
output_files = list() output_files = list()
for file in os.listdir( self.output_directory ): for file in os.listdir( self.output_directory ):
if self.include and re.search( self.pattern, file ) is not None: if self.include and re.search( self.pattern, file ) is not None:
output_files.append( IOFile(os.path.join(self.output_directory, file), None, None,self.file_format) ) output_files.append( IOFile(os.path.join(self.output_directory, file), self.file_format, self.component_nameid, None) )
self.component_parent_nameid.append(None)
elif not self.include and re.search( self.pattern, file ) is None: elif not self.include and re.search( self.pattern, file ) is None:
output_files.append( IOFile(os.path.join(self.output_directory, file), None, None,self.file_format) ) output_files.append( IOFile(os.path.join(self.output_directory, file), self.file_format, self.component_nameid, None) )
self.component_parent_nameid.append(None)
return list.__init__(self, output_files) return list.__init__(self, output_files)
\ No newline at end of file
...@@ -338,13 +338,14 @@ class Workflow(threading.Thread): ...@@ -338,13 +338,14 @@ class Workflow(threading.Thread):
gr.add_node_attribute(cpt.get_nameid(), self.COMPONENT_GRAPH_LABEL) gr.add_node_attribute(cpt.get_nameid(), self.COMPONENT_GRAPH_LABEL)
for cpt in self.components: for cpt in self.components:
for ioparameter in cpt.__dict__.values(): for ioparameter in cpt.__dict__.values():
if issubclass( ioparameter.__class__, InputFile ) and hasattr(ioparameter, "component_nameid"): if issubclass( ioparameter.__class__, InputFile ):
if ioparameter.parent_component_nameid != None:
try: gr.add_edge((ioparameter.parent_component_nameid, ioparameter.component_nameid)) try: gr.add_edge((ioparameter.parent_component_nameid, ioparameter.component_nameid))
except: pass except: pass
if issubclass( ioparameter.__class__, InputFileList): if issubclass( ioparameter.__class__, InputFileList):
for io in ioparameter: for iofile in ioparameter:
if hasattr(io, "component_nameid"): if iofile.parent_component_nameid != None:
try: gr.add_edge((io.parent_component_nameid, io.component_nameid)) try: gr.add_edge((iofile.parent_component_nameid, ioparameter.component_nameid))
except: pass except: pass
return gr return gr
...@@ -620,8 +621,6 @@ class Workflow(threading.Thread): ...@@ -620,8 +621,6 @@ class Workflow(threading.Thread):
# update outputs # update outputs
for output in cmpt_object.get_dynamic_outputs(): for output in cmpt_object.get_dynamic_outputs():
output.update() output.update()
for file in output:
file.component_id = cmpt_object.get_nameid()
else: else:
if self._component_is_duplicated(cmpt_object): if self._component_is_duplicated(cmpt_object):
raise ValueError("Component " + cmpt_object.__class__.__name__ + " with prefix " + raise ValueError("Component " + cmpt_object.__class__.__name__ + " with prefix " +
......
Supports Markdown
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