def submit_benchmark(benchmark_id, num_tasks, fast=False, use_database=False, complete_run=False, keep_old_data=False, use_native_structure=False): '''Submit the benchmark to the cluster.''' qsub_command = 'qsub', benchmark_command = ( 'loop_benchmark.py', str(benchmark_id), '--use-database' if use_database else '--not-use-database', '--complete-run' if complete_run else '--not-complete_run', '--use-native-structure' if use_native_structure else '--not-use-native-structure') if fast: qsub_command += '-t', '1-{0}'.format(num_tasks) qsub_command += '-l', 'h_rt=0:30:00' else: qsub_command += '-t', '1-{0}'.format(num_tasks) qsub_command += '-l', 'h_rt=24:00:00' if not keep_old_data: utilities.clear_directory('job_output') qsub_command += '-o', 'job_output', '-e', 'job_output' qsub_cwd = os.path.dirname(__file__) subprocess.call(qsub_command + benchmark_command, cwd=qsub_cwd)
def resume_benchmark(benchmark_id, nstruct=None): qsub_command = 'qsub', benchmark_command = 'loop_benchmark.py', benchmark_id # You get weird errors if you forget to cast nstruct from string to int. if nstruct is not None: nstruct = int(nstruct) # Read the job parameters from the database. with database.connect() as session: benchmark = session.query(database.Benchmarks).get(benchmark_id) num_pdbs = len(benchmark.input_pdbs) # Make sure the right version of rosetta is being used. git_commit = subprocess.check_output( shlex.split('git rev-parse HEAD'), cwd=settings.rosetta).strip() git_diff = subprocess.check_output( shlex.split('git diff'), cwd=settings.rosetta).strip() if benchmark.git_commit != git_commit: message = "Benchmark \"{0}\" was run with rosetta commit #{1}, but commit #{2} is currently checked out. Press [Ctrl-C] to abort or [Enter] to continue." message = textwrap.fill(message.format(benchmark.id, benchmark.git_commit[:8], git_commit[:8])) raw_input(message) elif benchmark.git_diff != git_diff: message = "Uncommitted changes have been made to rosetta since benchmark \"{0}\" was run. Press [Ctrl-C] to abort or [Enter] to continue." message = textwrap.fill(message.format(benchmark.id)) raw_input(message) # Build the qsub command. if benchmark.fast: qsub_command += '-t', '1-{0}'.format((nstruct or 10) * num_pdbs) qsub_command += '-l', 'h_rt=0:30:00' else: qsub_command += '-t', '1-{0}'.format((nstruct or 500) * num_pdbs) qsub_command += '-l', 'h_rt=4:00:00' print "Your benchmark \"{0}\" (id={1}) is being resumed".format( benchmark.name, benchmark_id) # Submit the job. utilities.clear_directory('job_output') qsub_command += '-o', 'job_output', '-e', 'job_output' subprocess.call(qsub_command + benchmark_command)
def setup_latex_dir(self): """ Create the directory where all the *.tex and *.pdf files generated for this report will be stored. This method is meant to be used in a 'with' statement, so that it can automatically clean up the directory once the program terminates (either normally or via an exception). """ import shutil import tempfile try: # Create the root latex directory. if self.latex_dir is not None: utilities.clear_directory(self.latex_dir) else: self.latex_dir = tempfile.mkdtemp('.loop_benchmark') self.latex_dir = os.path.abspath(self.latex_dir) # Create subdirectories for every benchmark and loop. for benchmark in self: benchmark.latex_dir = os.path.join( self.latex_dir, benchmark.name + '_analysis', ) os.mkdir(benchmark.latex_dir) for loop in benchmark: loop.latex_dir = os.path.join( benchmark.latex_dir, loop.pdb_id, ) os.mkdir(loop.latex_dir) # Yield control to the rest of the program. yield finally: # Remove the latex directory if the user doesn't want to keep it. if not self.keep_latex and self.latex_dir is not None: shutil.rmtree(self.latex_dir)
def resume_benchmark(benchmark_id, nstruct=None, use_database=False): # This feature has not been implemented on the disk platfrom if not use_database: raise Exception( "resume benchmark has not been implemented on the disk platform!") qsub_command = 'qsub', benchmark_command = ('loop_benchmark.py', benchmark_id, '--use-database' if use_database else '--not-use-database', '--not-complete-run') # You get weird errors if you forget to cast nstruct from string to int. if nstruct is not None: nstruct = int(nstruct) # Read the job parameters from the saved data data_controller = DataController( 'database') if use_database else DataController('disk') benchmark_define_dict = data_controller.get_benchmark_define_dict( benchmark_id) num_pdbs = len(benchmark_define_dict['input_pdbs']) # Make sure the right version of rosetta is being used. git_commit = subprocess.check_output(shlex.split('git rev-parse HEAD'), cwd=settings.rosetta).strip() git_diff = subprocess.check_output(shlex.split('git diff'), cwd=settings.rosetta).strip() if benchmark_define_dict['git_commit'] != git_commit: message = "Benchmark \"{0}\" was run with rosetta commit #{1}, but commit #{2} is currently checked out. Press [Ctrl-C] to abort or [Enter] to continue." message = textwrap.fill( message.format(benchmark_define_dict['id'], benchmark_define_dict['git_commit'][:8], git_commit[:8])) raw_input(message) elif benchmark_define_dict['git_diff'] != git_diff: message = "Uncommitted changes have been made to rosetta since benchmark \"{0}\" was run. Press [Ctrl-C] to abort or [Enter] to continue." message = textwrap.fill(message.format(benchmark_define_dict['id'])) raw_input(message) # Build the qsub command. if benchmark_define_dict['fast']: qsub_command += '-t', '1-{0}'.format((nstruct or 10) * num_pdbs) qsub_command += '-l', 'h_rt=24:00:00' else: qsub_command += '-t', '1-{0}'.format((nstruct or 500) * num_pdbs) qsub_command += '-l', 'h_rt=24:00:00' print "Your benchmark \"{0}\" (id={1}) is being resumed".format( benchmark_define_dict['name'], benchmark_id) # Submit the job. utilities.clear_directory('job_output') qsub_command += '-o', 'job_output', '-e', 'job_output' subprocess.call(qsub_command + benchmark_command)
# Submit the benchmark to the cluster. qsub_command = 'qsub', benchmark_command = 'loop_benchmark.py', benchmark_id if fast: qsub_command += '-t', '1-{0}'.format(nstruct * len(pdbs)) qsub_command += '-l', 'h_rt=0:30:00' else: qsub_command += '-t', '1-{0}'.format(nstruct * len(pdbs)) qsub_command += '-l', 'h_rt=6:00:00' if not arguments['--keep-old-data']: utilities.clear_directory('job_output') qsub_command += '-o', 'job_output', '-e', 'job_output' qsub_cwd = os.path.dirname(__file__) subprocess.call(qsub_command + benchmark_command, cwd=qsub_cwd) def resume_benchmark(benchmark_id, nstruct=None): qsub_command = 'qsub', benchmark_command = 'loop_benchmark.py', benchmark_id # You get weird errors if you forget to cast nstruct from string to int. if nstruct is not None: nstruct = int(nstruct) # Read the job parameters from the database.