Commit f4e90440 authored by Penom Nom's avatar Penom Nom
Browse files

Update addanalysis workflow to link the basicanalysis to any existing analysis...

Update addanalysis workflow to link the basicanalysis to any existing analysis using the analysis id.
email type check.
parent a58aa0cb
......@@ -45,7 +45,7 @@ from jflow.component import Component
from weaver.function import PythonFunction
def add_analysis(analysis_cfg, *input_files):
def add_analysis(parent_id, analysis_cfg, *input_files):
from ng6.analysis import Analysis
from ng6.project import Project
from ng6.run import Run
......@@ -66,6 +66,9 @@ def add_analysis(analysis_cfg, *input_files):
if os.path.isfile(parent_analysis_cfg):
parent = Analysis.get_from_file(parent_analysis_cfg)
analysis.parent = parent
elif parent_id != 'none' :
parent = Analysis.get_from_id(int(parent_id))
analysis.parent = parent
# process the parsing of the analysis
analysis.post_process()
......@@ -166,6 +169,7 @@ class Analysis (Component):
analysis_dump.close()
inputs.append(analysis_dump_path)
parent_id = 'none'
wait_for_files = []
for attr in self.__dict__:
# TODO if no Output object raise error
......@@ -175,13 +179,16 @@ class Analysis (Component):
elif self.__getattribute__(attr).__class__.__name__ == "OutputFileList":
wait_for_files.extend(self.__getattribute__(attr))
if self.parent:
inputs.append(self.parent.get_config_file_path())
if self.parent.id:
parent_id = self.parent.id
else :
inputs.append(self.parent.get_config_file_path())
# then run the component
self.process()
# add the add_analysis command lines to the make
add = PythonFunction(add_analysis, cmd_format="{EXE} {OUT} {IN}")
add(includes=wait_for_files, outputs=self.get_config_file_path(), inputs=inputs)
add = PythonFunction(add_analysis, cmd_format="{EXE} {ARG} {OUT} {IN}")
add(includes=wait_for_files, outputs=self.get_config_file_path(), inputs=inputs, arguments=parent_id)
def __str__(self):
"""
......
......@@ -21,6 +21,7 @@ import sys
from ng6.ng6workflow import BasicNG6Workflow
from ng6.project import Project
from ng6.run import Run
from ng6.analysis import Analysis
class AddAnalysis (BasicNG6Workflow):
......@@ -32,13 +33,14 @@ class AddAnalysis (BasicNG6Workflow):
self.add_parameter("compression", "How should data be compressed once archived", choices = ['none', 'gz', 'bz2'], default = 'none')
self.add_parameter("delete", "Should the input data be deleted once the process is over", type = bool , default = False)
self.add_parameter("archive_name", "Give a name to the final archive", default = 'ng6_archive')
self.add_parameter("project_id", "The project id the analysis belongs to", type = int, required = True)
self.add_parameter("run_id", "The run id the run belongs to", type = int, required = True)
self.add_parameter("project_id", "The project id the analysis belongs to", type = 'int', required = True)
self.add_parameter("run_id", "The run id the run belongs to", type = 'int', required = True)
self.add_parameter("analysis_name", "Give a name to your analysis", required = True)
self.add_parameter("analysis_description", "Give a description to your analysis", required = True)
self.add_parameter("analysis_software", "Which software was used for this analysis", required = True)
self.add_parameter("analysis_software_options", "Which software options were used for this analysis", required = True)
self.add_parameter("analysis_software_version", "analysis_software_version", required = True)
self.add_parameter("parent_analysis", "The id of an analysis to be used as a parent analysis", type= 'int')
self.add_exclusion_rule( "project_id", "run_id" )
def process(self):
......@@ -68,11 +70,12 @@ class AddAnalysis (BasicNG6Workflow):
sys.exit()
addto = "project" if self.project else "run"
parent = Analysis.get_from_id(self.parent_analysis) if self.parent_analysis else None
basicanalysis = self.add_component("BasicAnalyse", [files_to_save, self.analysis_name,
self.analysis_description, self.analysis_software, self.analysis_software_options,
self.analysis_software_version, self.compression, self.delete,
self.archive_name], addto=addto)
self.archive_name], addto=addto, parent = parent)
def post_process(self):
if self.runobj:
......
......@@ -19,6 +19,7 @@ import argparse
import datetime
import os
import pwd
import re
from ng6.t3MySQLdb import t3MySQLdb
......@@ -101,6 +102,9 @@ def password(val):
return val
def email(val):
if not re.match( r'[^@]+@[^@]+\.[^@]+', val) :
raise argparse.ArgumentTypeError("Invalid email '%s' " % val)
return val
def samplemetadata(metadata):
......
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