def killMasterAndParasol(): """Method to destroy master process """ tempFile = getTempFile() popen("ps -a", tempFile) fileHandle = open(tempFile, 'r') line = fileHandle.readline() #Example parasol state lines: #67401 ttys002 0:00.06 /Users/benedictpaten/kent/src/parasol/bin/paraNode start -hub=localhost -log=/tmp/node.2009-07-08.log -umask=002 -userPath=bin:bin/x86_64:bin/i #67403 ttys002 0:00.65 /Users/benedictpaten/kent/src/parasol/bin/paraHub -log=/tmp/hub.2009-07-08.log machineList subnet=127.0.0 #68573 ttys002 0:00.00 /Users/benedictpaten/kent/src/parasol/bin/paraNode start -hub=localhost -log=/tmp/node.2009-07-08.log -umask=002 -userPath=bin:bin/x86_64:bin/i while line != '': tokens = line.split() if 'paraNode' in line or 'paraHub' in line: if random.random() > 0.5: i = os.system("kill %i" % int(tokens[0])) logger.info("Tried to kill parasol process: %i, line: %s, exit value: %i" % (int(tokens[0]), line, i)) break elif 'jobTreeMaster.py' in line: logger.info("Have job tree master line") if random.random() > 0.5: i = os.system("kill %i" % int(tokens[0])) logger.info("Tried to kill master process: %i, line: %s, exit value: %i" % (int(tokens[0]), line, i)) break line = fileHandle.readline() fileHandle.close() os.remove(tempFile) parasolRestart()
def parasolRestart(): """Function starts the parasol hub and node. """ parasolStop() while True: machineList = os.path.join(workflowRootPath(), "jobTree", "machineList") #pathEnvVar = os.environ["PATH"] os.system("paraNode start -hub=localhost") #-umask=002 -userPath=%s -sysPath=%s" % (pathEnvVar, pathEnvVar)) os.system("paraHub %s subnet=127.0.0 &" % (machineList,)) tempFile = getTempFile() dead = True try: popen("parasol status", tempFile) fileHandle = open(tempFile, 'r') line = fileHandle.readline() while line != '': if "Nodes dead" in line: print line if int(line.split()[-1]) == 0: dead = False line = fileHandle.readline() fileHandle.close() except RuntimeError: pass os.remove(tempFile) if not dead: break else: logger.info("Tried to restart the parasol process, but failed, will try again") parasolStop() time.sleep(5) logger.info("Restarted the parasol process")
def _run_evolver_decomposed_wdl(self, name): """ Run the full evolver test, putting the jobstore and output in tempDir but instead of doing in in one shot, use cactus-prepare to make a wdl script and run that locally through cromwell """ # hack to use docker to remove filetree in teardown, as cromwell # can leave root files hanging around there self.cromwell = True out_seqfile = os.path.join(self.tempDir, 'evolverMammalsOut.txt') in_seqfile = './examples/evolverMammals.txt' out_wdl = os.path.join(self.tempDir, 'prepared.wdl') cmd = [ 'cactus-prepare', in_seqfile, '--outHal', self._out_hal(name), '--jobStore', self._job_store(name), '--wdl', '--dockerImage', 'evolvertestdocker/cactus:latest', '--preprocessCores', '2', '--blastCores', '4', '--alignCores', '4' ] # specify an output directory cw_optionsfile = os.path.join(self.tempDir, 'options.json') cw_output = os.path.join(self.tempDir, 'cromwell-output') with open(cw_optionsfile, 'w') as cw_opts: cw_opts.write('{\n') cw_opts.write( ' \"final_workflow_outputs_dir\": \"{}\",\n'.format( cw_output)) cw_opts.write(' \"use_relative_output_paths\": true\n') cw_opts.write('}\n') # download cromwell subprocess.check_call([ 'wget', '-q', 'https://github.com/broadinstitute/cromwell/releases/download/49/cromwell-49.jar' ], cwd=self.tempDir) # run cactus-prepare and write the output to a wdl file popen(' '.join(cmd), out_wdl) # run the wdl script in cromwell subprocess.check_call([ 'java', '-jar', './cromwell-49.jar', 'run', out_wdl, '-o', cw_optionsfile ], cwd=self.tempDir) # fish the file out of cromwell shutil.copyfile( os.path.join(cw_output, os.path.basename(self._out_hal(name))), self._out_hal(name))