Commit f896ad90 authored by Zdralovic Edim's avatar Zdralovic Edim

Cleaning up code

parent afdff62b
This diff is collapsed.
......@@ -58,7 +58,7 @@ class CWLRestAPI(FlaskView):
route_base = '/' #flask_classful specific, class variable
def __init__(self):
self.baseDir = './workflows/' #for developing only
#self.sharedStorage = '/home/cuhoni66/toilCWLTest/'
self.sharedStorage = '/home/cuhoni66/toilCWLTest/'
self.__wfManager = WorkflowManager()
############################################################
#Section: Routed Methods
......@@ -68,32 +68,16 @@ class CWLRestAPI(FlaskView):
<h2>The service is available.</h2>
"""
# @route('/workflows/setPath', methods=['POST'])
# def postGit(self):
"""
A POST on this route expects three arguments:
1) Usertoken
2) Workflowname
3) public Git URL
The Git-Repo is pulled and stored locally. It is expected to have a CWL and YAML file in
the outmost directive. The YAML file is parsed, converted in JSON and returned to the frontend.
A WorkflowWrapper object is instantiated. This only sets up a pipeline but does not start it.
"""
# byteData = request.data
# data = json.loads(byteData.decode("utf-8"))
# wf = WorkflowWrapper(data["usertoken"], self.sharedStorage, data["workflowName"])
# return json.dumps(self.__wfManager.addWorkflow(wf))
@route('/workflows', methods=['POST'])
def postWorkflow(self):
"""
Here the pipeline is addressed with the given workflowname (route /workflows/gitURL) and
actually started with the corresponding parameters from the modified YAML file.
Here the pipeline is initialized, getting the path to the shared storage from Django. The path is passed as a parameter
and the CWL and YAML file from the given directory are set as parameters.
"""
byteData = request.data
data = json.loads(byteData.decode("utf-8"))
wf = WorkflowWrapper(userToken = data["usertoken"], sharedStorage = data["sharedStoragePath"], workflowName = data["workflowName"], baseDir = self.baseDir)
wf = WorkflowWrapper(userToken = data["usertoken"], sharedStorage = self.sharedStorage, workflowName = data["workflowName"], baseDir = self.baseDir)
self.__wfManager.addWorkflow(wf)
return json.dumps(self.__wfManager.startWorkflow(wf.workflowName))
......@@ -342,14 +326,7 @@ class WorkflowWrapper(threading.Thread):
|
|---workflows
|
|---USER_TOKEN
|
|---data
|
|--- WORKFLOW_NAME
|
|--- *.cwl
|--- *.yaml
|---WORKFLOW_NAME
|
|---jobStore
|
......@@ -392,24 +369,19 @@ class WorkflowWrapper(threading.Thread):
self.workDir = sys.intern(baseDir+userToken+"/work/")
self.jobStore = sys.intern(baseDir+userToken+"/jobStore/")
self.logDir = sys.intern(baseDir+userToken+"/logs/")
#self.dataDir = sys.intern(baseDir+userToken+"/data/")
self.userToken = userToken
#self.dataFilesDir = ""
self.workflowDBID = None
self.stopped = False
self.jobStoreForPipeline = self.jobStore+str(self.workflowName)
#self.dataFilesDir = self.dataDir+str(self.workflowName)
if not self.restart:
self.createDirs()
#self.saveFilesToDataFileDir()
self.workflowDBID = wesParser.parse_workflow(self.userToken, workflowName, self.cwlFilePath, wesDAO, self.ymlFilePath)
#self.toilRunnerArgsList = ["toil-cwl-runner", "--debugWorker", "--clean=onSuccess", "--outdir="+self.outDir,"--workDir="+self.workDir, "--jobStore="+self.jobStoreForPipeline, "--singularity", self.cwlFilePath, self.ymlFilePath,]
self.toilRunnerArgsList = ["toil-cwl-runner", "--debugWorker", "--outdir="+self.outDir,"--workDir="+self.workDir, "--jobStore="+self.jobStoreForPipeline, "--singularity", self.cwlFilePath, self.ymlFilePath,]
self.toilRunnerArgsListRestart = ["toil-cwl-runner", "--restart", "--debugWorker", "--clean=onSuccess", "--outdir="+self.outDir,"--workDir="+self.workDir, "--jobStore="+self.jobStoreForPipeline, "--singularity", self.cwlFilePath, self.ymlFilePath,]
self.toilRunnerArgsList = ["toil-cwl-runner", "--maxMemory=3G", "--debugWorker", "--outdir="+self.outDir,"--workDir="+self.workDir, "--jobStore="+self.jobStoreForPipeline, "--singularity", self.cwlFilePath, self.ymlFilePath,]
self.toilRunnerArgsListRestart = ["toil-cwl-runner", "--maxMemory=3G", "--restart", "--debugWorker", "--clean=onSuccess", "--outdir="+self.outDir,"--workDir="+self.workDir, "--jobStore="+self.jobStoreForPipeline, "--singularity", self.cwlFilePath, self.ymlFilePath,]
threading.Thread.__init__(self)
############################################################
#Section: Public Methods
......@@ -424,19 +396,6 @@ class WorkflowWrapper(threading.Thread):
os.makedirs(self.workDir)
os.makedirs(self.logDir)
os.makedirs(self.jobStore)
#os.makedirs(self.dataDir)
#os.makedirs(self.dataFilesDir)
def saveFilesToDataFileDir(self):
"""
The given Git-Repo is pulled and stored in the 'dataFilesDir' directory.
"""
gitCloner = subprocess.Popen(['git', 'clone', self.gitRepoUrl, self.dataFilesDir], shell=False)
gitCloner.wait()
self.ymlFilePath = glob.glob(self.dataFilesDir+"/*.yml")[0]
self.cwlFilePath = glob.glob(self.dataFilesDir+"/*.cwl")[0]
self.yamlStream = yaml.safe_load(open(self.ymlFilePath, "r"))
self.cwlStream = yaml.safe_load(open(self.cwlFilePath, "r"))
def run(self):
"""
......
digraph "packages" {
charset="utf-8"
rankdir=BT
"0" [label="__init__", shape="box"];
"1" [label="encodings", shape="box"];
"2" [label="encodings.aliases", shape="box"];
"3" [label="encodings.ascii", shape="box"];
"4" [label="encodings.base64_codec", shape="box"];
"5" [label="encodings.big5", shape="box"];
"6" [label="encodings.big5hkscs", shape="box"];
"7" [label="encodings.bz2_codec", shape="box"];
"8" [label="encodings.charmap", shape="box"];
"9" [label="encodings.cp037", shape="box"];
"10" [label="encodings.cp1006", shape="box"];
"11" [label="encodings.cp1026", shape="box"];
"12" [label="encodings.cp1125", shape="box"];
"13" [label="encodings.cp1140", shape="box"];
"14" [label="encodings.cp1250", shape="box"];
"15" [label="encodings.cp1251", shape="box"];
"16" [label="encodings.cp1252", shape="box"];
"17" [label="encodings.cp1253", shape="box"];
"18" [label="encodings.cp1254", shape="box"];
"19" [label="encodings.cp1255", shape="box"];
"20" [label="encodings.cp1256", shape="box"];
"21" [label="encodings.cp1257", shape="box"];
"22" [label="encodings.cp1258", shape="box"];
"23" [label="encodings.cp273", shape="box"];
"24" [label="encodings.cp424", shape="box"];
"25" [label="encodings.cp437", shape="box"];
"26" [label="encodings.cp500", shape="box"];
"27" [label="encodings.cp65001", shape="box"];
"28" [label="encodings.cp720", shape="box"];
"29" [label="encodings.cp737", shape="box"];
"30" [label="encodings.cp775", shape="box"];
"31" [label="encodings.cp850", shape="box"];
"32" [label="encodings.cp852", shape="box"];
"33" [label="encodings.cp855", shape="box"];
"34" [label="encodings.cp856", shape="box"];
"35" [label="encodings.cp857", shape="box"];
"36" [label="encodings.cp858", shape="box"];
"37" [label="encodings.cp860", shape="box"];
"38" [label="encodings.cp861", shape="box"];
"39" [label="encodings.cp862", shape="box"];
"40" [label="encodings.cp863", shape="box"];
"41" [label="encodings.cp864", shape="box"];
"42" [label="encodings.cp865", shape="box"];
"43" [label="encodings.cp866", shape="box"];
"44" [label="encodings.cp869", shape="box"];
"45" [label="encodings.cp874", shape="box"];
"46" [label="encodings.cp875", shape="box"];
"47" [label="encodings.cp932", shape="box"];
"48" [label="encodings.cp949", shape="box"];
"49" [label="encodings.cp950", shape="box"];
"50" [label="encodings.euc_jis_2004", shape="box"];
"51" [label="encodings.euc_jisx0213", shape="box"];
"52" [label="encodings.euc_jp", shape="box"];
"53" [label="encodings.euc_kr", shape="box"];
"54" [label="encodings.gb18030", shape="box"];
"55" [label="encodings.gb2312", shape="box"];
"56" [label="encodings.gbk", shape="box"];
"57" [label="encodings.hex_codec", shape="box"];
"58" [label="encodings.hp_roman8", shape="box"];
"59" [label="encodings.hz", shape="box"];
"60" [label="encodings.idna", shape="box"];
"61" [label="encodings.iso2022_jp", shape="box"];
"62" [label="encodings.iso2022_jp_1", shape="box"];
"63" [label="encodings.iso2022_jp_2", shape="box"];
"64" [label="encodings.iso2022_jp_2004", shape="box"];
"65" [label="encodings.iso2022_jp_3", shape="box"];
"66" [label="encodings.iso2022_jp_ext", shape="box"];
"67" [label="encodings.iso2022_kr", shape="box"];
"68" [label="encodings.iso8859_1", shape="box"];
"69" [label="encodings.iso8859_10", shape="box"];
"70" [label="encodings.iso8859_11", shape="box"];
"71" [label="encodings.iso8859_13", shape="box"];
"72" [label="encodings.iso8859_14", shape="box"];
"73" [label="encodings.iso8859_15", shape="box"];
"74" [label="encodings.iso8859_16", shape="box"];
"75" [label="encodings.iso8859_2", shape="box"];
"76" [label="encodings.iso8859_3", shape="box"];
"77" [label="encodings.iso8859_4", shape="box"];
"78" [label="encodings.iso8859_5", shape="box"];
"79" [label="encodings.iso8859_6", shape="box"];
"80" [label="encodings.iso8859_7", shape="box"];
"81" [label="encodings.iso8859_8", shape="box"];
"82" [label="encodings.iso8859_9", shape="box"];
"83" [label="encodings.johab", shape="box"];
"84" [label="encodings.koi8_r", shape="box"];
"85" [label="encodings.koi8_t", shape="box"];
"86" [label="encodings.koi8_u", shape="box"];
"87" [label="encodings.kz1048", shape="box"];
"88" [label="encodings.latin_1", shape="box"];
"89" [label="encodings.mac_arabic", shape="box"];
"90" [label="encodings.mac_centeuro", shape="box"];
"91" [label="encodings.mac_croatian", shape="box"];
"92" [label="encodings.mac_cyrillic", shape="box"];
"93" [label="encodings.mac_farsi", shape="box"];
"94" [label="encodings.mac_greek", shape="box"];
"95" [label="encodings.mac_iceland", shape="box"];
"96" [label="encodings.mac_latin2", shape="box"];
"97" [label="encodings.mac_roman", shape="box"];
"98" [label="encodings.mac_romanian", shape="box"];
"99" [label="encodings.mac_turkish", shape="box"];
"100" [label="encodings.mbcs", shape="box"];
"101" [label="encodings.oem", shape="box"];
"102" [label="encodings.palmos", shape="box"];
"103" [label="encodings.ptcp154", shape="box"];
"104" [label="encodings.punycode", shape="box"];
"105" [label="encodings.quopri_codec", shape="box"];
"106" [label="encodings.raw_unicode_escape", shape="box"];
"107" [label="encodings.rot_13", shape="box"];
"108" [label="encodings.shift_jis", shape="box"];
"109" [label="encodings.shift_jis_2004", shape="box"];
"110" [label="encodings.shift_jisx0213", shape="box"];
"111" [label="encodings.tis_620", shape="box"];
"112" [label="encodings.undefined", shape="box"];
"113" [label="encodings.unicode_escape", shape="box"];
"114" [label="encodings.unicode_internal", shape="box"];
"115" [label="encodings.utf_16", shape="box"];
"116" [label="encodings.utf_16_be", shape="box"];
"117" [label="encodings.utf_16_le", shape="box"];
"118" [label="encodings.utf_32", shape="box"];
"119" [label="encodings.utf_32_be", shape="box"];
"120" [label="encodings.utf_32_le", shape="box"];
"121" [label="encodings.utf_7", shape="box"];
"122" [label="encodings.utf_8", shape="box"];
"123" [label="encodings.utf_8_sig", shape="box"];
"124" [label="encodings.uu_codec", shape="box"];
"125" [label="encodings.zlib_codec", shape="box"];
"0" -> "100" [arrowhead="open", arrowtail="none"];
"1" -> "100" [arrowhead="open", arrowtail="none"];
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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