Import some stuff
In [16]:
from lib import MongoBackend
from matplotlib import pyplot as plt
from matplotlib.pyplot import show
from collections import defaultdict
from pprint import pprint
backend = MongoBackend('master')
In [20]:
def get_timelines(experiment, query):
get_timeline=lambda d: d[0][1]
raw_timeline_data = backend.query(experiment, query )
metrics_timeline = get_timeline(raw_timeline_data)
metrics= defaultdict(list)
for m in metrics_timeline:
metrics['time'].append(m[0])
master_metrics = m[1]['master']
for k,v in master_metrics.iteritems():
metrics[k].append(v)
print metrics.keys()
# special cases
metrics['cpu']= map(lambda i: 100-i, metrics['cpu_idle'])
return metrics
def plot_timeline(subplot, x,y, title=None, xlabel=None, ylabel=None):
subplot.plot(x,y)
if title: subplot.set_title(title)
if ylabel: subplot.set_ylabel(ylabel)
if xlabel: subplot.set_xlabel(xlabel)
def plot_timelines(experiment, query):
tm = get_timelines(experiment,query)
f, (ax1,ax2) = plt.subplots(2, sharex=True)
plot_timeline(ax1,tm['time'], tm['mem_free'], "Free Memory", 'Time (sec)', 'GB')
plot_timeline(ax2, tm['time'], tm['cpu'],"CPU Utilization", None, '%')
plt.show()
plot_timelines('imr_w2v_vectorize',({"lines":1001000},{'metrics_timeline':1}) ) #failed
plot_timelines('imr_w2v_vectorize',({"lines":251000},{'metrics_timeline':1}) )
In [48]:
In [38]:
#backend.plot_query('imr_w2v_vectorize', ({},{'lines':1, 'time':1}))
In [ ]: