Commit 7fba3f38 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Added exciting parser.

parent 3f2c409a
......@@ -57,6 +57,16 @@
"-sv", "tests/test_normalizing.py"
]
},
{
"name": "Python: tests/test_parsing.py::test_exciting_parser",
"type": "python",
"request": "launch",
"cwd": "${workspaceFolder}",
"program": "${workspaceFolder}/.pyenv/bin/pytest",
"args": [
"-sv", "tests/test_parsing.py::test_exciting_parser"
]
},
{
"name": "Python: tests/test_search.py",
"type": "python",
......
......@@ -124,7 +124,7 @@ class PythonGit():
_logger.info('pull %s for %s' % (self.git_commit, self.name))
origin = git.remote('origin')
origin.pull(self.git_commit)
origin.pull(self.git_commit, depth=1)
if os.path.exists('requirements.txt'):
_logger.info('install requirements.txt for %s' % self.name)
......@@ -160,10 +160,10 @@ dependencies = [
name='parsers/vasp',
git_url='https://gitlab.mpcdf.mpg.de/nomad-lab/parser-vasp.git',
git_commit='nomad-xt'),
# PythonGit(
# name='parsers/exciting',
# git_url='https://gitlab.mpcdf.mpg.de/nomad-lab/parser-exciting.git',
# git_commit='master'),
PythonGit(
name='parsers/exciting',
git_url='https://gitlab.mpcdf.mpg.de/nomad-lab/parser-exciting.git',
git_commit='nomad-xt'),
PythonGit(
name='normalizers/stats',
git_url='https://gitlab.mpcdf.mpg.de/nomad-lab/normalizer-stats.git',
......
......@@ -364,8 +364,17 @@ class LocalBackend(LegacyParserBackend):
self._open_context: Tuple[str, int] = None
self._context_section = None
def finishedParsingSession(self, parserStatus, parserErrors, **kwargs):
self._delegate.finishedParsingSession(parserStatus, parserErrors, **kwargs)
self._unknown_attributes = {}
def __getattr__(self, name):
""" Support for unimplemented and unexpected methods. """
if self._unknown_attributes.get(name) is None:
logger.debug('Access of unexpected backend attribute/method', attribute=name)
self._unknown_attributes[name] = name
return lambda *args, **kwargs: None
def finishedParsingSession(self, parserStatus, parserErrors, *args, **kwargs):
self._delegate.finishedParsingSession(parserStatus, parserErrors, *args, **kwargs)
self._status = parserStatus
self._errors = parserErrors
......@@ -613,9 +622,13 @@ class Parser():
module = importlib.import_module('.'.join(module_name))
Parser = getattr(module, parser_class)
parser = Parser(backend=create_backend, debug=True)
parser.parse(mainfile)
backend = parser.parse(mainfile)
# TODO we need a homogeneous interface to parsers, but we dont have it right now
# thats a hack to distringuish between ParserInterface parser and simple_parser
if backend is None or not hasattr(backend, 'status'):
backend = parser.parser_context.super_backend
backend = parser.parser_context.super_backend
return backend
def __repr__(self):
......@@ -634,12 +647,15 @@ parsers = [
r'?\s*<i name="program" type="string">\s*vasp\s*</i>'
r'?')
),
# Parser(
# python_git=dependencies['parsers/exciting'],
# parser_class_name='vaspparser.VASPParser',
# main_file_re=r'^.*\.todo$',
# main_contents_re=(r'^todo')
# ),
Parser(
python_git=dependencies['parsers/exciting'],
parser_class_name='parser_exciting.ExcitingParser',
main_file_re=r'^.*/INFO\.OUT?',
main_contents_re=(
r'^\s*=================================================+\s*'
r'\s*\|\s*EXCITING\s+\S+\s+started\s*='
r'\s*\|\s*version hash id:\s*\S*\s*=')
),
]
""" Instanciation and constructor based config of all parsers. """
......
......@@ -191,6 +191,24 @@ def test_vasp_parser(parsed_vasp_example: LocalBackend):
assert errors is None or len(errors) == 0
exciting_examples = [
'.dependencies/parsers/exciting/test/examples/Ag/INFO.OUT',
'.dependencies/parsers/exciting/test/examples/lithium/INFO.OUT',
'.dependencies/parsers/exciting/test/examples/GW/INFO.OUT',
]
@pytest.mark.parametrize('example_mainfile', exciting_examples)
def test_exciting_parser(example_mainfile):
exciting_parser = parser_dict['parsers/exciting']
parsed_exciting_example = exciting_parser.run(example_mainfile)
status, errors = parsed_exciting_example.status
assert status == 'ParseSuccess'
assert errors is None or len(errors) == 0
def test_match():
vasp_parser = parser_dict['parsers/vasp']
directory = './data/examples_vasp_6'
......
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