def test_make_jobs(self):
        """writing the job files works"""
        # no commands should make no jobs files
        self.assertEqual(make_jobs([], "test", self.queue), [])

        # one job file should be created
        filenames = make_jobs([self.command], "test_qsub", self.queue)
        self.assertTrue(len(filenames) == 1)
        observed_text = list(open(filenames[0]))

        self.assertEqual(
            "".join(observed_text), QSUB_TEXT %
            ("72:00:00", 1, 1, self.queue, "test_qsub", "oe", self.command))
Example #2
0
    def test_make_jobs(self):
        """writing the job files works"""
        # no commands should make no jobs files
        self.assertEqual(make_jobs([], "test", self.queue), [])

        # one job file should be created
        filenames = make_jobs([self.command], "test_qsub", self.queue)
        self.assertTrue(len(filenames) == 1)
        observed_text = list(open(filenames[0]))

        self.assertEqual(
            "".join(observed_text), QSUB_TEXT % ("72:00:00", 1, 1, self.queue, "test_qsub", "oe", self.command)
        )
def main():
    option_parser, opts, args =\
       parse_command_line_parameters(**script_info)
       
    if opts.submit_jobs and not opts.make_jobs:
        option_parser.error('Must pass -m if passing -s. (Sorry about this, '+\
        'it\'s for backwards-compatibility.)') 

    min_args = 2
    if len(args) != min_args:
        option_parser.error('Program requires <commands file> and  <job prefix>')

    if (len(args[1])>10 or len(args[1])==0):
        option_parser.error('job prefix must be 1-10 characters long')
 
    commands = list(open(args[0]))
    job_prefix = args[1]

    if(not exists(opts.job_dir)):
        try:
            makedirs(opts.job_dir)
        except OSError:
            exit(" Jobs directory can not be created. "
                 +"Check for permissions or file with the same name: %s\n"
                 % opts.job_dir)

    if (opts.make_jobs):
        filenames = make_jobs(commands, job_prefix, opts.queue, opts.job_dir)
    else:
        exit("Should we ever get here???")
    if (opts.submit_jobs):
        submit_jobs(filenames, opts.verbose)
def main():
    option_parser, opts, args =\
       parse_command_line_parameters(**script_info)

    if opts.submit_jobs and not opts.make_jobs:
        option_parser.error('Must pass -m if passing -s. (Sorry about this, '
                            'it\'s for backwards-compatibility.)')

    min_args = 2
    if len(args) != min_args:
        option_parser.error('Program requires <commands file> and '
                            '<job prefix>')

    if (len(args[1]) > 10 or len(args[1]) == 0):
        option_parser.error('job prefix must be 1-10 characters long')

    commands = list(open(args[0]))
    job_prefix = args[1]

    if (not exists(opts.job_dir)):
        try:
            makedirs(opts.job_dir)
        except OSError:
            exit(" Jobs directory can not be created. "
                 "Check for permissions or file with the same name: %s\n" %
                 opts.job_dir)

    if (opts.make_jobs):
        filenames = make_jobs(commands, job_prefix, opts.queue, opts.job_dir,
                              (str(opts.max_walltime) + ":00:00"), opts.cpus,
                              opts.nodes)
    else:
        exit("Should we ever get here???")
    if (opts.submit_jobs):
        submit_jobs(filenames, opts.verbose)
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    if opts.submit_jobs and not opts.make_jobs:
        option_parser.error("Must pass -m if passing -s. (Sorry about this, " "it's for backwards-compatibility.)")

    min_args = 2
    if len(args) != min_args:
        option_parser.error("Program requires <commands file> and " "<job prefix>")

    if len(args[1]) > 10 or len(args[1]) == 0:
        option_parser.error("job prefix must be 1-10 characters long")

    commands = list(open(args[0]))
    job_prefix = args[1]

    if not exists(opts.job_dir):
        try:
            makedirs(opts.job_dir)
        except OSError:
            exit(
                " Jobs directory can not be created. "
                "Check for permissions or file with the same name: %s\n" % opts.job_dir
            )

    if opts.make_jobs:
        filenames = make_jobs(
            commands, job_prefix, opts.queue, opts.job_dir, (str(opts.max_walltime) + ":00:00"), opts.cpus, opts.nodes
        )
    else:
        exit("Should we ever get here???")
    if opts.submit_jobs:
        submit_jobs(filenames, opts.verbose)
