aiidateam / aiida-cp2k

The CP2K plugin for the AiiDA workflow and provenance engine.
https://aiida-cp2k.readthedocs.io/en/latest/
MIT License
23 stars 28 forks source link

Dashboard test failing #71

Closed oschuett closed 4 years ago

oschuett commented 4 years ago

The CP2K Dashboard test is currently failing. Well, actually it times out. Hence, I ran it again locally and pasted the full output below:

========== Running AiiDA-CP2K Tests ==========
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-4.6.9, py-1.8.1, pluggy-0.13.1
rootdir: /opt/aiida-cp2k, inifile: pytest.ini
plugins: cov-2.8.1
collected 28 items

examples/single_calculations/example_dft.py .                            [  3%]
examples/single_calculations/example_dft_atomic_kinds.py .               [  7%]
examples/single_calculations/example_failure.py .                        [ 10%]
examples/single_calculations/example_geopt.py .                          [ 14%]
examples/single_calculations/example_mm.py F                             [ 17%]
examples/single_calculations/example_multiple_force_eval.py .            [ 21%]
examples/single_calculations/example_no_struct.py .                      [ 25%]
examples/single_calculations/example_precision.py .                      [ 28%]
examples/single_calculations/example_restart.py F                        [ 32%]
examples/single_calculations/example_structure_through_file.py .         [ 35%]
examples/workchains/example_base.py .                                    [ 39%]
examples/workchains/example_multistage_Al.py .                           [ 42%]
examples/workchains/example_multistage_h2o-.py .                         [ 46%]
examples/workchains/example_multistage_h2o.py .                          [ 50%]
examples/workchains/example_multistage_h2o_fail.py .                     [ 53%]
examples/workchains/example_multistage_h2o_singlepoint.py .              [ 57%]
examples/workchains/example_multistage_h2o_testfile.py .                 [ 60%]
test/test_input_generator.py .........                                   [ 92%]
test/test_parsers.py .                                                   [ 96%]
test/test_version_agreement.py .                                         [100%]

=================================== FAILURES ===================================
__________________________________ example_mm __________________________________

cp2k_code = <Code: Remote code 'cp2k' on localhost-test, pk: 1, uuid: 862a8bff-a16f-4352-bb80-e4bcca10593f>

    def example_mm(cp2k_code):
        """Run molecular mechanics calculation"""

        print("Testing CP2K ENERGY on H2O (MM) ...")

        # force field
        with open(os.path.join("/tmp", "water.pot"), "w") as f:
            f.write("""BONDS
        H    H       0.000     1.5139
        O    H     450.000     0.9572

        ANGLES
        H    O    H      55.000   104.5200

        DIHEDRALS

        IMPROPER

        NONBONDED
        H      0.000000  -0.046000     0.224500
        O      0.000000  -0.152100     1.768200

        HBOND CUTHB 0.5

        END""")

        water_pot = SinglefileData(file=os.path.join("/tmp", "water.pot"))  # pylint: disable=no-value-for-parameter

        # structure using pdb format, because it also carries topology information
        atoms = ase.build.molecule('H2O')
        atoms.center(vacuum=10.0)
        atoms.write(os.path.join("/tmp", "coords.pdb"), format="proteindatabank")
        coords_pdb = SinglefileData(file=os.path.join("/tmp", "coords.pdb"))

        # parameters
        # based on cp2k/tests/Fist/regtest-1-1/water_1.inp
        parameters = Dict(
            dict={
                'FORCE_EVAL': {
                    'METHOD': 'fist',
                    'MM': {
                        'FORCEFIELD': {
                            'PARM_FILE_NAME': 'water.pot',
                            'PARMTYPE': 'CHM',
                            'CHARGE': [{
                                'ATOM': 'O',
                                'CHARGE': -0.8476
                            }, {
                                'ATOM': 'H',
                                'CHARGE': 0.4238
                            }]
                        },
                        'POISSON': {
                            'EWALD': {
                                'EWALD_TYPE': 'spme',
                                'ALPHA': 0.44,
                                'GMAX': 24,
                                'O_SPLINE': 6
                            }
                        }
                    },
                    'SUBSYS': {
                        'CELL': {
                            'ABC': '%f  %f  %f' % tuple(atoms.cell.diagonal()),
                        },
                        'TOPOLOGY': {
                            'COORD_FILE_NAME': 'coords.pdb',
                            'COORD_FILE_FORMAT': 'PDB',
                        },
                    },
                },
                'GLOBAL': {
                    'CALLGRAPH': 'master',
                    'CALLGRAPH_FILE_NAME': 'runtime'
                }
            })

        # settings
        settings = Dict(dict={'additional_retrieve_list': ["runtime.callgraph"]})

        # Construct process builder
        builder = Cp2kCalculation.get_builder()
        builder.parameters = parameters
        builder.settings = settings
        builder.code = cp2k_code
        builder.file = {
            'water_pot': water_pot,
            'coords_pdb': coords_pdb,
        }
        builder.metadata.options.resources = {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 1,
        }
        builder.metadata.options.max_wallclock_seconds = 1 * 3 * 60

        print("Submitted calculation...")
        calc = run(builder)

        # check warnings
