Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
parser-atk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nomad-lab
parser-atk
Commits
120d46e5
Commit
120d46e5
authored
Aug 12, 2019
by
Markus Scheidgen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Quick fixes (due to different SciPy version?). Allow empty or unknown data.
parent
b03240e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
atkparser/atkio.py
atkparser/atkio.py
+6
-2
atkparser/parser_atk.py
atkparser/parser_atk.py
+13
-6
No files found.
atkparser/atkio.py
View file @
120d46e5
...
...
@@ -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
()
...
...
atkparser/parser_atk.py
View file @
120d46e5
...
...
@@ -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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment