Dailycount should not need build_queue to exist.

Dailycount assumes that there is a metadata item called build_queue
with value gate and if this does not exist in the database, the
tool will fail messily. This patch allows you to specify the md
key and value to be used.

Note, it also treats NAN data by filling with 0 - otherwise
the graph gets very confused.

Patch set 2 -
  Fixed pep8 issues.
  Fixed option ordering issue as per review comments.

Patch set 3 -
  Removed debug print statement.

Change-Id: I51baf2ee15d65e315c8142824fae13d964d9f973
Story: 2001034
This commit is contained in:
Gavin Brebner 2017-06-15 18:18:26 +02:00
parent de195d5b75
commit 80ff853795
1 changed files with 15 additions and 3 deletions

View File

@ -28,7 +28,17 @@ matplotlib.style.use('ggplot')
def set_cli_opts(parser):
pass
parser.add_argument('--dcmd_key', default='build_queue',
help="When running dailycount, the runs included are "
"filtered based on metadata. If one is not "
"provided, a default of \"build_queue\" is used "
"as the metadata key.")
parser.add_argument('--dcmd_value', default='gate',
help="When running dailycount, the runs included are "
"filtered based on metadata. This option "
"specifies the value that metadata should have. "
"If not specified, a default of \"gate\" is "
"used.")
def generate_series():
@ -43,10 +53,12 @@ def generate_series():
session = api.get_session()
test_starts = api.get_test_run_series(start_date=start_date,
stop_date=stop_date,
session=session)
session=session,
key=CONF.command.dcmd_key,
value=CONF.command.dcmd_value)
session.close()
ts = pd.Series(test_starts)
daily_count = ts.resample('D').sum()
daily_count = ts.resample('D').sum().fillna(value=0)
mean = daily_count.rolling(window=10, center=False).mean()
rolling_std = daily_count.rolling(window=10, center=False).std()
plt.figure()