Commit 16f7a7f6 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Parser optimizations.

parent 2ef508e9
......@@ -13,9 +13,9 @@ import wien2kparser.wien2k_parser_in1c as wien2k_parser_in1c
import wien2kparser.wien2k_parser_in2c as wien2k_parser_in2c
import wien2kparser.wien2k_parser_in1 as wien2k_parser_in1
import wien2kparser.wien2k_parser_in2 as wien2k_parser_in2
import wien2kparser.setup_paths as setup_paths
import logging as _logging
from nomad.parsing.legacy import CoESimpleMatcherParser
################################################################
# This is the parser for the main output file (.scf) of WIEN2k.
......@@ -266,47 +266,26 @@ mainFileDescription = SM(
])
# which values to cache or forward (mapping meta name -> CachingLevel)
class Wien2kParser(CoESimpleMatcherParser):
cachingLevelForMetaName = {
def metainfo_env(self):
from .metainfo import m_env
return m_env
"XC_functional_name": CachingLevel.ForwardAndCache,
"energy_total": CachingLevel.ForwardAndCache
def create_super_context(self):
return Wien2kContext()
}
def create_simple_matcher(self):
return mainFileDescription
# loading metadata from nomad-meta-info/meta_info/nomad_meta_info/fhi_aims.nomadmetainfo.json
def create_parser_description(self):
return {
"name": "Wien2k",
"version": "1.0"
}
parserInfo = {
"name": "Wien2k",
"version": "1.0"
}
class Wien2kParser():
""" A proper class envolop for running this parser from within python. """
def __init__(self, backend, **kwargs):
self.backend_factory = backend
def parse(self, mainfile):
from unittest.mock import patch
_logging.getLogger('nomadcore').setLevel(_logging.WARNING)
backend = self.backend_factory("wien2k.nomadmetainfo.json")
with patch.object(sys, 'argv', ['<exe>', '--uri', 'nmd://uri', mainfile]):
mainFunction(
mainFileDescription,
None,
parserInfo,
cachingLevelForMetaName = cachingLevelForMetaName,
superContext=Wien2kContext(),
superBackend=backend)
return backend
if __name__ == "__main__":
import metainfo
metaInfoPath = os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(metainfo.__file__)), "wien2k.nomadmetainfo.json"))
metaInfoEnv, warnings = loadJsonFile(filePath = metaInfoPath, dependencyLoader = None, extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
superContext = Wien2kContext()
mainFunction(mainFileDescription, metaInfoEnv, parserInfo, superContext = superContext)
def create_caching_levels(self):
return {
"XC_functional_name": CachingLevel.ForwardAndCache,
"energy_total": CachingLevel.ForwardAndCache
}
# Copyright 2016-2018 Daria Tomecka, Fawzi Mohamed
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys, os, os.path
baseDir = os.path.dirname(os.path.abspath(__file__))
commonDir = os.path.normpath(os.path.join(baseDir,"../../../../python-common/common/python"))
if not commonDir in sys.path:
sys.path.insert(0, commonDir)
from builtins import object
import wien2kparser.setup_paths as setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import wien2kparser.setup_paths as setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import wien2kparser.setup_paths as setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import wien2kparser.setup_paths as setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import wien2kparser.setup_paths as setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
from builtins import object
import wien2kparser.setup_paths as setup_paths
from nomadcore.simple_parser import mainFunction, CachingLevel
from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.local_meta_info import loadJsonFile, InfoKindEl
......
Markdown is supported
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