Example #1
0
def test_job_tmpl_errors():
    """Test the raising of the appropriate errors"""
    from aiida.schedulers.datastructures import JobTemplate
    from aiida.common.datastructures import CodeRunMode

    scheduler = LsfScheduler()
    job_tmpl = JobTemplate()

    # Raises for missing resources with tot_num_mpiprocs
    with pytest.raises(ValueError):
        scheduler.get_submit_script(job_tmpl)
    job_tmpl.job_resource = scheduler.create_job_resource(tot_num_mpiprocs=2)
    job_tmpl.codes_info = []

    # Raises for missing codes_run_mode
    with pytest.raises(NotImplementedError):
        scheduler.get_submit_script(job_tmpl)
    job_tmpl.codes_run_mode = CodeRunMode.SERIAL

    # Incorrect setups
    job_tmpl.max_wallclock_seconds = 'Not-a-Number'
    with pytest.raises(ValueError):
        scheduler.get_submit_script(job_tmpl)
    job_tmpl.pop('max_wallclock_seconds')

    job_tmpl.max_memory_kb = 'Not-a-Number'
    with pytest.raises(ValueError):
        scheduler.get_submit_script(job_tmpl)
    job_tmpl.pop('max_memory_kb')

    # Verify minimal working parameters don't raise
    scheduler.get_submit_script(job_tmpl)
Example #2
0
    def test_submit_script(self):
        """
        Test the creation of a simple submission script.
        """
        from aiida.schedulers.datastructures import JobTemplate
        from aiida.common.datastructures import CodeInfo, CodeRunMode

        scheduler = LsfScheduler()

        job_tmpl = JobTemplate()
        job_tmpl.shebang = '#!/bin/bash'
        job_tmpl.uuid = str(uuid.uuid4())
        job_tmpl.job_resource = scheduler.create_job_resource(
            tot_num_mpiprocs=2, parallel_env='b681e480bd.cern.ch')
        job_tmpl.max_wallclock_seconds = 24 * 3600
        code_info = CodeInfo()
        code_info.cmdline_params = [
            'mpirun', '-np', '2', 'pw.x', '-npool', '1'
        ]
        code_info.stdin_name = 'aiida.in'
        job_tmpl.codes_info = [code_info]
        job_tmpl.codes_run_mode = CodeRunMode.SERIAL

        submit_script_text = scheduler.get_submit_script(job_tmpl)

        self.assertTrue(submit_script_text.startswith('#!/bin/bash'))

        self.assertTrue('#BSUB -rn' in submit_script_text)
        self.assertTrue('#BSUB -W 24:00' in submit_script_text)
        self.assertTrue('#BSUB -n 2' in submit_script_text)

        self.assertTrue("'mpirun' '-np' '2' 'pw.x' '-npool' '1'" +
                        " < 'aiida.in'" in submit_script_text)