def scheduleJob(self, scriptDir, jobUniqueId, jobDescriptor, jobString): # Generate the script file scriptFilePath = self.writeScriptFile(scriptDir, jobUniqueId, jobString) # Update the job descriptor with the path to the generated script jobDescriptor['jobScriptFile'] = scriptFilePath # Generate the job scheduler command schedulerType = jobDescriptor['schedulerType'] generator = SchedulerCommand.factory(schedulerType) command = generator.generateSubmitCommand(jobDescriptor) # Now run the generated command try: process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) outputTuple = process.communicate(None) output = outputTuple[0] error = outputTuple[1] except subprocess.CalledProcessError as inst: return 'ERROR: ' + str(inst) # Now look for the job id in the output outArray = output.split('\n') for line in outArray: m = self.qsubOutputRegex.match(line) if m: return m.group(1) return 'ERROR: ' + error + ', OUTPUT: ' + output
def scheduleJob(self, scriptDir, jobUniqueId, jobDescriptor, jobString): # Generate the script file scriptFilePath = self.writeScriptFile(scriptDir, jobUniqueId, jobString) # Update the job descriptor with the path to the generated script jobDescriptor['jobScriptFile'] = scriptFilePath # Generate the job scheduler command schedulerType = jobDescriptor['schedulerType'] generator = SchedulerCommand.factory(schedulerType) command = generator.generateSubmitCommand(jobDescriptor) # Now run the generated command try : process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) outputTuple = process.communicate(None) output = outputTuple[0] error = outputTuple[1] except subprocess.CalledProcessError as inst : return 'ERROR: ' + str(inst) # Now look for the job id in the output outArray = output.split('\n') for line in outArray : m = self.qsubOutputRegex.match(line) if m : return m.group(1) return 'ERROR: ' + error + ', OUTPUT: ' + output
def getJobStatus(self, jobId, jobDescriptor): # Generate the job status command schedulerType = jobDescriptor['schedulerType'] generator = SchedulerCommand.factory(schedulerType) command = generator.generateStatusCommand() try: process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) outputTuple = process.communicate(None) output = outputTuple[0] except subprocess.CalledProcessError as inst: return 'ERROR: ' + str(inst) # Now find the line of output corresponding to our job # 235364 scottwit 00:05:00 1 starting vs64.tukey matcher = re.compile( '^' + str(jobId) + '\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s*$') outArray = output.split('\n') for line in outArray: m = matcher.match(line) if m: return json.dumps([m.group(4), {'hostnames': m.group(5)}]) return json.dumps([ 'NO_SUCH_JOB', { 'problem': 'Unable to find job id in status list' } ])
def getJobStatus(self, jobId, jobDescriptor) : # Generate the job status command schedulerType = jobDescriptor['schedulerType'] generator = SchedulerCommand.factory(schedulerType) command = generator.generateStatusCommand() try : process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) outputTuple = process.communicate(None) output = outputTuple[0] except subprocess.CalledProcessError as inst : return 'ERROR: ' + str(inst) # Now find the line of output corresponding to our job # 235364 scottwit 00:05:00 1 starting vs64.tukey matcher = re.compile('^' + str(jobId) + '\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s*$') outArray = output.split('\n') for line in outArray : m = matcher.match(line) if m : return json.dumps([ m.group(4), {'hostnames': m.group(5)} ]) return json.dumps([ 'NO_SUCH_JOB', { 'problem': 'Unable to find job id in status list' } ])