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
beat
beat.cmdline
Commits
2a8de19c
Commit
2a8de19c
authored
Jun 03, 2020
by
Samuel GAIST
Browse files
[experiments] Improve plotter output selection
Fixes
#71
parent
80f44b7e
Pipeline
#40297
passed with stage
in 4 minutes and 10 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/cmdline/experiments.py
View file @
2a8de19c
...
...
@@ -36,8 +36,8 @@
import
curses
import
glob
import
io
import
logging
import
mimetypes
import
os
import
queue
import
signal
...
...
@@ -641,10 +641,6 @@ def plot_impl(configuration, names, remote, show, output_folder):
for
exp_name
,
results
in
data_to_plot
.
items
():
for
result_name
,
result_data
in
results
.
items
():
outputimage_name
=
"{}_{}.png"
.
format
(
exp_name
.
replace
(
"/"
,
"_"
),
result_name
)
result_type
=
result_data
[
"type"
]
plotter
=
_get_plotter_for
(
result_type
)
...
...
@@ -660,7 +656,6 @@ def plot_impl(configuration, names, remote, show, output_folder):
)
default_parameters
=
_get_parametters_for
(
plotter
)
default_parameters
.
setdefault
(
"content_type"
,
"image/png"
)
runner
=
plotter
.
runner
()
runner
.
setup
(
default_parameters
)
...
...
@@ -677,18 +672,23 @@ def plot_impl(configuration, names, remote, show, output_folder):
sample_data
=
result_data
[
"value"
]
data_to_plot
=
[(
"sample_plot"
,
sample_data
)]
fig
=
runner
.
process
(
data_to_plot
)
if
show
:
from
PIL
import
Image
im
=
Image
.
open
(
io
.
BytesIO
(
fig
))
im
.
show
()
plotter_data
=
runner
.
process
(
data_to_plot
)
output_name
=
os
.
path
.
join
(
output_folder
,
outputimage_name
)
with
open
(
output_name
,
"wb"
)
as
fh
:
fh
.
write
(
fig
)
content_type
=
getattr
(
runner
.
obj
,
"content_type"
,
"image/png"
)
extension
=
mimetypes
.
guess_extension
(
content_type
)
outputimage_name
=
"{}_{}{}"
.
format
(
exp_name
.
replace
(
"/"
,
"_"
),
result_name
,
extension
)
output_path
=
os
.
path
.
realpath
(
os
.
path
.
join
(
output_folder
,
outputimage_name
)
)
with
open
(
output_path
,
"wb"
)
as
fh
:
fh
.
write
(
plotter_data
)
indentation
=
4
logger
.
info
(
"%ssaved image `%s'..."
,
indentation
*
" "
,
output_name
)
logger
.
info
(
"%ssaved image `%s'..."
,
indentation
*
" "
,
output_path
)
if
show
:
click
.
launch
(
output_path
)
def
get_dependencies
(
ctx
,
asset_name
):
...
...
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