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

Removed smart parser dep on old metainfo.

parent cf843eda
...@@ -26,7 +26,12 @@ import MDAnalysis.core.universe as mda_u ...@@ -26,7 +26,12 @@ import MDAnalysis.core.universe as mda_u
import MDAnalysis.coordinates as mda_c import MDAnalysis.coordinates as mda_c
import panedr import panedr
import parmed as pmd import parmed as pmd
import pymolfile as pym # this might not be available on all development systems, we still want to pass the import
# eventhough not all code will work
try:
import pymolfile as pym
except:
pass
from nomadcore.md_data_access import GromosTopoObjects as gto from nomadcore.md_data_access import GromosTopoObjects as gto
from nomadcore.md_data_access.GromosTopoObjects import get_zipType, get_fileExtensions from nomadcore.md_data_access.GromosTopoObjects import get_zipType, get_fileExtensions
import io import io
......
...@@ -7,16 +7,6 @@ import re ...@@ -7,16 +7,6 @@ import re
import ast import ast
from collections import namedtuple from collections import namedtuple
import metainfo
COMMON_META_INFO_PATH = os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(metainfo.__file__)),
"common.nomadmetainfo.json"))
PUBLIC_META_INFO_PATH = os.path.normpath(os.path.join(
os.path.dirname(os.path.abspath(metainfo.__file__)),
"public.nomadmetainfo.json"))
NOTEXCEPT = re.compile(r'[a-cf-zA-CF-Z!\?,{}\[\]]') NOTEXCEPT = re.compile(r'[a-cf-zA-CF-Z!\?,{}\[\]]')
def is_number(val): def is_number(val):
...@@ -756,25 +746,8 @@ class JsonMetaInfo(object): ...@@ -756,25 +746,8 @@ class JsonMetaInfo(object):
Loads data and extracts values of items Loads data and extracts values of items
with specified superNames with specified superNames
""" """
def __init__(self, *args): def __init__(self, metainfo_env):
self.jsonList = None self.jsonList = metainfo_env.to_legacy_dict(metainfo_env.packages)['metaInfos']
for filepath in args:
try:
with open(filepath, encoding="utf-8") as f:
jsonDict = json.load(f)
except:
logging.exception("Error while loading file %s" % filepath)
raise
typeStr = jsonDict.get("type","nomad_meta_info_1_0")
typeRe = re.compile(r"nomad_meta_info_(?P<major>[0-9]+)_(?P<minor>[0-9]+)$")
m = typeRe.match(typeStr)
if not m:
raise Exception("unexpected type '%s', expected nomad_meta_info_1_0" % typeStr)
newJsonList = jsonDict.get("metaInfos",[])
if self.jsonList:
self.jsonList = self.jsonList + newJsonList
else:
self.jsonList = newJsonList
def attributes(self, sectionname): def attributes(self, sectionname):
attributes = {} attributes = {}
...@@ -889,7 +862,8 @@ if __name__ == "__main__": ...@@ -889,7 +862,8 @@ if __name__ == "__main__":
'section_repository_info' 'section_repository_info'
]} ]}
jsonmetadata = JsonMetaInfo(COMMON_META_INFO_PATH, PUBLIC_META_INFO_PATH) from nomad.datamodel.metainfo import m_env
jsonmetadata = JsonMetaInfo(m_env)
updateDict = { updateDict = {
'startSection' : [['section_topology']], 'startSection' : [['section_topology']],
......
...@@ -3,7 +3,6 @@ from nomadcore.unit_conversion.unit_conversion import convert_unit ...@@ -3,7 +3,6 @@ from nomadcore.unit_conversion.unit_conversion import convert_unit
from nomadcore.caching_backend import CachingLevel from nomadcore.caching_backend import CachingLevel
from nomadcore.simple_parser import mainFunction from nomadcore.simple_parser import mainFunction
from nomadcore.simple_parser import SimpleMatcher as SM from nomadcore.simple_parser import SimpleMatcher as SM
from nomadcore.metainfo_storage.MetaInfoStorage import COMMON_META_INFO_PATH, PUBLIC_META_INFO_PATH
from nomadcore.metainfo_storage import MetaInfoStorage as mStore from nomadcore.metainfo_storage import MetaInfoStorage as mStore
from nomadcore.metainfo_storage.MetaInfoStorage import strcleaner, strisinstance, literal_eval from nomadcore.metainfo_storage.MetaInfoStorage import strcleaner, strisinstance, literal_eval
from nomadcore.smart_parser.SmartParserDictionary import getDict_MetaStrInDict, getList_MetaStrInDict, get_unitDict from nomadcore.smart_parser.SmartParserDictionary import getDict_MetaStrInDict, getList_MetaStrInDict, get_unitDict
...@@ -14,6 +13,8 @@ import os ...@@ -14,6 +13,8 @@ import os
import re import re
import io import io
from nomad.metainfo.legacy import LegacyMetainfoEnvironment
@contextmanager @contextmanager
def open_section(parser, name): def open_section(parser, name):
gid = parser.openSection(name) gid = parser.openSection(name)
...@@ -45,10 +46,7 @@ def conv_float(n, default=None): ...@@ -45,10 +46,7 @@ def conv_float(n, default=None):
return None return None
def get_metaInfo(self): def get_metaInfo(self):
metaInfoEnv, warnings = loadJsonFile(filePath=self.META_INFO_PATH, metaInfoEnv = LegacyMetainfoEnvironment.from_legacy_package_path(self.META_INFO_PATH)
dependencyLoader=None,
extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
uri=None)
metaInfoEnv = set_section_metaInfoEnv(self.PARSERTAG, metaInfoEnv, self.sectionDict) metaInfoEnv = set_section_metaInfoEnv(self.PARSERTAG, metaInfoEnv, self.sectionDict)
metaInfoEnv = setDict_metaInfoEnv(metaInfoEnv, self.metaDicts) metaInfoEnv = setDict_metaInfoEnv(metaInfoEnv, self.metaDicts)
return metaInfoEnv return metaInfoEnv
...@@ -170,11 +168,7 @@ class ParserBase(object): ...@@ -170,11 +168,7 @@ class ParserBase(object):
]} ]}
self.META_INFO_PATH = metainfopath self.META_INFO_PATH = metainfopath
PARSER_INFO_DEFAULT = parserinfodef PARSER_INFO_DEFAULT = parserinfodef
jsonmetadata = mStore.JsonMetaInfo( jsonmetadata = mStore.JsonMetaInfo(LegacyMetainfoEnvironment.from_legacy_package_path(metainfopath))
COMMON_META_INFO_PATH,
PUBLIC_META_INFO_PATH,
self.META_INFO_PATH
)
self.metaStorage.build(jsonmetadata, 'section_run', exclude_dict) self.metaStorage.build(jsonmetadata, 'section_run', exclude_dict)
self.metaStorageRestrict.build(jsonmetadata, 'section_restricted_uri', exclude_dict) self.metaStorageRestrict.build(jsonmetadata, 'section_restricted_uri', exclude_dict)
self.re_program_name = re_program_name self.re_program_name = re_program_name
......
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