+ for ttype in plot.get(u"test-type", (u"ndr", u"pdr")):
+ for core in plot.get(u"core", tuple()):
+ vals = dict()
+ for item in plot.get(u"include", tuple()):
+ reg_ex = re.compile(str(item.format(core=core)).lower())
+ for job in in_data:
+ for build in job:
+ for test_id, test in build.iteritems():
+ if not re.match(reg_ex, str(test_id).lower()):
+ continue
+ for tag in test[u"tags"]:
+ groups = re.search(regex_cn, tag)
+ if groups:
+ chain = str(groups.group(1))
+ node = str(groups.group(2))
+ break
+ else:
+ continue
+ groups = re.search(regex_test_name, test[u"name"])
+ if groups and len(groups.groups()) == 3:
+ hover_name = (
+ f"{str(groups.group(1))}-"
+ f"{str(groups.group(2))}-"
+ f"{str(groups.group(3))}"
+ )
+ else:
+ hover_name = u""
+ if vals.get(chain, None) is None:
+ vals[chain] = dict()
+ if vals[chain].get(node, None) is None:
+ vals[chain][node] = dict(
+ name=hover_name,
+ vals=list(),
+ nr=None,
+ mean=None,
+ stdev=None
+ )
+ try:
+ if ttype == u"mrr":
+ result = test[u"result"][u"receive-rate"]
+ elif ttype == u"pdr":
+ result = \
+ test[u"throughput"][u"PDR"][u"LOWER"]
+ elif ttype == u"ndr":
+ result = \
+ test[u"throughput"][u"NDR"][u"LOWER"]
+ else:
+ result = None
+ except TypeError:
+ result = None
+
+ if result:
+ vals[chain][node][u"vals"].append(result)
+
+ if not vals:
+ logging.error(u"No data.")
+ return
+
+ txt_chains = list()
+ txt_nodes = list()
+ for key_c in vals:
+ txt_chains.append(key_c)
+ for key_n in vals[key_c].keys():
+ txt_nodes.append(key_n)
+ if vals[key_c][key_n][u"vals"]:
+ vals[key_c][key_n][u"nr"] = \
+ len(vals[key_c][key_n][u"vals"])
+ vals[key_c][key_n][u"mean"] = \
+ round(mean(vals[key_c][key_n][u"vals"]) / 1e6, 1)
+ vals[key_c][key_n][u"stdev"] = \
+ round(stdev(vals[key_c][key_n][u"vals"]) / 1e6, 1)
+ txt_nodes = list(set(txt_nodes))
+
+ txt_chains = sorted(txt_chains, key=sort_by_int)
+ txt_nodes = sorted(txt_nodes, key=sort_by_int)
+
+ chains = [i + 1 for i in range(len(txt_chains))]
+ nodes = [i + 1 for i in range(len(txt_nodes))]
+
+ data = [list() for _ in range(len(chains))]
+ for chain in chains:
+ for node in nodes:
+ try:
+ val = vals[txt_chains[chain - 1]] \
+ [txt_nodes[node - 1]][u"mean"]
+ except (KeyError, IndexError):
+ val = None
+ data[chain - 1].append(val)
+
+ # Color scales:
+ my_green = [[0.0, u"rgb(235, 249, 242)"],
+ [1.0, u"rgb(45, 134, 89)"]]
+
+ my_blue = [[0.0, u"rgb(236, 242, 248)"],
+ [1.0, u"rgb(57, 115, 172)"]]
+
+ my_grey = [[0.0, u"rgb(230, 230, 230)"],
+ [1.0, u"rgb(102, 102, 102)"]]
+
+ hovertext = list()
+ annotations = list()
+
+ text = (u"Test: {name}<br>"
+ u"Runs: {nr}<br>"
+ u"Thput: {val}<br>"
+ u"StDev: {stdev}")
+
+ for chain, _ in enumerate(txt_chains):
+ hover_line = list()
+ for node, _ in enumerate(txt_nodes):
+ if data[chain][node] is not None:
+ annotations.append(
+ dict(
+ x=node+1,
+ y=chain+1,
+ xref=u"x",
+ yref=u"y",
+ xanchor=u"center",
+ yanchor=u"middle",
+ text=str(data[chain][node]),
+ font=dict(
+ size=14,
+ ),
+ align=u"center",
+ showarrow=False
+ )
+ )
+ hover_line.append(text.format(
+ name=vals[txt_chains[chain]][txt_nodes[node]]
+ [u"name"],
+ nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
+ val=data[chain][node],
+ stdev=vals[txt_chains[chain]][txt_nodes[node]]
+ [u"stdev"]
+ ))
+ hovertext.append(hover_line)
+
+ traces = [
+ plgo.Heatmap(
+ x=nodes,
+ y=chains,
+ z=data,
+ colorbar=dict(
+ title=plot.get(u"z-axis", u"{test_type}").
+ format(test_type=ttype.upper()),
+ titleside=u"right",
+ titlefont=dict(
+ size=16
+ ),
+ tickfont=dict(
+ size=16,
+ ),
+ tickformat=u".1f",
+ yanchor=u"bottom",
+ y=-0.02,
+ len=0.925,
+ ),
+ showscale=True,
+ colorscale=my_green,
+ text=hovertext,
+ hoverinfo=u"text"
+ )
+ ]
+
+ for idx, item in enumerate(txt_nodes):
+ # X-axis, numbers:
+ annotations.append(
+ dict(
+ x=idx+1,
+ y=0.05,
+ xref=u"x",
+ yref=u"y",
+ xanchor=u"center",
+ yanchor=u"top",
+ text=item,
+ font=dict(
+ size=16,
+ ),
+ align=u"center",
+ showarrow=False
+ )
+ )
+ for idx, item in enumerate(txt_chains):
+ # Y-axis, numbers:
+ annotations.append(
+ dict(
+ x=0.35,
+ y=idx+1,
+ xref=u"x",
+ yref=u"y",
+ xanchor=u"right",
+ yanchor=u"middle",
+ text=item,
+ font=dict(
+ size=16,
+ ),
+ align=u"center",
+ showarrow=False
+ )
+ )
+ # X-axis, title:
+ annotations.append(
+ dict(
+ x=0.55,
+ y=-0.15,
+ xref=u"paper",
+ yref=u"y",
+ xanchor=u"center",
+ yanchor=u"bottom",
+ text=plot.get(u"x-axis", u""),