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
fca57924
Commit
fca57924
authored
Jan 25, 2021
by
Markus Scheidgen
Browse files
Allow the admin user to provide uploader metadata via nomad.json.
parent
bf687c24
Pipeline
#92638
canceled with stages
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
nomad/processing/data.py
View file @
fca57924
...
@@ -586,6 +586,10 @@ class Calc(Proc):
...
@@ -586,6 +586,10 @@ class Calc(Proc):
if
definition
is
None
and
self
.
upload
.
from_oasis
:
if
definition
is
None
and
self
.
upload
.
from_oasis
:
definition
=
_oasis_metadata
.
get
(
key
,
None
)
definition
=
_oasis_metadata
.
get
(
key
,
None
)
if
key
==
'uploader'
:
if
datamodel
.
User
.
get
(
self
.
upload
.
user_id
).
is_admin
:
definition
=
datamodel
.
EntryMetadata
.
uploader
if
definition
is
None
:
if
definition
is
None
:
logger
.
warn
(
'Users cannot set metadata'
,
quantity
=
key
)
logger
.
warn
(
'Users cannot set metadata'
,
quantity
=
key
)
continue
continue
...
...
tests/conftest.py
View file @
fca57924
...
@@ -297,6 +297,7 @@ def keycloak(monkeypatch):
...
@@ -297,6 +297,7 @@ def keycloak(monkeypatch):
@
pytest
.
fixture
(
scope
=
'function'
)
@
pytest
.
fixture
(
scope
=
'function'
)
def
proc_infra
(
worker
,
elastic
,
mongo
,
raw_files
):
def
proc_infra
(
worker
,
elastic
,
mongo
,
raw_files
):
''' Combines all fixtures necessary for processing (elastic, worker, files, mongo) '''
''' Combines all fixtures necessary for processing (elastic, worker, files, mongo) '''
processing
.
Upload
.
metadata_file_cached
.
cache_clear
()
return
dict
(
elastic
=
elastic
)
return
dict
(
elastic
=
elastic
)
...
...
tests/data/proc/examples_with_adminmetadata.zip
0 → 100644
View file @
fca57924
File added
tests/processing/test_data.py
View file @
fca57924
...
@@ -606,3 +606,25 @@ def test_read_metadata_from_file(proc_infra, test_user, other_test_user):
...
@@ -606,3 +606,25 @@ def test_read_metadata_from_file(proc_infra, test_user, other_test_user):
assert
entry_coauthors
[
j
].
email
==
coauthors
[
i
][
j
].
email
assert
entry_coauthors
[
j
].
email
==
coauthors
[
i
][
j
].
email
assert
entry_coauthors
[
j
].
first_name
==
coauthors
[
i
][
j
].
first_name
assert
entry_coauthors
[
j
].
first_name
==
coauthors
[
i
][
j
].
first_name
assert
entry_coauthors
[
j
].
last_name
==
coauthors
[
i
][
j
].
last_name
assert
entry_coauthors
[
j
].
last_name
==
coauthors
[
i
][
j
].
last_name
@
pytest
.
mark
.
parametrize
(
'user,uploader'
,
[
(
'admin_user'
,
'other_test_user'
),
(
'test_user'
,
'test_user'
)
])
def
test_read_adminmetadata_from_file
(
proc_infra
,
test_user
,
other_test_user
,
admin_user
,
user
,
uploader
):
def
user_from_name
(
user_name
):
if
user_name
==
'test_user'
:
return
test_user
if
user_name
==
'other_test_user'
:
return
other_test_user
if
user_name
==
'admin_user'
:
return
admin_user
user
=
user_from_name
(
user
)
uploader
=
user_from_name
(
uploader
)
upload
=
run_processing
(
(
'test_upload'
,
'tests/data/proc/examples_with_adminmetadata.zip'
),
user
)
calc
=
Calc
.
objects
(
upload_id
=
upload
.
upload_id
).
first
()
assert
calc
.
metadata
[
'uploader'
]
==
uploader
.
user_id
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