Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
parser-gpaw
Commits
a3f52f62
Commit
a3f52f62
authored
Mar 20, 2020
by
Markus Scheidgen
Browse files
Remove dependency on old metainfo.
parent
49615307
Changes
5
Hide whitespace changes
Inline
Side-by-side
gpawparser/parser-gpaw/parser.py
View file @
a3f52f62
...
...
@@ -21,7 +21,6 @@ from ase.data import chemical_symbols
import
setup_paths
from
nomadcore.unit_conversion.unit_conversion
import
convert_unit
as
cu
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
tar
import
Reader
from
libxc_names
import
get_libxc_xc_names
from
versions
import
get_prog_version
...
...
@@ -39,23 +38,6 @@ def c(value, unit=None):
parser_info
=
{
"name"
:
"parser_gpaw"
,
"version"
:
"1.0"
}
path
=
'../../../../nomad-meta-info/meta_info/nomad_meta_info/'
+
\
'gpaw.nomadmetainfo.json'
# metaInfoPath = os.path.normpath(
# os.path.join(os.path.dirname(os.path.abspath(__file__)), path))
# metaInfoEnv, warns = loadJsonFile(filePath=metaInfoPath,
# dependencyLoader=None,
# extraArgsHandling=InfoKindEl.ADD_EXTRA_ARGS,
# uri=None)
import
nomad_meta_info
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
nomad_meta_info
.
__file__
)),
"gpaw.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
class
LibAtomsParserWrapper
():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
...
...
@@ -63,15 +45,13 @@ class LibAtomsParserWrapper():
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
from
unittest.mock
import
patch
logging
.
info
(
'lib-atoms parser started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
meta
I
nfo
Env
)
backend
=
self
.
backend_factory
(
"gpaw.nomad
meta
i
nfo
.json"
)
backend
=
parse_without_class
(
mainfile
,
backend
)
return
backend
def
parse_without_class
(
filename
,
backend
):
# p = JsonParseEventsWriterBackend(metaInfoEnv)
p
=
backend
o
=
open_section
r
=
Reader
(
filename
)
...
...
gpawparser/parser-gpaw/parser2.py
View file @
a3f52f62
# Copyright 2015-2018 Mikkel Strange, Fawzi Mohamed, Ankit Kariryaa, Ask Hjorth Larsen, Jens Jørgen Mortensen
#
#
# 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.
...
...
@@ -26,10 +26,10 @@ from ase.units import Rydberg
import
setup_paths
from
nomadcore.unit_conversion.unit_conversion
import
convert_unit
as
cu
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
libxc_names
import
get_libxc_name
from
default_parameters
import
parameters
as
parms
from
nomad.parsing.legacy
import
Backend
@
contextmanager
def
open_section
(
p
,
name
):
...
...
@@ -56,7 +56,7 @@ metaInfoEnv, warns = loadJsonFile(filePath=metaInfoPath,
def
parse
(
filename
):
p
=
JsonParseEventsWriter
Backend
(
metaInfoEnv
)
p
=
Backend
(
metaInfoEnv
)
o
=
open_section
r
=
ulmopen
(
filename
)
# Reader(filename)
p
.
startedParsingSession
(
filename
,
parser_info
)
...
...
gpawparser/parser.py
View file @
a3f52f62
...
...
@@ -21,7 +21,6 @@ from ase.data import chemical_symbols
# import setup_paths
from
nomadcore.unit_conversion.unit_conversion
import
convert_unit
as
cu
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
gpawparser.tar
import
Reader
from
gpawparser.libxc_names
import
get_libxc_xc_names
from
gpawparser.versions
import
get_prog_version
...
...
@@ -42,29 +41,19 @@ parser_info = {"name": "parser_gpaw", "version": "1.0"}
path
=
'../../../../nomad-meta-info/meta_info/nomad_meta_info/'
+
\
'gpaw.nomadmetainfo.json'
import
nomad_meta_info
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
nomad_meta_info
.
__file__
)),
"gpaw.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
class
GPAWParserWrapper
():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
from
unittest.mock
import
patch
logging
.
info
(
'GPAW parser started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
meta
I
nfo
Env
)
backend
=
self
.
backend_factory
(
"gpaw.nomad
meta
i
nfo
.json"
)
backend
=
parse_without_class
(
mainfile
,
backend
)
return
backend
def
parse_without_class
(
filename
,
backend
):
# p = JsonParseEventsWriterBackend(metaInfoEnv)
p
=
backend
o
=
open_section
r
=
Reader
(
filename
)
...
...
gpawparser/parser2.py
View file @
a3f52f62
...
...
@@ -26,7 +26,6 @@ from ase.data import atomic_masses
from
ase.units
import
Rydberg
from
nomadcore.unit_conversion.unit_conversion
import
convert_unit
as
cu
from
nomadcore.local_meta_info
import
loadJsonFile
,
InfoKindEl
from
nomadcore.parser_backend
import
JsonParseEventsWriterBackend
from
gpawparser.libxc_names
import
get_libxc_name
from
gpawparser.default_parameters
import
parameters
as
parms
...
...
@@ -47,31 +46,21 @@ parser_info = {"name": "parser2_gpaw", "version": "1.0"}
path
=
'../../../../nomad-meta-info/meta_info/nomad_meta_info/'
+
\
'gpaw.nomadmetainfo.json'
import
nomad_meta_info
metaInfoPath
=
os
.
path
.
normpath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
nomad_meta_info
.
__file__
)),
"gpaw.nomadmetainfo.json"
))
metaInfoEnv
,
warnings
=
loadJsonFile
(
filePath
=
metaInfoPath
,
dependencyLoader
=
None
,
extraArgsHandling
=
InfoKindEl
.
ADD_EXTRA_ARGS
,
uri
=
None
)
class
GPAWParser2Wrapper
():
""" A proper class envolop for running this parser using Noamd-FAIRD infra. """
def
__init__
(
self
,
backend
,
**
kwargs
):
self
.
backend_factory
=
backend
def
parse
(
self
,
mainfile
):
from
unittest.mock
import
patch
logging
.
info
(
'GPAW parser 2 (note the 2) started'
)
logging
.
getLogger
(
'nomadcore'
).
setLevel
(
logging
.
WARNING
)
backend
=
self
.
backend_factory
(
meta
I
nfo
Env
)
backend
=
self
.
backend_factory
(
"gpaw.nomad
meta
i
nfo
.json"
)
backend
=
parse_without_class
(
mainfile
,
backend
)
return
backend
def
parse_without_class
(
filename
,
backend
):
p
=
backend
# p = JsonParseEventsWriterBackend(metaInfoEnv)
o
=
open_section
r
=
ulmopen
(
filename
)
# Reader(filename)
p
.
startedParsingSession
(
filename
,
parser_info
)
...
...
gpawparser/setup_paths.py
deleted
100644 → 0
View file @
49615307
# Copyright 2015-2018 Mikkel Strange, Fawzi Mohamed, Ankit Kariryaa, Ask Hjorth Larsen, Jens Jørgen Mortensen
#
# 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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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