Beispiel #1
0
 def load(self, filename):
     self.tabptr = 0
     self.tabdata = []
     self.tasks = []
     self.track = []
     self.keyref = {}
     with ZipFile(filename, "r") as wtab:
         workflowFile = wtab.open("workflow.cwl", "r")
         self.workflow = yamler(io.TextIOWrapper(workflowFile))
         templateFile = wtab.open("template.yml", "r")
         self.template = yamler(io.TextIOWrapper(templateFile))
         for cwlfile in wtab.namelist():
             if ".cwl" in cwlfile and cwlfile != "workflow.cwl":
                 taskfile = wtab.open(cwlfile, "r")
                 self.tasks.append(
                     [cwlfile, yamler(io.TextIOWrapper(taskfile))])
         header = 0
         for line in wtab.open("table.txt", "r"):
             line = line.decode("utf8")
             line = line.strip()
             if line[0] == '#':
                 continue
             if header == 2:
                 self.tabdata.append(re.split(' ', line))
                 self.keyref[(self.tabdata[-1])[1]] = len(self.tabdata) - 1
                 self.track.append(TR_COMPLETE)
                 continue
             if header == 0:
                 self.fieldnames = re.split(' ', line)
                 header = 1
             else:
                 self.fieldtypes = re.split(' ', line)
                 header = 2
     self.lastfilename = filename
Beispiel #2
0
def makeyml(pathname, command):
    """
    Generates a yml file to guide execution, based on the specific->general hierarchy
    Run specific parameters override batch specific parameters override global parameters

    :param pathname: The path of the project of interest
    """

    if ".wtx" in command:
        wt = Worktable(command)
        cmdDict = wt.template
    else:
        cmdyml = (re.split(".cwl", command)[0]).strip() + ".yml"
        cmdDict = yamler(open(scriptFolder + "/" + cmdyml, "r"))
    globalDict = yamler(open(coreFolder + "/stoa.yml", "r"))
    if not os.path.exists("stoa.yml"):
        open("stoa.yml", "a").close()
    batchDict = yamler(open("stoa.yml", "r"))
    if not os.path.exists(pathname + "/stoa.yml"):
        open(pathname + "/stoa.yml", "a").close()
    specDict = yamler(open(pathname + "/stoa.yml", "r"))

    for key in cmdDict:
        globalDict[key] = cmdDict[key]
    for key in batchDict:
        globalDict[key] = batchDict[key]
    for key in specDict:
        globalDict[key] = specDict[key]

    writeyaml(globalDict, pathname + "/runraw.yml")
    ymlvars(pathname + "/runraw.yml", pathname + "/run.yml",
            coreFolder + "/" + pathname)
Beispiel #3
0
def ExecCWL(cmdFile, pathname):
    result = {}
    success = 0
    if ".wtx" in cmdFile:
        wt = Worktable(cmdFile)
        wtFile = cmdFile
        cmdFile = wt.unpack()
    else:
        wt = False
        cmdFile = scriptFolder + "/" + cmdFile
    try:
        result = cwlinvoke(
            pathname, cmdFile,
            yamler(open(pathname + "/run.yml", "r"), convert=True))
        writeyaml(result, pathname + "/.pipelog.txt")
    except WorkflowException as werr:
        success = 1
        log = open(pathname + "/.pipelog.txt", "a")
        log.write("Workflow Exception: {}\n".format(werr.args))
        log.close()
    #writeyaml(result, pathname+"/stoa_out.yml")
    if wt:
        wt.repack(cmdFile)  # Needs a more efficient indexing method here
        index = wt.byref(pathname)
        wt.update(index, parsecwloutput(pathname, result))
        wt.save(wtFile)

    return success
Beispiel #4
0
def parseAction(filename):
    """
    Parses a script file to extract directives

    :param filename: The name of the script file
    :return: A list of directives
    """
    properties = {}
    tree = yamler(filename)
    if 'stoa' in tree:
        for item in tree['stoa']:
            properties[item] = tree['stoa'][item]
    return properties
Beispiel #5
0
 def addtask(self, filename):
     newfile = re.split("/", filename)[-1]
     self.tasks.append([newfile, yamler(open(filename, "r"))])
Beispiel #6
0
 def addtask(self, filename):
     self.task.append([filename, yamler(open(filename, "r"))])
Beispiel #7
0
 def addfile(self, filename):
     if ".cwl" in filename:
         self.workflow = yamler(open(filename, "r"))
     if ".yml" in filename:
         self.template = yamler(open(filename, "r"))
Beispiel #8
0
started = False

targetFolder = ""
currentFolder = {}
userspace = {}
session = {}
runStatus = "Nothing"

tasklist = {}

siteroot = "http://127.0.0.1:8888"
scriptPath = os.path.realpath(__file__)
webPath = os.path.split(scriptPath)[0] + "/"

config = yamler(open("stoa.yml", "r"))
projectname = config['stoa-info']['project-name']

handlerpath = config['stoa-info']['filehandler']['script']
handlerpattern = config['stoa-info']['filehandler']['pattern']
handler_name, fext = os.path.splitext(os.path.split(handlerpath)[-1])
filehandler = load_source(handler_name, handlerpath)

reftables = {}
if 'reftable' in config['stoa-info']:
    reftables[config['stoa-info']['reftable']
              ['name']] = config['stoa-info']['reftable']['coords']

obsfile = ""  #TODO: Link this value to config file

stopCommand = "<a href=\"javascript:getPath('r')\">Click here to stop batch</a>"