Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
nomad-lab
nomad-FAIR
Commits
7e719534
Commit
7e719534
authored
Mar 25, 2020
by
Lauri Himanen
Browse files
Updated the exception messages for missing basis set information.
parent
2d7d0b1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
nomad/normalizing/encyclopedia/method.py
View file @
7e719534
...
...
@@ -62,7 +62,7 @@ class MethodNormalizer():
try
:
method_dict
.
check
(
recursive
=
True
)
except
(
KeyError
,
ValueError
)
as
e
:
self
.
logger
.
info
(
"Could not create method hash
, missing required information
: {}"
.
format
(
str
(
e
)
))
self
.
logger
.
info
(
"Could not create method hash: {}"
.
format
(
e
))
else
:
method
.
method_hash
=
method_dict
.
hash
()
...
...
@@ -72,11 +72,11 @@ class MethodNormalizer():
def
group_eos_hash
(
self
,
method
:
Method
,
material
:
Material
,
repr_method
:
Section
):
eos_dict
=
RestrictedDict
(
mandatory_keys
=
(
mandatory_keys
=
[
"upload_id"
,
"method_hash"
,
"formula"
,
)
,
]
,
forbidden_values
=
[
None
]
)
...
...
@@ -93,7 +93,7 @@ class MethodNormalizer():
try
:
eos_dict
.
check
(
recursive
=
True
)
except
(
KeyError
,
ValueError
)
as
e
:
self
.
logger
.
info
(
"Could not create EOS hash
, missing required information
: {}"
.
format
(
str
(
e
)
))
self
.
logger
.
info
(
"Could not create EOS hash: {}"
.
format
(
e
))
else
:
method
.
group_eos_hash
=
eos_dict
.
hash
()
...
...
@@ -146,7 +146,7 @@ class MethodNormalizer():
try
:
param_dict
.
check
(
recursive
=
True
)
except
(
KeyError
,
ValueError
)
as
e
:
self
.
logger
.
info
(
"Could not create parameter variation hash
, missing required information
: {}"
.
format
(
str
(
e
)
))
self
.
logger
.
info
(
"Could not create parameter variation hash: {}"
.
format
(
e
))
else
:
method
.
group_parametervariation_hash
=
param_dict
.
hash
()
...
...
nomad/utils.py
View file @
7e719534
...
...
@@ -562,7 +562,7 @@ class RestrictedDict(OrderedDict):
optional_keys: Keys that are optional.
forbidden_values: Values that are forbidden. Only supports hashable values.
lazy: If false, the values are checked already when inserting. If
t
rue, the values
are on
ly checked
manually
by calling the
T
rue, the values
should be manual
ly checked by calling the
check()-function.
"""
super
().
__init__
()
...
...
@@ -595,7 +595,7 @@ class RestrictedDict(OrderedDict):
# Check that only the defined keys are used
if
key
not
in
self
.
_mandatory_keys
and
key
not
in
self
.
_optional_keys
:
raise
KeyError
(
"The key {} is not allowed."
.
format
(
key
))
raise
KeyError
(
"The key
'
{}
'
is not allowed."
.
format
(
key
))
# Check that forbidden values are not used.
try
:
...
...
@@ -604,7 +604,7 @@ class RestrictedDict(OrderedDict):
pass
# Unhashable value will not match
else
:
if
match
:
raise
ValueError
(
"The value {} is not allowed."
.
format
(
key
))
raise
ValueError
(
"The value
'
{}
'
is not allowed."
.
format
(
key
))
super
().
__setitem__
(
key
,
value
)
...
...
@@ -612,22 +612,23 @@ class RestrictedDict(OrderedDict):
# Check that only the defined keys are used
for
key
in
self
.
keys
():
if
key
not
in
self
.
_mandatory_keys
and
key
not
in
self
.
_optional_keys
:
raise
KeyError
(
"The key {} is not allowed."
.
format
(
key
))
raise
KeyError
(
"The key
'
{}
'
is not allowed."
.
format
(
key
))
# Check that all mandatory values are all defined
for
key
in
self
.
_mandatory_keys
:
if
key
not
in
self
:
raise
KeyError
(
"The mandatory key {} is not present."
.
format
(
key
))
raise
KeyError
(
"The mandatory key
'
{}
'
is not present."
.
format
(
key
))
# Check that forbidden values are not used.
for
value
in
self
.
values
():
for
key
,
value
in
self
.
items
():
match
=
False
try
:
match
=
value
in
self
.
_forbidden_values
except
TypeError
:
pass
# Unhashable value will not match
else
:
if
match
:
raise
ValueError
(
"The value {} is not allowed."
.
format
(
key
))
raise
ValueError
(
"The value
'
{}
'
is not allowed
but was set for key '{}'
."
.
format
(
value
,
key
))
# Check recursively
if
recursive
:
...
...
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