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
a2cef69a
Commit
a2cef69a
authored
Dec 17, 2021
by
Markus Scheidgen
Browse files
Clean API user metadata.
parent
df4515a1
Pipeline
#118132
passed with stages
in 34 minutes and 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/datamodel/__init__.py
View file @
a2cef69a
...
...
@@ -92,7 +92,7 @@ from .ems import EMSMetadata
from
.qcms
import
QCMSMetadata
from
.datamodel
import
(
Dataset
,
User
,
Author
,
EditableUserMetadata
,
UserProvidableMetadata
,
OasisMetadata
,
MongoMetadata
,
EntryMetadata
,
EntryArchive
)
MongoMetadata
,
EntryMetadata
,
EntryArchive
,
user_reference
,
author_reference
)
from
.optimade
import
OptimadeEntry
,
Species
from
.metainfo
import
m_env
...
...
nomad/search.py
View file @
a2cef69a
...
...
@@ -43,6 +43,11 @@ _entry_metadata_defaults = {
if
quantity
.
default
not
in
[
None
,
[],
False
,
0
]
}
_all_author_quantities
=
[
quantity
.
name
for
quantity
in
datamodel
.
EntryMetadata
.
m_def
.
all_quantities
.
values
()
if
quantity
.
type
in
[
datamodel
.
user_reference
,
datamodel
.
author_reference
]]
def
_es_to_entry_dict
(
hit
,
required
:
MetadataRequired
)
->
Dict
[
str
,
Any
]:
'''
...
...
@@ -61,6 +66,16 @@ def _es_to_entry_dict(hit, required: MetadataRequired) -> Dict[str, Any]:
entry_dict
[
key
]
=
value
for
author_quantity
in
_all_author_quantities
:
authors
=
entry_dict
.
get
(
author_quantity
)
if
authors
is
None
:
continue
if
isinstance
(
authors
,
dict
):
authors
=
[
authors
]
for
author
in
authors
:
if
'email'
in
author
:
del
(
author
[
'email'
])
return
entry_dict
...
...
tests/app/v1/routers/test_entries.py
View file @
a2cef69a
...
...
@@ -227,6 +227,9 @@ def assert_entry_metadata(response_json):
if
'required'
not
in
response_json
:
assert
'license'
in
entry
if
'uploader'
in
entry
:
assert
'email'
not
in
entry
[
'uploader'
]
def
assert_entries_metadata_response
(
response
,
status_code
=
None
):
response_json
=
assert_entries_raw_metadata_response
(
response
,
status_code
=
status_code
)
...
...
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