Пример #1
0
def delete_run (request):
    response = { "status" : "ok" }
    workdir = request.REQUEST ["workdir"]
    workflowId = request.REQUEST ["workflowid"]
    runId = request.REQUEST ["runid"]    
    workflowName = os.path.basename (workflowId).replace (".dax", "")
    process_username = ViewUtil.get_os_username ()    
    workdirPath = workdir
    if runId:
        workdirPath = GraysonUtil.form_workdir_path (workdir, process_username, workflowName, runId)
    user = ViewUtil.get_user (request)
    workdirPath = ViewUtil.form_workflow_path (user, workdirPath)
    logger.debug ("DELETING workflow run: %s", workdirPath)
    try:
        shutil.rmtree (workdirPath)
    except Exception as e:
        logger.exception ("exception deleting %s", workdirPath)
        traceback.print_exc ()
        response ["status"] = "fail"
    return ViewUtil.get_json_response (response)
Пример #2
0
def get_job_output (request):
    user = ViewUtil.get_user (request)
    workdir = request.REQUEST ['workdir']
    workflow_id = request.REQUEST ['workflowid']
    job_id = request.REQUEST ['jobid']
    run_id = request.REQUEST ['runid']
    if not run_id:
        run_id = ""
    if not workflow_id:
        workflow_id = ""
    logger.debug ("getting job output: workdir=%s, workflowid: %s, runid: %s, jobid: %s", workdir, workflow_id, run_id, job_id)
    process_username = ViewUtil.get_os_username ()
    workdirPath = GraysonUtil.form_workdir_path (workdir, process_username, workflow_id, run_id)

    workdirPath = ViewUtil.form_workflow_path (user, workdirPath)

    logger.debug ("workdirPath: %s", workdirPath)

    text = ""

    if job_id.startswith ('/'):
        job_id = job_id [1:]
    concrete = os.path.join (workdirPath, job_id)
    logger.debug ('concrete: --- %s', concrete)
    if os.path.exists (concrete):
        logger.debug ("concrete --- : %s", concrete)
        text = GraysonUtil.readFile (concrete)
    else:
        logger.debug ("regex: --- : %s", concrete)
        workflow = GridWorkflow (workdirPath)
        outputs = workflow.getOutputFiles (subworkflows = [ workdirPath ], item = job_id) 
        jobOutput = None
        if outputs and len (outputs) > 0:
            jobOutput = outputs [0]
        logger.debug ("got job output: %s \n for job_id: %s", jobOutput, job_id)
        if jobOutput:
            text = GraysonUtil.readFileAsString (jobOutput)
    return ViewUtil.get_text_response (text)
Пример #3
0
def get_flow_events (request):
    workdir    = request.REQUEST ["workdir"]
    workflowId = request.REQUEST ["workflowid"]
    runId      = request.REQUEST ["runid"]    
    dax        = request.REQUEST ["dax"] if "dax" in request.REQUEST else None

    if not dax:
        dax = os.path.basename (workflowId)
        logger.debug ("dax: %s", dax)

    workflowName = os.path.basename (workflowId).replace (".dax", "")

    
    process_username = ViewUtil.get_os_username ()
    workdirPath = GraysonUtil.form_workdir_path (workdir, process_username, workflowName, runId)
    user = ViewUtil.get_user (request)
    workdirPath = ViewUtil.form_workflow_path (user, workdirPath)
    logger.debug ("launching monitor: user: %s, workdir: %s, workflowId: %s, runId: %s, dax: %s",
                  user.username, workdirPath, workflowId, runId, dax)

    workflowMonitorDatabase = WorkflowMonitorDatabase ()
    WorkflowMonitor.ensureRunning (workflowRoot    = settings.GRAYSONWEB_WORKFLOW_ROOT,
                                   amqpSettings    = settings.AMQP_SETTINGS,
                                   eventBufferSize = settings.EVENT_BUFFER_SIZE)
    
    workflowMonitorDatabase.subscribeToWorkflow (
        settings.GRAYSONWEB_WORKFLOW_ROOT,
        {
            "username"    : user.username,
            "workflowId"  : workflowId,
            "workdir"     : workdirPath,
            "daxen"       : dax.split (','),
            "buffer"      : 0
            })

    return ViewUtil.get_json_response ({ "status" : "ok" })