From 6e9dae785f1e0b6e4cd00757f46fa98413c5c306 Mon Sep 17 00:00:00 2001 From: Matthew Treinish Date: Sun, 11 Feb 2018 22:54:33 -0500 Subject: [PATCH] Add --dpi flag to subunit2sql-graph This commit adds a new flag, --dpi, to the subunit2sql-graph command. This flag is used to specify a DPI for generated graph images. Previously most graph commands hard coded the DPI to 900 (which is far too high for most people) and others didn't specify one. This commit changes that so it's user adjustable and consistent between all commands. Change-Id: I5c8c48bda18daff11d6069c35451d932ffe4e33b --- releasenotes/notes/dpi-cli-flag-64552fd0e10e5d91.yaml | 4 ++++ subunit2sql/analysis/agg_count.py | 2 +- subunit2sql/analysis/dailycount.py | 2 +- subunit2sql/analysis/failures.py | 2 +- subunit2sql/analysis/graph.py | 2 ++ subunit2sql/analysis/run_failure_rate.py | 2 +- subunit2sql/analysis/run_time.py | 2 +- subunit2sql/analysis/run_time_meta.py | 2 +- subunit2sql/analysis/test_run_time.py | 2 +- 9 files changed, 13 insertions(+), 7 deletions(-) create mode 100644 releasenotes/notes/dpi-cli-flag-64552fd0e10e5d91.yaml diff --git a/releasenotes/notes/dpi-cli-flag-64552fd0e10e5d91.yaml b/releasenotes/notes/dpi-cli-flag-64552fd0e10e5d91.yaml new file mode 100644 index 0000000..4345de2 --- /dev/null +++ b/releasenotes/notes/dpi-cli-flag-64552fd0e10e5d91.yaml @@ -0,0 +1,4 @@ +--- +features: + - Add a new CLI flag, --dpi, for subunit2sql-graph to adjust the output image + DPI for the generated graphs. diff --git a/subunit2sql/analysis/agg_count.py b/subunit2sql/analysis/agg_count.py index 49da590..149d637 100644 --- a/subunit2sql/analysis/agg_count.py +++ b/subunit2sql/analysis/agg_count.py @@ -78,4 +78,4 @@ def generate_series(): df = pd.DataFrame.from_dict(test_dict, orient='index') plot = df.plot(kind='barh', stacked=True).set_title(title) fig = plot.get_figure() - fig.savefig(CONF.output) + fig.savefig(CONF.output, dpi=CONF.dpi) diff --git a/subunit2sql/analysis/dailycount.py b/subunit2sql/analysis/dailycount.py index a520163..a0ef0b3 100644 --- a/subunit2sql/analysis/dailycount.py +++ b/subunit2sql/analysis/dailycount.py @@ -84,4 +84,4 @@ def generate_series(): upper_std_dev[10:], color='b', alpha=0.2, label='Std Dev') plt.legend() - plt.savefig(CONF.output, dpi=900) + plt.savefig(CONF.output, dpi=CONF.dpi) diff --git a/subunit2sql/analysis/failures.py b/subunit2sql/analysis/failures.py index dcdbb55..bb68ba8 100644 --- a/subunit2sql/analysis/failures.py +++ b/subunit2sql/analysis/failures.py @@ -75,5 +75,5 @@ def generate_series(): print('Success Percentage: %.4f%%' % percent(success_count, run_count)) print('Skip Percentage: %.4f%%' % percent(skip_count, run_count)) fig = plot.get_figure() - fig.savefig(CONF.output) + fig.savefig(CONF.output, dpi=CONF.dpi) return ts diff --git a/subunit2sql/analysis/graph.py b/subunit2sql/analysis/graph.py index 40a8eca..12848c2 100644 --- a/subunit2sql/analysis/graph.py +++ b/subunit2sql/analysis/graph.py @@ -43,6 +43,8 @@ SHELL_OPTS = [ cfg.StrOpt('stop-date', short='s', help='Stop date for the graph only data from before this date ' 'will be used. Uses ISO 8601 format: 1914-06-28'), + cfg.IntOpt('dpi', default=900, + help='Image DPI to use for the output graph images') ] diff --git a/subunit2sql/analysis/run_failure_rate.py b/subunit2sql/analysis/run_failure_rate.py index 2794fa1..f0dc37a 100644 --- a/subunit2sql/analysis/run_failure_rate.py +++ b/subunit2sql/analysis/run_failure_rate.py @@ -74,4 +74,4 @@ def generate_series(): locs, labels = plt.yticks(range(len(perc_data)), list(perc_data.keys())) plt.xlabel('Failure Percentage') plt.tight_layout() - plt.savefig(CONF.output, dpi=900) + plt.savefig(CONF.output, dpi=CONF.dpi) diff --git a/subunit2sql/analysis/run_time.py b/subunit2sql/analysis/run_time.py index e3a8a41..cc03c6f 100644 --- a/subunit2sql/analysis/run_time.py +++ b/subunit2sql/analysis/run_time.py @@ -79,5 +79,5 @@ def generate_series(): lower_std_dev, color='b', alpha=0.2, label='std dev') plt.legend() - plt.savefig(CONF.output, dpi=900) + plt.savefig(CONF.output, dpi=CONF.dpi) return ts diff --git a/subunit2sql/analysis/run_time_meta.py b/subunit2sql/analysis/run_time_meta.py index 561329c..88481b6 100644 --- a/subunit2sql/analysis/run_time_meta.py +++ b/subunit2sql/analysis/run_time_meta.py @@ -68,4 +68,4 @@ def generate_series(): df.plot(kind='box', rot=90) plt.ylabel('Time (sec.)') plt.tight_layout() - plt.savefig(CONF.output, dpi=900) + plt.savefig(CONF.output, dpi=CONF.dpi) diff --git a/subunit2sql/analysis/test_run_time.py b/subunit2sql/analysis/test_run_time.py index c5373fe..74c1fe3 100644 --- a/subunit2sql/analysis/test_run_time.py +++ b/subunit2sql/analysis/test_run_time.py @@ -63,4 +63,4 @@ def generate_series(): df.plot(kind='box', rot=90) plt.ylabel('Time (sec.)') plt.tight_layout() - plt.savefig(CONF.output, dpi=900) + plt.savefig(CONF.output, dpi=CONF.dpi)