>       assert calc['output_parameters'].dict.nwarnings == 0
E       assert 2 == 0
E        +  where 2 = <aiida.orm.utils.managers.AttributeManager object at 0x7f75e3a29080>.nwarnings
E        +    where <aiida.orm.utils.managers.AttributeManager object at 0x7f75e3a29080> = <Dict: uuid: 5c7bc6f2-91f1-483c-aa1b-5740bb5ebb9d (pk: 39)>.dict

examples/single_calculations/example_mm.py:125: AssertionError
----------------------------- Captured stdout call -----------------------------
Testing CP2K ENERGY on H2O (MM) ...
Submitted calculation...
_______________________________ example_restart ________________________________

cp2k_code = <Code: Remote code 'cp2k' on localhost-test, pk: 1, uuid: 862a8bff-a16f-4352-bb80-e4bcca10593f>

    def example_restart(cp2k_code):
        """Test CP2K restart"""

        print("Testing CP2K restart...")

        pwd = os.path.dirname(os.path.realpath(__file__))

        # structure
        atoms1 = ase.build.molecule('H2O')
        atoms1.center(vacuum=2.0)
        structure1 = StructureData(ase=atoms1)

        # basis set
        basis_file = SinglefileData(file=os.path.join(pwd, "..", "files", "BASIS_MOLOPT"))

        # pseudopotentials
        pseudo_file = SinglefileData(file=os.path.join(pwd, "..", "files", "GTH_POTENTIALS"))

        # CP2K input
        params1 = Dict(
            dict={
                'GLOBAL': {
                    'RUN_TYPE': 'GEO_OPT',
                    'WALLTIME': '00:00:10',  # too short
                },
                'MOTION': {
                    'GEO_OPT': {
                        'MAX_FORCE': 1e-20,  # impossible to reach
                        'MAX_ITER': 100000  # run forever
                    },
                },
                'FORCE_EVAL': {
                    'METHOD': 'Quickstep',
                    'DFT': {
                        'BASIS_SET_FILE_NAME': 'BASIS_MOLOPT',
                        'POTENTIAL_FILE_NAME': 'GTH_POTENTIALS',
                        'QS': {
                            'EPS_DEFAULT': 1.0e-12,
                            'WF_INTERPOLATION': 'ps',
                            'EXTRAPOLATION_ORDER': 3,
                        },
                        'MGRID': {
                            'NGRIDS': 4,
                            'CUTOFF': 280,
                            'REL_CUTOFF': 30,
                        },
                        'XC': {
                            'XC_FUNCTIONAL': {
                                '_': 'LDA',
                            },
                        },
                        'POISSON': {
                            'PERIODIC': 'none',
                            'PSOLVER': 'MT',
                        },
                        'SCF': {
                            'PRINT': {
                                'RESTART': {
                                    '_': 'ON'
                                }
                            }
                        },
                    },
                    'SUBSYS': {
                        'KIND': [
                            {
                                '_': 'O',
                                'BASIS_SET': 'DZVP-MOLOPT-SR-GTH',
                                'POTENTIAL': 'GTH-LDA-q6'
                            },
                            {
                                '_': 'H',
                                'BASIS_SET': 'DZVP-MOLOPT-SR-GTH',
                                'POTENTIAL': 'GTH-LDA-q1'
                            },
                        ],
                    },
                }
            })

        # ------------------------------------------------------------------------------
        # Construct process builder
        builder = Cp2kCalculation.get_builder()

        # Set up the first calculation
        builder.structure = structure1
        builder.parameters = params1
        builder.code = cp2k_code
        builder.file = {
            'basis': basis_file,
            'pseudo': pseudo_file,
        }
        builder.metadata.options.resources = {
            "num_machines": 1,
            "num_mpiprocs_per_machine": 1,
        }
        builder.metadata.options.max_wallclock_seconds = 1 * 2 * 60

        print("submitted calculation 1:")
        calc1 = run(builder)

        # check walltime exceeded
        assert calc1['output_parameters'].dict.exceeded_walltime is True
        assert calc1['output_parameters'].dict.energy is not None
        assert 'output_structure' in calc1
        print("OK, walltime exceeded as expected")

        # ------------------------------------------------------------------------------
        # Set up and start the second calculation

        # parameters
        params2 = deepcopy(params1.get_dict())
        del params2['GLOBAL']['WALLTIME']
        del params2['MOTION']['GEO_OPT']['MAX_FORCE']
        restart_wfn_fn = './parent_calc/aiida-RESTART.wfn'
        params2['FORCE_EVAL']['DFT']['RESTART_FILE_NAME'] = restart_wfn_fn
        params2['FORCE_EVAL']['DFT']['SCF']['SCF_GUESS'] = 'RESTART'
        params2['EXT_RESTART'] = {'RESTART_FILE_NAME': './parent_calc/aiida-1.restart'}
        params2 = Dict(dict=params2)

        # structure
        atoms2 = ase.build.molecule('H2O')
        atoms2.center(vacuum=2.0)
        atoms2.positions *= 0.0  # place all atoms at origin -> nuclear fusion :-)
        structure2 = StructureData(ase=atoms2)

        # Update the process builder.
        builder.structure = structure2
        builder.parameters = params2
        builder.parent_calc_folder = calc1['remote_folder']

        print("submitted calculation 2")
        calc2 = run(builder)

        # check energy
        expected_energy = -17.1566455959
        if abs(calc2['output_parameters'].dict.energy - expected_energy) < 1e-10:
            print("OK, energy has the expected value")

        # if restart wfn is not found it will create a warning
