Esempio n. 1
0
    def prepare(self, commands, environs=None, pre_environ=None, **gen_opts):
        environs = environs or []
        if self.num_tasks <= 0:
            num_tasks_per_node = self.num_tasks_per_node or 1
            min_num_tasks = (-self.num_tasks if self.num_tasks else
                             num_tasks_per_node)

            try:
                guessed_num_tasks = self.guess_num_tasks()
            except NotImplementedError as e:
                raise JobError('flexible node allocation is not supported by '
                               'this backend') from e

            if guessed_num_tasks < min_num_tasks:
                raise JobError(
                    'could not satisfy the minimum task requirement: '
                    'required %s, found %s' %
                    (min_num_tasks, guessed_num_tasks))

            self.num_tasks = guessed_num_tasks
            getlogger().debug('flex_alloc_nodes: setting num_tasks to %s' %
                              self.num_tasks)

        with shell.generate_script(self.script_filename,
                                   **gen_opts) as builder:
            builder.write_prolog(self.scheduler.emit_preamble(self))
            for c in pre_environ:
                builder.write_body(c)
            builder.write(env.emit_load_commands(*environs))
            for c in commands:
                builder.write_body(c)
Esempio n. 2
0
 def test_emit_load_commands(self):
     self.setup_modules_system()
     rt = runtime()
     expected_commands = [
         rt.modules_system.emit_load_commands('testmod_foo')[0],
         'export _var0=val1',
         'export _var2=$_var0',
         'export _var3=${_var1}',
     ]
     assert expected_commands == env.emit_load_commands(self.environ)
Esempio n. 3
0
    def test_emit_load_commands_with_confict(self):
        self.setup_modules_system()

        # Load a conflicting module
        self.modules_system.load_module('testmod_bar')
        rt = runtime()
        expected_commands = [
            rt.modules_system.emit_unload_commands('testmod_bar')[0],
            rt.modules_system.emit_load_commands('testmod_foo')[0],
            'export _var0=val1',
            'export _var2=$_var0',
            'export _var3=${_var1}',
        ]
        assert expected_commands == env.emit_load_commands(self.environ)