Commit 59bf17e4 authored by Flavio TARSETTI's avatar Flavio TARSETTI
Browse files

[experiments/plotters] added --show option to display image with PIL

parent c5669982
Pipeline #20101 failed with stages
in 22 minutes and 20 seconds
......@@ -38,7 +38,7 @@
%(prog)s experiments fork <src> <dst>
%(prog)s experiments rm [--remote] <name>...
%(prog)s experiments draw [--path=<dir>] [<name>]...
%(prog)s experiments plot [--force] [--remote] [--outputfolder=<folder>][<name>]...
%(prog)s experiments plot [--force] [--remote] [--show] [--outputfolder=<folder>][<name>]...
%(prog)s experiments --help
......@@ -430,7 +430,7 @@ def pull(webapi, prefix, names, force, indentation, format_cache):
return status + tc_status + db_status + algo_status
def plot(webapi, configuration, prefix, names, remote_results, force, indentation, format_cache, outputfolder=None):
def plot(webapi, configuration, prefix, names, remote_results, show, force, indentation, format_cache, outputfolder=None):
"""Plots experiments from the server.
Parameters:
......@@ -502,7 +502,7 @@ def plot(webapi, configuration, prefix, names, remote_results, force, indentatio
output_name = key + '.png'
output_name = os.path.join(output_folder, output_name)
pl_status = plotters_pull(webapi, configuration.path, [value['type']], force, indentation + 2, {})
plot_status = plotters_plot(webapi, configuration.path, [value['type']], False, False, value['value'],
plot_status = plotters_plot(webapi, configuration.path, [value['type']], show, False, False, value['value'],
output_name, None, indentation + 2, format_cache)
status += pl_status
status += plot_status
......@@ -546,7 +546,7 @@ def plot(webapi, configuration, prefix, names, remote_results, force, indentatio
output_name = the_data + '.png'
output_name = os.path.join(output_folder, output_name)
pl_status = plotters_pull(webapi, configuration.path, [datatype], force, indentation + 2, {})
plot_status = plotters_plot(webapi, configuration.path, [datatype], False, False,
plot_status = plotters_plot(webapi, configuration.path, [datatype], show, False, False,
data.as_dict()[the_data], output_name, None, indentation + 2, format_cache)
status += pl_status
status += plot_status
......@@ -617,7 +617,7 @@ def process(args):
elif args['plot']:
with common.make_webapi(config) as webapi:
return plot(webapi, config, 'experiment', names, args['--remote'],
force, 0, {}, args['--outputfolder'])
args['--show'], force, 0, {}, args['--outputfolder'])
# Should not happen
logger.error("unrecognized `experiments' subcommand")
......
......@@ -30,7 +30,7 @@
%(prog)s plotters list [--remote]
%(prog)s plotters check [<name>]...
%(prog)s plotters pull [--force] [<name>]...
%(prog)s plotters plot [--force] [--sample_data] [--inputdata=<filename.json>] [--outputimage=<filename.png>] [--plotterparameter=<plotterparameter>] [<name>]...
%(prog)s plotters plot [--show] [--force] [--sample_data] [--inputdata=<filename.json>] [--outputimage=<filename.png>] [--plotterparameter=<plotterparameter>] [<name>]...
%(prog)s plotters create <name>...
%(prog)s plotters version <name>
%(prog)s plotters fork <src> <dst>
......@@ -63,6 +63,8 @@ import collections
from .dataformats import pull as dataformats_pull
from .plotterparameters import pull as plotterparameters_pull
from .libraries import pull as libraries_pull
from PIL import Image
import cStringIO
import logging
logger = logging.getLogger(__name__)
......@@ -135,7 +137,7 @@ def pull(webapi, prefix, names, force, indentation, format_cache):
return status + lb_status + df_status
def plot(webapi, prefix, names, force, need_data_sample, inputdata, outputimage, plotterparameter, indentation, format_cache):
def plot(webapi, prefix, names, show, force, need_data_sample, inputdata, outputimage, plotterparameter, indentation, format_cache):
"""plot sample plot from the server.
Parameters:
......@@ -254,6 +256,9 @@ def plot(webapi, prefix, names, force, need_data_sample, inputdata, outputimage,
assert runnable.ready
data_to_plot = [('sample_plot', sample_data)]
fig = runnable.process(data_to_plot)
if show:
im = Image.open(cStringIO.StringIO(fig))
im.show()
output_name = os.path.join(prefix, outputimage_name)
with open(output_name, "wb") as fh:
fh.write(fig)
......@@ -286,7 +291,7 @@ def process(args):
elif args['plot']:
with common.make_webapi(args['config']) as webapi:
return plot(webapi, args['config'].path, args['<name>'],
return plot(webapi, args['config'].path, args['<name>'], args['--show'],
args['--force'], args['--sample_data'], args['--inputdata'],
args['--outputimage'], args['--plotterparameter'],
0, {})
......
Supports Markdown
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