Commit e23633c0 authored by Speckhard, Daniel (dansp)'s avatar Speckhard, Daniel (dansp)

merged changes.

parents 85bf33ef 22024d2b
...@@ -131,6 +131,8 @@ class LocalBackend(object): ...@@ -131,6 +131,8 @@ class LocalBackend(object):
# Check the type # Check the type
dtype_str = dataManager.metaInfo.dtypeStr dtype_str = dataManager.metaInfo.dtypeStr
if dtype_str is None:
raise TypeError("The metainfo '{}' does not define a dtypeStr".format(metaName))
single_types = self.single_value_type_for_metainfo_type(dtype_str) single_types = self.single_value_type_for_metainfo_type(dtype_str)
actual_numpy_type = type(value) actual_numpy_type = type(value)
if actual_numpy_type not in single_types: if actual_numpy_type not in single_types:
...@@ -319,14 +321,14 @@ class Results(object): ...@@ -319,14 +321,14 @@ class Results(object):
if metainfo is None: if metainfo is None:
raise LookupError("The metainfo name '{}' does not exist in the metainfo environment. Check for typos or try updating the metainfo git package.".format(metaname)) raise LookupError("The metainfo name '{}' does not exist in the metainfo environment. Check for typos or try updating the metainfo git package.".format(metaname))
def traverse(self): def traverse(self, root_section='section_run'):
"""A generator function for traversing the data in the parser results. """A generator function for traversing the data in the parser results.
This generator returns a tuple of three item: the metainfo name, the This generator returns a tuple of three item: the metainfo name, the
event type, and the event value. event type, and the event value.
""" """
root = self._sectionmanagers["section_run"] root = self._sectionmanagers[root_section]
for x in self.traverse_recursive("section_run", root.openSections): for x in self.traverse_recursive(root_section, root.openSections):
yield x yield x
def traverse_recursive(self, name, open_sections): def traverse_recursive(self, name, open_sections):
...@@ -625,7 +627,7 @@ class SectionManager(object): ...@@ -625,7 +627,7 @@ class SectionManager(object):
gI = gIndex gI = gIndex
try: try:
self.openSections[gI].addValue(valueMetaInfo, value) self.openSections[gI].addValue(valueMetaInfo, value)
except KeyError: except (KeyError, IndexError):
raise Exception("Cannot add value for metadata %s to section %d (%d) of %s, as it is not open" % (valueMetaInfo.name, gI, gIndex, self.metaInfo.name)) raise Exception("Cannot add value for metadata %s to section %d (%d) of %s, as it is not open" % (valueMetaInfo.name, gI, gIndex, self.metaInfo.name))
def setArrayValues(self, valueMetaInfo, value, offset=None, gIndex=-1): def setArrayValues(self, valueMetaInfo, value, offset=None, gIndex=-1):
...@@ -635,7 +637,7 @@ class SectionManager(object): ...@@ -635,7 +637,7 @@ class SectionManager(object):
gI = gIndex gI = gIndex
try: try:
self.openSections[gI].setArrayValues(valueMetaInfo, value, offset) self.openSections[gI].setArrayValues(valueMetaInfo, value, offset)
except KeyError: except (KeyError, IndexError):
raise Exception("Cannot set array values for metadata %s to section %d (%d) of %s, as it is not open" % (valueMetaInfo.name, gI, gIndex, self.metaInfo.name)) raise Exception("Cannot set array values for metadata %s to section %d (%d) of %s, as it is not open" % (valueMetaInfo.name, gI, gIndex, self.metaInfo.name))
def addArrayValues(self, valueMetaInfo, value, gIndex=-1, **kwargs): def addArrayValues(self, valueMetaInfo, value, gIndex=-1, **kwargs):
...@@ -644,8 +646,8 @@ class SectionManager(object): ...@@ -644,8 +646,8 @@ class SectionManager(object):
else: else:
gI = gIndex gI = gIndex
try: try:
self.openSections[gI].addArrayValues(valueMetaInfo, value, **kwargs) self.openSections[gI].addArrayValues(valueMetaInfo, value)
except KeyError: except (KeyError, IndexError):
raise Exception("Cannot add array values for metadata %s to section %d (%d) of %s, as it is not open" % (valueMetaInfo.name, gI, gIndex, self.metaInfo.name)) raise Exception("Cannot add array values for metadata %s to section %d (%d) of %s, as it is not open" % (valueMetaInfo.name, gI, gIndex, self.metaInfo.name))
......
...@@ -10,6 +10,7 @@ import json ...@@ -10,6 +10,7 @@ import json
import os, re import os, re
from nomadcore.json_support import jsonCompactS, jsonCompactD, jsonIndentD from nomadcore.json_support import jsonCompactS, jsonCompactD, jsonIndentD
from io import open from io import open
import nomad_meta_info
"""objects to handle a local InfoKinds with unique name (think self written json)""" """objects to handle a local InfoKinds with unique name (think self written json)"""
class InfoKindEl(object): class InfoKindEl(object):
...@@ -183,14 +184,20 @@ class RelativeDependencySolver(object): ...@@ -183,14 +184,20 @@ class RelativeDependencySolver(object):
self.deps = {} self.deps = {}
def __call__(self, infoKindEnv, source, dep): def __call__(self, infoKindEnv, source, dep):
if "relativePath" not in dep: if "metainfoPath" in dep:
raise Exception('Invalid dependency for relativeDependencySolver there must be a relativePath') basePath = nomad_meta_info.__file__
basePath = source.get('path') path = dep["metainfoPath"]
elif "relativePath" in dep:
basePath = source.get('path')
path = dep["relativePath"]
else:
raise Exception('Invalid dependency for relativeDependencySolver there must be a relativePath or metainfoPath')
if basePath: if basePath:
baseDir = os.path.dirname(os.path.abspath(basePath)) baseDir = os.path.dirname(os.path.abspath(basePath))
else: else:
baseDir = os.getcwd() baseDir = os.getcwd()
dPath = os.path.realpath(os.path.join(baseDir, dep['relativePath'])) dPath = os.path.realpath(os.path.join(baseDir, path))
if dPath in self.deps: if dPath in self.deps:
return self.deps[dPath] return self.deps[dPath]
depInfo = None depInfo = None
...@@ -456,7 +463,7 @@ class InfoKindEnv(object): ...@@ -456,7 +463,7 @@ class InfoKindEnv(object):
def toJsonList(self, withGids): def toJsonList(self, withGids):
infoKinds = list(self.infoKinds.keys()) infoKinds = list(self.infoKinds.keys())
infoKinds.sort(lambda x, y: self.compareKeys(x.name, y.name)) # infoKinds.sort(lambda x, y: self.compareKeys(x.name, y.name))
return [self.infoKinds[x].toDict(self, return [self.infoKinds[x].toDict(self,
self if withGids else None) for x in infoKinds] self if withGids else None) for x in infoKinds]
......
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