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
05d42257
Commit
05d42257
authored
Nov 06, 2019
by
Markus Scheidgen
Browse files
Enable multi ids in queries for edit and download.
parent
ec7b8701
Changes
4
Hide whitespace changes
Inline
Side-by-side
gui/src/components/EditUserMetadataDialog.js
View file @
05d42257
...
...
@@ -481,7 +481,7 @@ class EditUserMetadataDialogUnstyled extends React.Component {
const
{
classes
,
buttonProps
,
total
,
api
,
user
,
example
,
disabled
}
=
this
.
props
const
{
open
,
actions
,
verified
,
submitting
}
=
this
.
state
const
dialogEnabled
=
user
&&
example
.
uploader
.
user_id
===
user
.
sub
&&
!
disabled
const
dialogEnabled
=
user
&&
example
.
uploader
&&
example
.
uploader
.
user_id
===
user
.
sub
&&
!
disabled
const
submitEnabled
=
Object
.
keys
(
actions
).
length
&&
!
submitting
&&
verified
const
listTextInputProps
=
(
key
,
verify
)
=>
{
...
...
nomad/app/api/repo.py
View file @
05d42257
...
...
@@ -138,12 +138,13 @@ def add_query(search_request: search.SearchRequest, args: Dict[str, Any]):
args
=
{
key
:
value
for
key
,
value
in
args
.
items
()
if
value
is
not
None
}
# owner
owner
=
args
.
get
(
'owner'
,
'all'
)
try
:
search_request
.
owner
(
args
.
get
(
'owner'
,
'all'
)
,
owner
,
g
.
user
.
user_id
if
g
.
user
is
not
None
else
None
)
except
ValueError
as
e
:
abort
(
401
,
getattr
(
e
,
'message'
,
'Invalid owner parameter
'
))
abort
(
401
,
getattr
(
e
,
'message'
,
'Invalid owner parameter
: %s'
%
owner
))
except
Exception
as
e
:
abort
(
400
,
getattr
(
e
,
'message'
,
'Invalid owner parameter'
))
...
...
@@ -298,7 +299,7 @@ query_model_parameters = {
}
for
quantity
in
search
.
quantities
.
values
():
if
quantity
.
multi
:
if
quantity
.
multi
and
quantity
.
argparse_action
is
None
:
def
field
(
**
kwargs
):
return
fields
.
List
(
fields
.
String
(
**
kwargs
))
else
:
...
...
@@ -434,8 +435,16 @@ class EditRepoCalcsResource(Resource):
return
json_data
,
400
# get all calculations that have to change
parsed_query
=
{}
for
quantity_name
,
quantity
in
search
.
quantities
.
items
():
if
quantity_name
in
query
:
value
=
query
[
quantity_name
]
if
quantity
.
multi
and
quantity
.
argparse_action
==
'split'
and
not
isinstance
(
value
,
list
):
value
=
value
.
split
(
','
)
parsed_query
[
quantity_name
]
=
value
search_request
=
search
.
SearchRequest
()
add_query
(
search_request
,
query
)
add_query
(
search_request
,
parsed_
query
)
calc_ids
=
list
(
hit
[
'calc_id'
]
for
hit
in
search_request
.
execute_scan
())
# perform the update on the mongo db
...
...
nomad/datamodel/base.py
View file @
05d42257
...
...
@@ -303,11 +303,21 @@ class Domain:
quantities
=
DomainQuantity
(
multi
=
True
,
description
=
'Search for the existence of a certain meta-info quantity'
),
upload_id
=
DomainQuantity
(
description
=
'Search for the upload_id.'
),
calc_id
=
DomainQuantity
(
description
=
'Search for the calc_id.'
),
pid
=
DomainQuantity
(
description
=
'Search for the pid.'
),
raw_id
=
DomainQuantity
(
description
=
'Search for the raw_id.'
),
mainfile
=
DomainQuantity
(
description
=
'Search for the mainfile.'
),
upload_id
=
DomainQuantity
(
description
=
'Search for the upload_id.'
,
multi
=
True
,
argparse_action
=
'split'
,
elastic_search_type
=
'terms'
),
calc_id
=
DomainQuantity
(
description
=
'Search for the calc_id.'
,
multi
=
True
,
argparse_action
=
'split'
,
elastic_search_type
=
'terms'
),
pid
=
DomainQuantity
(
description
=
'Search for the pid.'
,
multi
=
True
,
argparse_action
=
'split'
,
elastic_search_type
=
'terms'
),
raw_id
=
DomainQuantity
(
description
=
'Search for the raw_id.'
,
multi
=
True
,
argparse_action
=
'split'
,
elastic_search_type
=
'terms'
),
mainfile
=
DomainQuantity
(
description
=
'Search for the mainfile.'
,
multi
=
True
,
argparse_action
=
'append'
,
elastic_search_type
=
'terms'
),
external_id
=
DomainQuantity
(
description
=
'External user provided id. Does not have to be unique necessarily.'
,
multi
=
True
,
argparse_action
=
'split'
,
elastic_search_type
=
'terms'
),
...
...
tests/app/test_api.py
View file @
05d42257
...
...
@@ -1114,6 +1114,14 @@ class TestEditRepo():
assert
not
self
.
mongo
(
4
,
comment
=
'test_edit_all'
)
assert
not
self
.
elastic
(
4
,
comment
=
'test_edit_all'
)
def
test_edit_multi
(
self
):
rv
=
self
.
perform_edit
(
comment
=
'test_edit_multi'
,
query
=
dict
(
upload_id
=
'upload_1,upload_3'
))
self
.
assert_edit
(
rv
,
quantity
=
'comment'
,
success
=
True
,
message
=
False
)
assert
self
.
mongo
(
1
,
4
,
comment
=
'test_edit_multi'
)
assert
self
.
elastic
(
1
,
4
,
comment
=
'test_edit_multi'
)
assert
not
self
.
mongo
(
2
,
3
,
comment
=
'test_edit_multi'
)
assert
not
self
.
elastic
(
2
,
3
,
comment
=
'test_edit_multi'
)
def
test_edit_some
(
self
):
rv
=
self
.
perform_edit
(
comment
=
'test_edit_some'
,
query
=
dict
(
upload_id
=
'upload_1'
))
self
.
assert_edit
(
rv
,
quantity
=
'comment'
,
success
=
True
,
message
=
False
)
...
...
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