Commit 2a8de19c authored by Samuel GAIST's avatar Samuel GAIST

[experiments] Improve plotter output selection

Fixes #71
parent 80f44b7e
Pipeline #40297 passed with stage
in 4 minutes and 10 seconds
......@@ -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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment