-
-
Save mschubert/8736380 to your computer and use it in GitHub Desktop.
A python script that emulates the LSF "bsub" command so you can test configurations locally before running them on a cluster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Fake qsub command, for testing qsub jobs in local | |
original: https://bitbucket.org/dalloliogm/fake-qsub | |
""" | |
import argparse | |
import subprocess | |
import logging | |
import os | |
parser = argparse.ArgumentParser(description = __doc__, | |
epilog='fake-bsub is an environment for testing Grid jobs in local') | |
#parser.add_argument('commandsfile', metavar='commands', type=str, help='the file containing the commands to be run') | |
parser.add_argument('--queue', '-q', metavar='queue', type=str, help='queue', default='medium') | |
parser.add_argument('-J', metavar='jobname', help='set job name') | |
parser.add_argument('-w', metavar='description', help='Job description - message to be printed when the job is finished?') | |
parser.add_argument('-o', metavar='stdoutfile', help='STDOUT log file') | |
parser.add_argument('-e', metavar='stderrfile', help='STDERR log file') | |
parser.add_argument('-P', metavar='team', help='Team or user name') | |
parser.add_argument('-M', metavar='memory', help='RAM memory required') | |
parser.add_argument('-R', metavar='requirements', help='String of resource requirements') | |
parser.add_argument('-K', help='Wait for job completion', action="store_true") | |
parser.add_argument('commands', metavar='commands', help='command to be executed', nargs='+') | |
parser.add_argument('--fakebsub_debug', metavar='fakebsub_debug', help='Fake-bsub debug mode') | |
# Parse arguments and eventually set debug mode | |
args = parser.parse_args() | |
if args.fakebsub_debug is True: | |
logging.basicConfig(level=logging.DEBUG) | |
# Print debugging things | |
logging.debug(args) | |
#logging.debug('launching ' + commandsfile) | |
# Call the bash process | |
subprocess.call(args.commands, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment