Ejemplo n.º 1
0
 def test_write_pbs_files(self):
     commands = ["echo 1", "echo 2", "echo 3", "echo 4"]
     command_params = {'nb_cores_per_command': self.cores}
     job_generator = JobGenerator(self.queue,
                                  commands,
                                  command_params=command_params)
     filenames = job_generator.write_pbs_files(self.testing_dir)
     assert_equal(len(filenames), 4)
 def test_generate_pbs2_cpu(self):
     # Should needs two PBS file
     command_params = {'nb_cores_per_command': self.cores // 2}
     job_generator = JobGenerator(self.queue, self.commands, command_params)
     assert_equal(len(job_generator.pbs_list), 2)
     assert_equal(job_generator.pbs_list[0].commands, self.commands[:2])
     assert_equal(job_generator.pbs_list[1].commands, self.commands[2:])
    def test_generate_pbs(self):
        job_generator = JobGenerator(self.queue, self.commands)

        # Test nb_cores_per_command argument
        # Should needs one PBS file
        assert_equal(len(job_generator.pbs_list), 1)
        assert_equal(job_generator.pbs_list[0].commands, self.commands)
Ejemplo n.º 4
0
 def test_generate_pbs2_gpu(self):
     # Test nb_gpus_per_command argument
     # Should needs two PBS file
     command_params = {'nb_gpus_per_command': self.gpus // 2}
     job_generator = JobGenerator(self.queue_gpu,
                                  self.commands,
                                  command_params=command_params)
     assert_equal(len(job_generator.pbs_list), 2)
     assert_equal(job_generator.pbs_list[0].commands, self.commands[:2])
     assert_equal(job_generator.pbs_list[1].commands, self.commands[2:])
Ejemplo n.º 5
0
    def _test_add_pbs_flags(self, flags):
        job_generator = JobGenerator(self.queue, self.commands)
        job_generator.add_pbs_flags(flags)

        resources = []
        options = []

        for flag in flags:
            if flag.startswith('-l'):
                resources += [flag[:2] + ' ' + flag[2:]]
            elif flag.startswith('-'):
                options += [(flag[:2] + ' ' + flag[2:]).strip()]

        for pbs in job_generator.pbs_list:
            pbs_str = pbs.__str__()
            for flag in resources:
                assert_equal(pbs_str.count(flag), 1)
                assert_equal(pbs_str.count(flag[:flag.find('=')]), 1)
            for flag in options:
                assert_equal(pbs_str.count(flag), 1)
Ejemplo n.º 6
0
    def _test_add_pbs_flags(self, flags):
        job_generator = JobGenerator(self.queue, self.commands)
        job_generator.add_pbs_flags(flags)

        resources = []
        options = []

        for flag in flags:
            if flag.startswith('-l'):
                resources += [flag[:2] + ' ' + flag[2:]]
            elif flag.startswith('-'):
                options += [(flag[:2] + ' ' + flag[2:]).strip()]

        for pbs in job_generator.pbs_list:
            pbs_str = pbs.__str__()
            for flag in resources:
                assert_equal(pbs_str.count(flag), 1)
                assert_equal(pbs_str.count(flag[:flag.find('=')]), 1)
            for flag in options:
                assert_equal(pbs_str.count(flag), 1)
    def test_generate_pbs4_cpu(self):
        # Should needs four PBS file
        command_params = {'nb_cores_per_command': self.cores}
        job_generator = JobGenerator(self.queue, self.commands, command_params)
        assert_equal(len(job_generator.pbs_list), 4)
        assert_equal([pbs.commands[0] for pbs in job_generator.pbs_list],
                     self.commands)

        # Since queue has no gpus it should not be specified in PBS resource `nodes`
        assert_true('gpus' not in job_generator.pbs_list[0].resources['nodes'])

        # Test modules to load
        # Check if needed modules for this queue are included in the PBS file
        assert_equal(job_generator.pbs_list[0].modules, self.modules)
Ejemplo n.º 8
0
 def test_write_pbs_files(self):
     commands = ["echo 1", "echo 2", "echo 3", "echo 4"]
     command_params = {'nb_cores_per_command': self.cores}
     job_generator = JobGenerator(self.queue, commands, command_params=command_params)
     filenames = job_generator.write_pbs_files(self.testing_dir)
     assert_equal(len(filenames), 4)