Skip to content

Commit

Permalink
Use mosaic to calculate epic progress
Browse files Browse the repository at this point in the history
The factory team has begun working on epics to increase the team's
velocity. These epics have specific goals around increasing or
decreasing a key metric by X percent. We'd like to report on progress on
these epics by calculating the current metric number as a percentage of
the goal.

We've developed a tool, mosaic, that calculates the values of the key
metrics we wish to track on. This tool can be found at [1]

When generating reports using finishline, we want to have the progress
percentage for these epics calculated using mosaic. This change enables
this functionality. I've added a new argument '--mosaic-config' to the
finshline script. When this argument is present, finishline will parse
the specified config file to determine which issues to use mosaic for,
as well as to determine how to calculate progress. If the argument is
not specified, finishline behaves as normal.

[1] https://github.com/accorvin/jira-mosaic
  • Loading branch information
accorvin committed Mar 27, 2018
1 parent 6913f30 commit 55bbe67
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Makefile.factory
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ buildstatus: install
--subtitle "$(shell date '+%B %d, %Y') — PnT DevOps" \
--attribution \
--references threebean/references.md \
--template threebean/slides.md > foo.md # \
--template threebean/slides.md > foo.md \
--mosaic-config configs/mosaic_config.Factory # \
#--since "$(shell date -d '1 month ago' '+%Y-%m-%d')" \

uploadstatus: buildstatus
Expand Down Expand Up @@ -70,5 +71,6 @@ buildemail: install
--subtitle "$(shell date '+%B %d, %Y') — PnT DevOps" \
--references threebean/references.md \
--attribution \
--template threebean/email.md > report-$(shell date '+%F').md #
--template threebean/email.md > report-$(shell date '+%F').md \
--mosaic-config configs/mosaic_config.Factory # \
#--since "$(shell date -d '1 month ago' '+%Y-%m-%d')" \
20 changes: 20 additions & 0 deletions configs/mosaic_config.Factory
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[mosaic]
mosaic_issues=FACTORY-1940,FACTORY-1942,FACTORY-1944
baseline_start=2017-12-01
baseline_end=2018-02-28
current_period_start=2018-03-01
current_period_end=2018-05-31

[FACTORY-1940]
query=prioritycycletime
query_argument=Critical
target=-20%

[FACTORY-1942]
query=cycletime
target=-10%

[FACTORY-1944]
query=statusduration
query_argument=Internal Deployment
target=-20%
66 changes: 66 additions & 0 deletions finishline
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import re
import six
import sys

from mosaic import mosaic

try:
import configparser
except ImportError:
Expand Down Expand Up @@ -117,6 +119,8 @@ def parse_arguments():
default='Miscellaneous')
parser.add_argument('--attribution', help='Show attribution for status.',
default=False, action='store_true')
parser.add_argument('--mosaic-config',
help='Path to config file for mosaic options')
args = parser.parse_args()

# Manually check requirements so that we may use defaults from a file
Expand Down Expand Up @@ -301,6 +305,63 @@ def get_epic_details(client, args, key):
return epic


def _run_mosaic(args, start_date, end_date):
args['begin_date'] = start_date
args['end_date'] = end_date
return mosaic.run(args, client)

def _calculate_mosaic_progress(baseline, current, target):
delta_begin_index = 0
if target[0] == '-':
operator = '-'
delta_begin_index = 1
else:
operator = '+'

if target[-1] == '%':
delta = '.' + target[delta_begin_index:-1]
delta = float(delta) * baseline
else:
delta = target[delta_begin_index:]
delta = float(delta)

if operator == '-':
status = (baseline - current) / delta
else:
status = (current - baseline) / delta

return '{0:0.1f}'.format(status * 100)


def get_mosaic_status(epics, project, jira_client, mosaic_config):
mosaic_config = configparser.ConfigParser()
mosaic_config.read([args.mosaic_config])
mosaic_config = mosaic_config._sections
mosaic_issues = mosaic_config['mosaic'].get('mosaic_issues', '')
print(('Mosaic will be used to determine status for the following '
'issues: {issues}').format(issues=mosaic_issues), file=sys.stderr)
mosaic_args = {
'auto_mode': True,
'project': project,
}
baseline_start = mosaic_config['mosaic']['baseline_start']
baseline_end = mosaic_config['mosaic']['baseline_end']
current_start = mosaic_config['mosaic']['current_period_start']
current_end = mosaic_config['mosaic']['current_period_end']
for issue in mosaic_issues.split(','):
print(('Executing mosaic to get status for '
'issue {0}').format(issue), file=sys.stderr)
assert issue in mosaic_config
issue_config = mosaic_config[issue]
mosaic_args['query'] = [issue_config['query']]
mosaic_args['query_argument'] = issue_config.get('query_argument', '')
baseline = _run_mosaic(mosaic_args, baseline_start, baseline_end)
current = _run_mosaic(mosaic_args, current_start, current_end)
progress = _calculate_mosaic_progress(float(baseline), float(current),
issue_config['target'])
epics[issue].percent_complete = progress


def collate_issues(client, args, issues):
epics = {}
objectives = collections.defaultdict(set)
Expand Down Expand Up @@ -395,6 +456,11 @@ if __name__ == '__main__':
client = jira.client.JIRA(**client_kwargs)
issues = pull_issues(client, args)
data = collate_issues(client, args, issues)
if args.mosaic_config:
print(('Mosaic config argument specified. Automatically '
'calculating completion percentage for configured '
'issues.'), file=sys.stderr)
get_mosaic_status(data['epics'], args.project, client, args.mosaic_config)
output = render(args.template, args, data)
if isinstance(output, six.text_type):
output = output.encode('utf-8')
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ jinja2
jira
requests_kerberos
pbr
git+git://github.com/accorvin/jira-mosaic.git

0 comments on commit 55bbe67

Please sign in to comment.