>       assert calc2['output_parameters'].dict.nwarnings == 1
E       assert 3 == 1
E        +  where 3 = <aiida.orm.utils.managers.AttributeManager object at 0x7f75e396a6a0>.nwarnings
E        +    where <aiida.orm.utils.managers.AttributeManager object at 0x7f75e396a6a0> = <Dict: uuid: 45d1f01a-5f74-4f68-8a75-a2244b6f637b (pk: 78)>.dict

examples/single_calculations/example_restart.py:169: AssertionError
----------------------------- Captured stdout call -----------------------------
Testing CP2K restart...
submitted calculation 1:
OK, walltime exceeded as expected
submitted calculation 2
=============================== warnings summary ===============================
examples/workchains/example_multistage_Al.py::example_multistage_al
examples/workchains/example_multistage_Al.py::example_multistage_al
  /usr/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
    return f(*args, **kwds)

/usr/local/lib/python3.6/dist-packages/_pytest/cacheprovider.py:127
  /usr/local/lib/python3.6/dist-packages/_pytest/cacheprovider.py:127: PytestCacheWarning: could not create cache path /opt/aiida-cp2k/.pytest_cache/v/cache/stepwise
    self.warn("could not create cache path {path}", path=path)

/usr/local/lib/python3.6/dist-packages/_pytest/cacheprovider.py:127
  /usr/local/lib/python3.6/dist-packages/_pytest/cacheprovider.py:127: PytestCacheWarning: could not create cache path /opt/aiida-cp2k/.pytest_cache/v/cache/nodeids
    self.warn("could not create cache path {path}", path=path)

/usr/local/lib/python3.6/dist-packages/_pytest/cacheprovider.py:127
  /usr/local/lib/python3.6/dist-packages/_pytest/cacheprovider.py:127: PytestCacheWarning: could not create cache path /opt/aiida-cp2k/.pytest_cache/v/cache/lastfailed
    self.warn("could not create cache path {path}", path=path)

-- Docs: https://docs.pytest.org/en/latest/warnings.html
============== 2 failed, 26 passed, 5 warnings in 1071.07 seconds ==============
yakutovicha commented 4 years ago

Hi @oschuett, thanks for the report.

Before I start fixing the problems could you please provide me with the link to the failing dashboard tests? It appears to me that the link you've posted above does not contain any reference to the logs. Also, does the fact that the tests timed-out mean that we should reduce the number of tests?

In the output you've posted I see two problems with the number of warnings. Do you think they are related to the recent CP2K update? Our tests went fine, so I am a bit puzzled. I assume that locally you have cp2k-7.1, right?

oschuett commented 4 years ago

Yes, I'm also a bit puzzled. In the CI it get to example_multistage_h2o_singlepoint.py and then stalls until the deadline of 3 hours is reached. Unfortunately, the output is not very helpful. Is there maybe any way I could enable more debugging output?

I'm running the test using the CP2K master branch. However, I think the likely cause is https://github.com/aiidateam/aiida-cp2k/commit/a049931946992a5332edc7efd6b9d7e78b42156e.

oschuett commented 4 years ago

I was wondering about these lines:

assert calc['output_parameters'].dict.nwarnings == 0
assert calc2['output_parameters'].dict.nwarnings == 1

In CP2K we are rather liberal about adding or removing warnings. So, this is probably not a good properties to assert on.

yakutovicha commented 4 years ago

In CP2K we are rather liberal about adding or removing warnings. So, this is probably not a good properties to assert on.

Good to know, I will then remove it :)

oschuett commented 4 years ago

Any news on this?