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
bdfb098b
Commit
bdfb098b
authored
May 29, 2020
by
Lauri Himanen
Browse files
Added histogram data to the statistics route.
parent
de12d1f7
Pipeline
#75768
passed with stages
in 36 minutes and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nomad/app/api/encyclopedia.py
View file @
bdfb098b
...
...
@@ -714,6 +714,7 @@ histogram = api.model("histogram", {
statistics_query
=
api
.
model
(
"statistics_query"
,
{
"calculations"
:
fields
.
List
(
fields
.
String
),
"properties"
:
fields
.
List
(
fields
.
String
),
"n_histogram_bins"
:
fields
.
Integer
,
})
statistics
=
api
.
model
(
"statistics"
,
{
"min"
:
fields
.
Float
,
...
...
@@ -799,13 +800,13 @@ class EncStatisticsResource(Resource):
s
=
s
.
extra
(
**
{
"size"
:
0
,
})
n_b
uckets
=
10
n_b
ins
=
data
[
"n_histogram_bins"
]
for
prop
in
properties
:
stats
=
getattr
(
response
.
aggs
,
"{}_stats"
.
format
(
prop
))
interval
=
(
stats
.
max
-
stats
.
min
)
/
n_b
ucket
s
interval
=
(
stats
.
max
*
1.001
-
stats
.
min
)
/
n_b
in
s
if
interval
==
0
:
interval
=
1
hist_agg
=
A
(
"histogram"
,
field
=
property_map
[
prop
],
interval
=
interval
)
hist_agg
=
A
(
"histogram"
,
field
=
property_map
[
prop
],
interval
=
interval
,
offset
=
stats
.
min
,
min_doc_count
=
0
)
s
.
aggs
.
bucket
(
"{}_hist"
.
format
(
prop
),
hist_agg
)
response_hist
=
s
.
execute
()
...
...
@@ -820,7 +821,7 @@ class EncStatisticsResource(Resource):
"min"
:
stats
.
min
,
"max"
:
stats
.
max
,
"avg"
:
stats
.
avg
,
"hist"
:
{
"hist
ogram
"
:
{
"occurrences"
:
occurrences
,
"values"
:
values
,
}
...
...
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