Commit 120d46e5 authored by Markus Scheidgen's avatar Markus Scheidgen

Quick fixes (due to different SciPy version?). Allow empty or unknown data.

parent b03240e3
......@@ -30,7 +30,9 @@ class Reader:
self.conf_names = None
self.calc_names = None
self.f = netcdf_file(fname, 'r', mmap=True)
self.atk_version = self.f.version[:].decode('utf-8').split()[-1]
self.atk_version = 'unavailable'
# TODO this implementation causes an error, in current SciPy netcdf_file has no .version
# self.atk_version = self.f.version[:].decode('utf-8').split()[-1]
self.read_names()
for gid in self.calc_names.keys():
conf_name = self.conf_names[gid]
......@@ -118,7 +120,9 @@ class Reader:
the finger print table which maps between calculated
quantities and configurations.
"""
self._names = self.f._names[:].decode('utf-8').split(';')
# TODO there are no ._names in this SciPy version
# self._names = self.f._names[:].decode('utf-8').split(';')
self._names = self.f.variables.keys() # [:].decode('utf-8').split(';')
self.conf_names = self._read_configuration_names()
self.calc_names = self._read_calculator_names()
self.finger_print_table = self._read_finger_print_table()
......
......@@ -51,29 +51,29 @@ metaInfoEnv, warnings = loadJsonFile(
extraArgsHandling = InfoKindEl.ADD_EXTRA_ARGS, uri = None)
class ATKParserWrapper():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
""" A proper class envolop for running this parser using nomad-FAIRDI infra. """
def __init__(self, backend, **kwargs):
self.backend_factory = backend
def parse(self, mainfile):
from unittest.mock import patch
logging.info('ATK parser started')
logging.getLogger('nomadcore').setLevel(logging.WARNING)
backend = self.backend_factory(metaInfoEnv)
backend = parse_without_class(mainfile, backend)
parse_without_class(mainfile, backend)
return backend
def parse_without_class(filename, backend):
p = backend # JsonParseEventsWriterBackend(metaInfoEnv)
o = open_section
r = Reader(filename)
indices = range(r.get_number_of_calculators())
for index in indices:
r.c = r.get_calculator(index)
if r.c is None:
return
return backend
r.atoms = r.get_atoms(index)
p = backend # JsonParseEventsWriterBackend(metaInfoEnv)
o = open_section
p.startedParsingSession(filename, parser_info)
with o(p, 'section_run'):
p.addValue('program_name', 'ATK')
......@@ -186,6 +186,13 @@ def parse_without_class(filename, backend):
p.finishedParsingSession("ParseSuccess", None)
return p
logging.getLogger('nomadcore').warn('no known calculator found, maybe not a ATK file?')
with o(p, 'section_run'):
p.addValue('program_name', 'ATK')
p.addValue('program_version', r.atk_version)
return p
if __name__ == '__main__':
import sys
filename = sys.argv[1]
......
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