Commit a6eb000d authored by Jerome Mariette's avatar Jerome Mariette

add NG6Workflow class

parent 63bef845
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import inspect
import os
import pickle
from jflow.workflow import Workflow
from weaver.function import PythonFunction
class NG6Workflow (Workflow):
"""
"""
def __add_analysis_behaviour(self, fn, input_files, arguments):
def new_run(*args, **kwargs):
fn(*args, **kwargs)
add = PythonFunction(add_analysis, cmd_format="{EXE} {ARG} {IN}")
add(inputs=input_files, arguments=arguments)
return new_run
def add_component(self, component_name, args, component_prefix="default"):
# first build and check if this component is OK
myPckge = __import__(self.compPckg[component_name], globals(), locals(), [component_name], -1)
# build the object and define required field
cmpt_object = getattr(myPckge, component_name)()
cmpt_object.output_directory = self.get_component_output_directory(component_name, component_prefix)
cmpt_object.prefix = component_prefix
cmpt_object.define_parameters(*args)
if self._component_is_duplicated(cmpt_object):
raise ValueError("Component " + cmpt_object.__class__.__name__ + " with prefix " +
cmpt_object.prefix + " already exist in this pipeline!")
# if the built object is an analysis
for derived_class in cmpt_object.__class__.__bases__:
if derived_class.__name__ == "Analyse":
# first add analysis information to the analysis object
cmpt_object.define_analysis()
# serialized the object
analysis_dump_path = self.get_temporary_file(".dump")
analysis_dump = open(analysis_dump_path, "wb")
pickle.dump(cmpt_object, analysis_dump)
analysis_dump.close()
args = [analysis_dump_path]
output_files = []
for table in cmpt_object.dump_files:
output_files.extend(cmpt_object.dump_files[table])
cmpt_object.run = self.__add_analysis_behaviour(cmpt_object.run, output_files, args)
break
# add the component
self.components.append(cmpt_object)
# if this one require a dynamic pipeline, execute the first part
if cmpt_object.is_dynamic:
self._execute_weaver()
# empty the component list execution
self.components = []
return cmpt_object
\ No newline at end of file
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