Merge "Add run_time_meta arge to specify values to use in graph"

This commit is contained in:
Jenkins 2017-03-07 00:43:58 +00:00 committed by Gerrit Code Review
commit 8a079dfec4
3 changed files with 34 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 KiB

View File

@ -137,6 +137,27 @@ will generate a graph like:
.. image:: graph-dailycount.png
Run Time Grouped By Run Metadata
--------------------------------
This graph generates a box and whiskers plot to show the distribution of run
times for runs with each plot grouped by values to a provided run_metadata key
For example, running something like::
subunit2sql-graph --title "Run times by Job Name" --database-connection mysql://test:test@localhost/subunit2sql -o test.png run_time_meta build_name --filter_list gate-tempest-dsvm-neutron-full-ssh,gate-tempest-dsvm-full-ubuntu-xenial,gate-tempest-dsvm-full-ubuntu-trusty,gate-tempest-dsvm-py35-ubuntu-xenial
will generate a graph like:
.. image:: graph-run_time_meta.png
:width: 115%
It's also worth noting the --filter_list argument used in the command above.
In some cases, especially larger data sets, there are too many distinct values
for a given run_metadata key to make the graph useful. To workaround this you
specify a list of values that will be used to filter the output so that only
matches of that key will be in the output.
subunit2sql-graph plugin interface
==================================

View File

@ -28,10 +28,16 @@ matplotlib.style.use('ggplot')
def set_cli_opts(parser):
parser.add_argument('metadata_key',
help="The run_metadata key to group the runs by")
parser.add_argument('--filter_list', '-f',
help='A comma seperated list of values to use')
def generate_series():
session = api.get_session()
if CONF.command.filter_list:
filter_list = CONF.command.filter_list.split(',')
else:
filter_list = None
if CONF.start_date:
start_date = datetime.datetime.strptime(CONF.start_date, '%Y-%m-%d')
else:
@ -43,8 +49,13 @@ def generate_series():
run_times = api.get_run_times_grouped_by_run_metadata_key(
CONF.command.metadata_key, start_date=start_date,
stop_date=stop_date, session=session)
df = pd.DataFrame(dict(
[(k, pd.Series(v)) for k, v in run_times.iteritems()]))
if not filter_list:
df = pd.DataFrame(dict(
[(k, pd.Series(v)) for k, v in run_times.iteritems()]))
else:
df = pd.DataFrame(dict(
[(k, pd.Series(v)) for k, v in run_times.iteritems()
if k in filter_list]))
if not CONF.title:
title = "Run aggregate run time grouped by metadata"
else: