Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
2490668f
Commit
2490668f
authored
Jul 30, 2020
by
Markus Scheidgen
Browse files
Fully removed normalizer dependence on backend.
parent
60d2111b
Changes
4
Show whitespace changes
Inline
Side-by-side
nomad/normalizing/encyclopedia/encyclopedia.py
View file @
2490668f
...
...
@@ -22,7 +22,6 @@ from nomad.datamodel.encyclopedia import (
Properties
,
Calculation
,
)
from
nomad.parsing.legacy
import
Backend
from
nomad.normalizing.encyclopedia.context
import
Context
from
nomad.normalizing.encyclopedia.material
import
MaterialBulkNormalizer
,
Material2DNormalizer
,
Material1DNormalizer
from
nomad.normalizing.encyclopedia.method
import
MethodDFTNormalizer
,
MethodGWNormalizer
...
...
@@ -37,10 +36,6 @@ class EncyclopediaNormalizer(Normalizer):
within a new section called "encyclopedia". In the future these separate
metainfos could be absorbed into the existing metainfo hiearchy.
"""
def
__init__
(
self
,
backend
:
Backend
):
super
().
__init__
(
backend
)
self
.
backend
:
Backend
=
backend
def
calc_type
(
self
,
calc
:
Calculation
)
->
str
:
"""Decides what type of calculation this is: single_point, md,
geometry_optimization, etc.
...
...
nomad/normalizing/normalizer.py
View file @
2490668f
...
...
@@ -15,27 +15,27 @@
from
abc
import
ABCMeta
,
abstractmethod
from
typing
import
List
from
nomad.parsing
import
Backend
from
nomad.utils
import
get_logger
from
nomad.metainfo
import
MSection
from
nomad.datamodel
import
EntryArchive
class
Normalizer
(
metaclass
=
ABCMeta
):
'''
A base class for normalizers. Normalizers work on a :class:`
Backend` instance
A base class for normalizers. Normalizers work on a :class:`
EntryArchive` section
for read and write. Normalizer instances are reused.
Arguments:
backend: The backend used to read and write data from and to
.
entry_archive: The entry_archive root section of the archive to normalize
.
'''
domain
=
'dft'
''' The domain this normalizer should be used in. Default for all normalizer is 'DFT'. '''
def
__init__
(
self
,
backend
:
Backend
)
->
None
:
self
.
entry_archive
=
backend
.
entry_archive
def
__init__
(
self
,
entry_archive
:
EntryArchive
)
->
None
:
self
.
entry_archive
=
entry_archive
try
:
self
.
section_run
=
backend
.
entry_archive
.
section_run
[
0
]
self
.
section_run
=
entry_archive
.
section_run
[
0
]
except
(
AttributeError
,
IndexError
):
self
.
section_run
=
None
self
.
logger
=
get_logger
(
__name__
)
...
...
@@ -57,8 +57,8 @@ class SystemBasedNormalizer(Normalizer, metaclass=ABCMeta):
Args:
only_representatives: Will only normalize the `representative` systems.
'''
def
__init__
(
self
,
backend
:
Backend
,
only_representatives
:
bool
=
False
):
super
().
__init__
(
backend
)
def
__init__
(
self
,
entry_archive
:
EntryArchive
,
only_representatives
:
bool
=
False
):
super
().
__init__
(
entry_archive
)
self
.
only_representatives
=
only_representatives
@
property
...
...
nomad/processing/data.py
View file @
2490668f
...
...
@@ -528,7 +528,7 @@ class Calc(Proc):
logger
,
'normalizer executed'
,
input_size
=
self
.
mainfile_file
.
size
):
with
self
.
use_parser_backend
(
normalizer_name
)
as
backend
:
try
:
normalizer
(
backend
).
normalize
(
logger
=
logger
)
normalizer
(
backend
.
entry_archive
).
normalize
(
logger
=
logger
)
except
Exception
as
e
:
self
.
_parser_backend
.
finishedParsingSession
(
'ParseFailure'
,
[
str
(
e
)])
logger
.
error
(
...
...
tests/normalizing/conftest.py
View file @
2490668f
...
...
@@ -32,7 +32,7 @@ def run_normalize(backend: Backend) -> Backend:
assert
status
==
'ParseSuccess'
for
normalizer_class
in
normalizers
:
normalizer
=
normalizer_class
(
backend
)
normalizer
=
normalizer_class
(
backend
.
entry_archive
)
normalizer
.
normalize
()
return
backend
...
...
Write
Preview
Supports
Markdown
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