Exemple #1
0
def test_write_custodian_spec_yaml_format_with_handler_neb(tmpdir):
    import pathlib
    from aiida_cusp.utils.custodian import CustodianSettings
    outfile = pathlib.Path(tmpdir) / 'custodian_spec_file.yaml'
    # setup custom inputs including handler: use default settings for
    # vasp, custodian and the chosen handler
    vasp_cmd = ['mpirun', '-np', '4', '/path/to/vasp']
    stdout = 'stdout.txt'
    stderr = 'stderr.txt'
    handlers = ['VaspErrorHandler']  # use default settings for handler
    settings = {}  # use the default vasp / custodian settings
    cstdn_settings = CustodianSettings(vasp_cmd, stdout, stderr, is_neb=True,
                                       handlers=handlers, settings=settings)
    assert outfile.is_file() is False  # check file is not already there
    cstdn_settings.write_custodian_spec(outfile)
    assert outfile.is_file() is True  # check file was written
    expected_spec_file_content = "\n".join([
        "custodian_params:",
        "  checkpoint: false",
        "  gzipped_output: false",
        "  max_errors: 10",
        "  max_errors_per_job: null",
        "  monitor_freq: 30",
        "  polling_time_step: 10",
        "  scratch_dir: null",
        "  skip_over_errors: false",
        "  terminate_func: null",
        "  terminate_on_nonzero_returncode: false",
        "handlers:",
        "- hdlr: custodian.vasp.handlers.VaspErrorHandler",
        "  params:",
        "    errors_subset_to_catch: null",
        "    natoms_large_cell: 100",
        "    output_filename: aiida.out",
        "jobs:",
        "- jb: custodian.vasp.jobs.VaspNEBJob",
        "  params:",
        "    $vasp_cmd:",
        "    - mpirun",
        "    - -np",
        "    - '4'",
        "    - /path/to/vasp",
        "    auto_continue: false",
        "    auto_gamma: false",
        "    auto_npar: false",
        "    backup: true",
        "    final: true",
        "    gamma_vasp_cmd: null",
        "    half_kpts: false",
        "    output_file: stdout.txt",
        "    settings_override: null",
        "    stderr_file: stderr.txt",
        "    suffix: ''",
    ]) + "\n"
    with open(outfile, 'r') as custodian_spec_file:
        custodian_spec_file_content = custodian_spec_file.read()
    assert custodian_spec_file_content == expected_spec_file_content
Exemple #2
0
def test_write_custodian_spec_raises_on_wrong_filetype(tmpdir):
    import pathlib
    from aiida_cusp.utils.custodian import CustodianSettings
    from aiida_cusp.utils.exceptions import CustodianSettingsError
    outfile = pathlib.Path(tmpdir) / 'custodian_spec_file.not_yaml_suffix'
    # setup custom inputs including handler: use default settings for
    # vasp, custodian and the chosen handler
    vasp_cmd = ['vasp']
    stdout = 'stdout.txt'
    stderr = 'stderr.txt'
    handlers = []
    settings = {}  # use the default vasp / custodian settings
    cstdn_settings = CustodianSettings(vasp_cmd, stdout, stderr, is_neb=False,
                                       handlers=handlers, settings=settings)
    with pytest.raises(CustodianSettingsError) as exception:
        cstdn_settings.write_custodian_spec(outfile)
    assert str(exception.value).startswith('Given path') is True