Commit c7cb86e0 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Various fixes related to new parsers. Exceptions for some keys in normalized test.

parent 50ce6c5c
Subproject commit 3b199d1f17f9cdf94e08fc5a3b46e2895147463d
Subproject commit b94cbfc9db3bc9ab720690a545dda6543aa8bd40
Subproject commit 7505b8b16035ec22025875bb6dfbe22f812ddcdd
Subproject commit 68b89cde86bc5f7ef7631d5e7abfa365664060d1
Subproject commit 4802d6d8ab942d2431a39d37e2ffefaf5c6ef478
Subproject commit 3811ced85fb7d68ca579d5ca8d93e800f48c53a5
Subproject commit 190b1dc12fe09a9ab1ad08d317fa08205c6f75ae
Subproject commit 039ed6cb532b26926f8e0d7dc2027403e965e67c
Subproject commit 0e0c20ab4adea61ad31f8a7e96876434008fb490
Subproject commit d8ee02926a9f37317c880ba3caa31f5140e7730e
......@@ -98,6 +98,8 @@ class CalcWithMetadata():
# temporary reference to the backend after successful processing
self.backend = None
self.parser_name = None
self.update(**kwargs)
def to_dict(self):
......
......@@ -107,6 +107,14 @@ class AbstractParserBackend(metaclass=ABCMeta):
""" Opens a new non overlapping section. """
pass
@abstractmethod
def setSectionInfo(self, metaName, gIndex, references):
"""
Sets info values of an open section references should be a dictionary with the
gIndexes of the root sections this section refers to.
"""
pass
@abstractmethod
def closeNonOverlappingSection(self, metaName):
"""
......
......@@ -305,6 +305,7 @@ class Calc(Proc):
calc_with_metadata = CalcWithMetadata(**self.metadata)
calc_with_metadata.apply_domain_metadata(self._parser_backend)
calc_with_metadata.parser_name = self.parser
calc_with_metadata.processed = True
# persist the calc metadata
......
......@@ -25,6 +25,29 @@ from tests.test_parsing import parsed_faulty_unknown_matid_example # pylint: di
from tests.utils import assert_log
symmetry_keys = ['spacegroup', 'spacegroup_symbol', 'crystal_system']
calc_metadata_keys = [
'code_name', 'code_version', 'basis_set', 'xc_functional', 'system'] + symmetry_keys
parser_exceptions = {
'parsers/wien2k': ['xc_functional'],
'parsers/nwchem': symmetry_keys,
'parsers/bigdft': symmetry_keys,
'parsers/gaussian': symmetry_keys,
'parsers/abinit': ['system'] + symmetry_keys,
'parsers/dl-poly': ['basis_set', 'xc_functional', 'system'] + symmetry_keys,
'parsers/lib-atoms': ['basis_set', 'xc_functional'],
'parsers/orca': symmetry_keys,
'parsers/octopus': symmetry_keys,
'parsers/phonopy': ['basis_set', 'xc_functional'],
'parsers/gpaw2': symmetry_keys,
'parsers/gamess': ['system'] + symmetry_keys,
'parsers/gulp': ['xc_functional', 'system'] + symmetry_keys,
'parsers/turbomole': symmetry_keys,
'parsers/elastic': ['basis_set', 'xc_functional', 'system'] + symmetry_keys
}
def run_normalize(backend: LocalBackend) -> LocalBackend:
status, _ = backend.status
......@@ -68,12 +91,11 @@ def assert_normalized(backend: LocalBackend):
assert len(metadata.atoms) > 0
assert metadata.spacegroup is not None
assert metadata.code_name != config.services.unavailable_value
assert metadata.code_version != config.services.unavailable_value
assert metadata.basis_set != config.services.unavailable_value
assert metadata.xc_functional != config.services.unavailable_value
assert metadata.system != config.services.unavailable_value
# TODO check symmetry where we know it should be there
exceptions = parser_exceptions.get(backend.get_value('parser_name'), [])
for key in calc_metadata_keys:
if key not in exceptions:
assert getattr(metadata, key) != config.services.unavailable_value
def test_normalizer(normalized_example: LocalBackend):
......
......@@ -52,14 +52,21 @@ parser_examples = [
('parsers/gpaw', 'tests/data/parsers/gpaw/Fe2.gpw'),
('parsers/gpaw2', 'tests/data/parsers/gpaw2/H2_lcao.gpw2'),
('parsers/atk', 'tests/data/parsers/atk/Si2.nc'),
# ('parsers/gulp', 'tests/data/parsers/gulp/example6.got'), # Issue with section_method
# ('parsers/siesta', 'tests/data/parsers/siesta/Fe/out'), # Issue with dir.
('parsers/gulp', 'tests/data/parsers/gulp/example6.got'),
('parsers/siesta', 'tests/data/parsers/siesta/Fe/out'),
('parsers/elk', 'tests/data/parsers/elk/Al/INFO.OUT'),
# ('parsers/elastic', 'tests/data/parsers/elastic/2nd/INFO_ElaStic') # 70Mb file 2big4git
# ('parsers/turbomole', 'tests/data/parsers/turbomole/acrolein.out') # Issue with backend
('parsers/elastic', 'dependencies/parsers/elastic/test/examples/2nd/INFO_ElaStic'), # 70Mb file 2big4git
('parsers/turbomole', 'tests/data/parsers/turbomole/acrolein.out'),
('parsers/gamess', 'tests/data/parsers/gamess/exam01.out')
]
# We need to remove some cases with external mainfiles, which might not exist
# in all testing environments (e.g. in the nomad docker image)
for parser, mainfile in parser_examples:
fixed_parser_examples = []
if os.path.exists(mainfile) or mainfile.startswith('tests'):
fixed_parser_examples.append((parser, mainfile))
faulty_unknown_one_d_matid_example = [
('parsers/template', 'tests/data/normalizers/no_sim_cell_boolean_positions.json')
]
......@@ -251,7 +258,7 @@ def assert_parser_result(backend):
def run_parser(parser_name, mainfile):
parser = parser_dict[parser_name]
result = parser.run(mainfile, logger=utils.get_logger(__name__))
return add_calculation_info(result)
return add_calculation_info(result, parser_name=parser_name)
@pytest.fixture
......@@ -280,13 +287,14 @@ def parsed_example(request) -> LocalBackend:
return result
def add_calculation_info(backend: LocalBackend) -> LocalBackend:
def add_calculation_info(backend: LocalBackend, **kwargs) -> LocalBackend:
backend.openNonOverlappingSection('section_calculation_info')
backend.addValue('upload_id', 'test_upload_id')
backend.addValue('calc_id', 'test_calc_id')
backend.addValue('calc_hash', 'test_calc_hash')
backend.addValue('main_file', 'test/mainfile.txt')
backend.addValue('parser_name', 'testParser')
for key, value in kwargs.items():
backend.addValue(key, value)
backend.closeNonOverlappingSection('section_calculation_info')
return backend
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment