Ejemplo n.º 1
0
    def executeWorkflow (self, sites, workflowName, compilerPlugin=None):
        additionalArgs = [ " --dir ${outputDir}/work --dax ${outputDax} --submit" ]
        arguments = self.getExecuteArguments (sites=sites,
                                              workflow=workflowName,
                                              other=additionalArgs)
        executeCommand = "pegasus-plan %s" % arguments
        logger.debug ("getExecuteArguments: %s", executeCommand)
        executor = Executor ({})
        logger.info ("--(pegasus-plan): %s", executeCommand)

        lines = []
        def submitProcessor (line):
            line = line.replace ("\n", "")
            lines.append (line)
            logger.info ("--(pegasus-plan): %s", line)

        wrappedOutputProcessor = submitProcessor
        if compilerPlugin:
            def wrappedOutputProcessor (line):
                submitProcessor (line)
                compilerPlugin.notifyShellEvent (line, workflowName)
        try:
            executor.execute (executeCommand, pipe=True, processor=wrappedOutputProcessor)
        except Exception as e:
            traceback.print_exc (e)
            # missing stderr.
            logger.error ('\n'.join (lines))
            raise e
Ejemplo n.º 2
0
    def examineWorkflow (self):

        jobstatelog = os.path.join (self.workdir, 'jobstate.log')

        sched_id = 0
        def process (line):
            finishedTag = 'DAGMAN_FINISHED'
            schedIdTag = 'DAGMAN STARTED'
            
            index = line.find (schedIdTag)
            if index > -1:
                sched_id = line.split (' ')[-2]
                
            index = line.find (finishedTag)
            if index > -1:
                self.isComplete = True
                    
        text = GraysonUtil.readFile (jobstatelog, process)

        output = []
        executor = Executor ({
                'condorHome' : os.environ ['CONDOR_HOME'],
                'sched_id'   : sched_id
                })
        executor.execute (command   = "${condorHome}/bin/condor_q ${sched_id} -format '%s' JobStatus",
                          pipe      = True,
                          processor = lambda n : output.append (n))

        self.isRunning = ''.join (output) == WorkflowStatus.CONDOR_JOB_STATUS__RUNNING        

        logger.debug ("WorkflowMonitor - isRunning=%s, isComplete=%s", self.isRunning, self.isComplete) 
Ejemplo n.º 3
0
def get_flow_status (request):
    path = os.path.join (settings.GRAYSONWEB_WORKFLOW_ROOT,
                         request.REQUEST ['path'])
    output = []
    executor = Executor ({ 'flowPath' : path })
    pegasus = os.environ ['PEGASUS_HOME']
    executor.execute (command   = "%s/bin/pegasus-status -l ${flowPath}" % pegasus,
                      pipe      = True,
                      processor = lambda n : output.append (n))
    return ViewUtil.get_text_response (''.join (output))
Ejemplo n.º 4
0
def debugger (request):
    commandMap = {
        'stop'   : 'condor_rm',
        'pause'  : 'condor_hold',
        'resume' : 'condor_release'
        }
    # TODO: Auth check to ensure this job belongs to this user... before running actual condor commands...

    output = []
    executor = Executor ({
            'condorHome' : os.environ ['CONDOR_HOME'],
            'command'    : commandMap [request.REQUEST ["command"]],
            'jobId'      : request.REQUEST ["job"]
            })

    executor.execute (command        = "${condorHome}/bin/${command} ${jobId} 2>&1",
                      pipe           = True,
                      processor      = lambda n : output.append (n),
                      raiseException = False)

    return ViewUtil.get_json_response ({
            "status" : "ok",
            "output" : ''.join (output)
            })