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
ae275ac4
Commit
ae275ac4
authored
Apr 09, 2020
by
Markus Scheidgen
Browse files
Removed statistics_order from api.
parent
2aca1cb9
Changes
6
Hide whitespace changes
Inline
Side-by-side
gui/src/components/search/UploadersList.js
View file @
ae275ac4
...
...
@@ -21,8 +21,7 @@ class UploadersList extends React.Component {
static
contextType
=
SearchContext
.
type
componentDidMount
()
{
const
{
state
:
{
query
},
setQuery
,
setStatisticsToRefresh
}
=
this
.
context
setQuery
({...
query
,
statistics_order
:
'
_count
'
})
const
{
setStatisticsToRefresh
}
=
this
.
context
setStatisticsToRefresh
(
'
uploader
'
)
}
...
...
nomad/app/api/repo.py
View file @
ae275ac4
...
...
@@ -113,8 +113,6 @@ _search_request_parser.add_argument(
'Possible values are %s.'
%
', '
.
join
(
search_extension
.
metrics
.
keys
())))
_search_request_parser
.
add_argument
(
'statistics'
,
type
=
bool
,
help
=
(
'Return statistics.'
))
_search_request_parser
.
add_argument
(
'statistics_order'
,
type
=
str
,
help
=
'Statistics order (can be _key or _count)'
)
_search_request_parser
.
add_argument
(
'exclude'
,
type
=
str
,
action
=
'split'
,
help
=
'Excludes the given keys in the returned data.'
)
for
group_name
in
search_extension
.
groups
:
...
...
@@ -203,7 +201,6 @@ class RepoCalcsResource(Resource):
with_statistics
=
args
.
get
(
'statistics'
,
False
)
or
\
any
(
args
.
get
(
group_name
,
False
)
for
group_name
in
search_extension
.
groups
)
statistics_order
=
args
.
get
(
'statistics_order'
,
'_key'
)
except
Exception
as
e
:
abort
(
400
,
message
=
'bad parameters: %s'
%
str
(
e
))
...
...
@@ -233,7 +230,7 @@ class RepoCalcsResource(Resource):
abort
(
400
,
message
=
'there is no metric %s'
%
metric
)
if
with_statistics
:
search_request
.
default_statistics
(
metrics_to_use
=
metrics
,
statistics_order
=
statistics_order
)
search_request
.
default_statistics
(
metrics_to_use
=
metrics
)
additional_metrics
=
[
group_quantity
.
metric_name
...
...
nomad/datamodel/datamodel.py
View file @
ae275ac4
...
...
@@ -351,7 +351,8 @@ class EntryMetadata(metainfo.MSection):
description
=
'Search uploader with exact names.'
,
metric_name
=
'uploaders'
,
metric
=
'cardinality'
,
many_or
=
'append'
,
search_field
=
'uploader.name.keyword'
,
default_statistic
=
True
,
statistic_size
=
10
),
default_statistic
=
True
,
statistic_size
=
10
,
statistic_order
=
'_count'
),
Search
(
name
=
'uploader_id'
,
search_field
=
'uploader.user_id'
)
])
...
...
nomad/datamodel/dft.py
View file @
ae275ac4
...
...
@@ -259,12 +259,16 @@ class DFTMetadata(MSection):
labels_springer_compound_class
=
Quantity
(
type
=
str
,
shape
=
[
'0..*'
],
description
=
'Springer compund classification.'
,
a_search
=
Search
(
many_and
=
'append'
,
default_statistic
=
True
,
statistic_size
=
10
))
a_search
=
Search
(
many_and
=
'append'
,
default_statistic
=
True
,
statistic_size
=
10
,
statistic_order
=
'_count'
))
labels_springer_classification
=
Quantity
(
type
=
str
,
shape
=
[
'0..*'
],
description
=
'Springer classification by property.'
,
a_search
=
Search
(
many_and
=
'append'
,
default_statistic
=
True
,
statistic_size
=
10
))
a_search
=
Search
(
many_and
=
'append'
,
default_statistic
=
True
,
statistic_size
=
10
,
statistic_order
=
'_count'
))
optimade
=
SubSection
(
sub_section
=
OptimadeEntry
,
...
...
nomad/metainfo/search_extension.py
View file @
ae275ac4
...
...
@@ -64,6 +64,9 @@ class Search(Elastic):
default_statistic: Indicates this quantity to be part of the default statistics.
statistics_size:
The maximum number of values in a statistic. Default is 10.
statistics_order:
The order key that is passed to elastic search to determine the order of
the statistic values.
group: Indicates that his quantity can be used to group results. The value will
be the name of the group.
search_field: The qualified field in the elastic mapping that is used to search.
...
...
@@ -81,6 +84,7 @@ class Search(Elastic):
group
:
str
=
None
,
metric
:
str
=
None
,
metric_name
:
str
=
None
,
default_statistic
:
bool
=
False
,
statistic_size
:
int
=
10
,
statistic_order
:
str
=
'_key'
,
derived
:
Callable
[[
Any
],
Any
]
=
None
,
search_field
:
str
=
None
,
**
kwargs
):
...
...
@@ -97,6 +101,7 @@ class Search(Elastic):
self
.
metric
=
metric
self
.
metric_name
=
metric_name
self
.
statistic_size
=
statistic_size
self
.
statistic_order
=
statistic_order
self
.
search_field
=
search_field
self
.
derived
=
derived
...
...
nomad/search.py
View file @
ae275ac4
...
...
@@ -281,25 +281,23 @@ class SearchRequest:
self
.
_add_metrics
(
self
.
_search
.
aggs
,
metrics_to_use
)
return
self
def
default_statistics
(
self
,
metrics_to_use
:
List
[
str
]
=
[]
,
statistics_order
:
str
=
'_key'
):
def
default_statistics
(
self
,
metrics_to_use
:
List
[
str
]
=
[]):
'''
Configures the domain's default statistics.
'''
mode
=
'desc'
if
statistics_order
==
'_key'
:
mode
=
'asc'
order
=
{
statistics_order
:
mode
}
for
search_quantity
in
default_statistics
[
self
.
_domain
]:
statistic_order
=
search_quantity
.
statistic_order
self
.
statistic
(
search_quantity
.
qualified_name
,
search_quantity
.
statistic_size
,
metrics_to_use
=
metrics_to_use
,
order
=
order
)
order
=
{
statistic_order
:
'asc'
if
statistic_order
==
'_key'
else
'desc'
}
)
return
self
def
statistic
(
self
,
quantity_name
:
str
,
size
:
int
,
metrics_to_use
:
List
[
str
]
=
[],
order
:
Dict
[
str
,
str
]
=
dict
(
_key
=
'asc'
)):
def
statistic
(
self
,
quantity_name
:
str
,
size
:
int
,
metrics_to_use
:
List
[
str
]
=
[],
order
:
Dict
[
str
,
str
]
=
dict
(
_key
=
'asc'
)):
'''
This can be used to display statistics over the searched entries and allows to
implement faceted search on the top values for each quantity.
...
...
@@ -323,6 +321,7 @@ class SearchRequest:
metrics_to_use: The metrics calculated over the aggregations. Can be
``unique_code_runs``, ``datasets``, other domain specific metrics.
The basic doc_count metric ``code_runs`` is always given.
order: The order dictionary is passed to the elastic search aggregation.
'''
quantity
=
search_quantities
[
quantity_name
]
terms
=
A
(
'terms'
,
field
=
quantity
.
search_field
,
size
=
size
,
order
=
order
)
...
...
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