X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a143375dc725aa517c091c6826bf37b4caa69161..0b4945244d55214b331adabce38e33800b55b3e1:/tools/crunchstat-summary/crunchstat_summary/dygraphs.py diff --git a/tools/crunchstat-summary/crunchstat_summary/dygraphs.py b/tools/crunchstat-summary/crunchstat_summary/dygraphs.py index e72832eb5e..10f1f26f46 100644 --- a/tools/crunchstat-summary/crunchstat_summary/dygraphs.py +++ b/tools/crunchstat-summary/crunchstat_summary/dygraphs.py @@ -8,26 +8,39 @@ import crunchstat_summary.webchart class DygraphsChart(crunchstat_summary.webchart.WebChart): CSS = 'https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.css' JSLIB = 'https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.js' - JSASSET = 'dygraphs.js' + JSASSETS = ['synchronizer.js','dygraphs.js'] def headHTML(self): return '\n'.format(self.CSS) - def chartdata(self, label, tasks, stat): + def chartdata(self, label, tasks, stats): + '''For Crunch2, label is the name of container request, + tasks is the top level container and + stats is index by a tuple of (category, metric). + ''' return { - 'data': self._collate_data(tasks, stat), + 'data': self._collate_data(tasks, stats), 'options': { + 'legend': 'always', 'connectSeparatedPoints': True, - 'labels': ['elapsed']+[uuid for uuid, _ in tasks.iteritems()], - 'title': '{}: {} {}'.format(label, stat[0], stat[1]), + 'labels': ['elapsed'] + stats[1], + 'title': '{}: {}'.format(label, stats[0]), }, } - def _collate_data(self, tasks, stat): + def _collate_data(self, tasks, stats): data = [] nulls = [] - for uuid, task in tasks.iteritems(): - for pt in task.series[stat]: - data.append([pt[0].total_seconds()] + nulls + [pt[1]]) + # uuid is category for crunch2 + for uuid, task in tasks.items(): + # All stats in a category are assumed to have the same time base and same number of samples + category = stats[0] + series_names = stats[1] + sn0 = series_names[0] + series = task.series[(category,sn0)] + for i in range(len(series)): + pt = series[i] + vals = [task.series[(category,stat)][i][1] for stat in series_names[1:]] + data.append([pt[0].total_seconds()] + nulls + [pt[1]] + vals) nulls.append(None) return sorted(data)