def main():
    option_parser, opts, args =\
        parse_command_line_parameters(**script_info)

    if opts.submit_jobs and not opts.make_jobs:
        option_parser.error('Must pass -m if passing -s. (Sorry about this, '
                            'it\'s for backwards-compatibility.)')

    min_args = 2
    if len(args) != min_args:
        option_parser.error('Program requires <commands file> and '
                            '<job prefix>')

    if (len(args[1]) > 10 or len(args[1]) == 0):
        option_parser.error('job prefix must be 1-10 characters long')

    if(not exists(opts.job_dir)):
        try:
            makedirs(opts.job_dir)
        except OSError:
            exit(" Jobs directory can not be created. "
                 "Check for permissions or file with the same name: %s\n"
                 % opts.job_dir)

    commands = list(open(args[0]))
    job_prefix = args[1]

    if opts.mem_per_cpu:
        mem_per_cpu = " --mem_per_cpu=" + opts.mem_per_cpu
    else:
        mem_per_cpu = ""

    if opts.queue:
        queue = " -p " + opts.queue
    else:
        queue = ""

    if (opts.make_jobs):
        filenames = make_jobs(
            commands,
            job_prefix,
            opts.queue,
            opts.job_dir)
    else:
        exit("Should we ever get here???")
    if (opts.submit_jobs):
        for f in filenames:
            qiime_system_call("".join([
                    "sbatch",
                    queue,
                    " -J ", job_prefix,
                    mem_per_cpu,
                    " -o ", normpath(opts.job_dir), sep, job_prefix, "_%j.out",
                    " ", f
                ]), shell=True)
def main():
    option_parser, opts, args =\
        parse_command_line_parameters(**script_info)

    if opts.submit_jobs and not opts.make_jobs:
        option_parser.error('Must pass -m if passing -s. (Sorry about this, '
                            'it\'s for backwards-compatibility.)')

    min_args = 2
    if len(args) != min_args:
        option_parser.error('Program requires <commands file> and '
                            '<job prefix>')

    if (len(args[1]) > 10 or len(args[1]) == 0):
        option_parser.error('job prefix must be 1-10 characters long')

    if(not exists(opts.job_dir)):
        try:
            makedirs(opts.job_dir)
        except OSError:
            exit(" Jobs directory can not be created. "
                 "Check for permissions or file with the same name: %s\n"
                 % opts.job_dir)

    commands = list(open(args[0]))
    job_prefix = args[1]

    if opts.mem_per_cpu:
        mem_per_cpu = " --mem-per-cpu=" + opts.mem_per_cpu
    else:
        mem_per_cpu = ""

    if opts.queue:
        queue = " -p " + opts.queue
    else:
        queue = ""

    if (opts.make_jobs):
        filenames = make_jobs(
            commands,
            job_prefix,
            opts.queue,
            opts.job_dir)
    else:
        exit("Should we ever get here???")
    if (opts.submit_jobs):
        for f in filenames:
            qiime_system_call("".join([
                    "sbatch",
                    queue,
                    " -J ", job_prefix,
                    mem_per_cpu,
                    " -o ", normpath(opts.job_dir), sep, job_prefix, "_%j.out",
                    " ", f
                ]), shell=True)
Example #8
0
    def test_submit_jobs(self):
        """submit jobs via qsub works"""

        filenames = make_jobs([self.command], "test_qsub", self.queue)
        submit_jobs(filenames)

        for i in range(10):
            if exists(self.tmp_result_file):
                return
            else:
                #wait for job to finish
                sleep(10)
        self.fail("The test job apparently never finished.\n" +
                  "check the jobs error log and check the queue status\n.")
 def test_submit_jobs(self):
     """submit jobs via qsub works"""
     
     filenames = make_jobs([self.command], "test_qsub", self.queue) 
     submit_jobs(filenames)
     
     for i in range(10):
         if exists(self.tmp_result_file):
             return
         else:
             #wait for job to finish
             sleep(10)
     self.fail("The test job apparently never finished.\n"
               +"check the jobs error log and check the queue status\n.")