Exemplo n.º 1
0
def test_create_job_resource():
    """
    Test to verify that script fails in the following cases:
        * if we specify only num_machines
        * if tot_num_mpiprocs is not an int (and can't be casted to one)
        * if parallel_env is not a str
    """
    from aiida.schedulers.datastructures import JobTemplate

    scheduler = LsfScheduler()
    job_tmpl = JobTemplate()

    with pytest.raises(TypeError):
        job_tmpl.job_resource = scheduler.create_job_resource(
            tot_num_mpiprocs='Not-a-Number')

    with pytest.raises(TypeError):
        job_tmpl.job_resource = scheduler.create_job_resource(
            num_machines=1,
            num_mpiprocs_per_machine=1,
        )

    with pytest.raises(TypeError):
        job_tmpl.job_resource = scheduler.create_job_resource(
            tot_num_mpiprocs=2,
            parallel_env=0,
        )
Exemplo n.º 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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
    def test_submit_script_with_num_machines(self):
        """
        Test to verify that script fails if we specify only
        num_machines.
        """
        from aiida.schedulers.datastructures import JobTemplate

        scheduler = LsfScheduler()
        job_tmpl = JobTemplate()
        with self.assertRaises(TypeError):
            job_tmpl.job_resource = scheduler.create_job_resource(
                num_machines=1,
                num_mpiprocs_per_machine=1,
            )