1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Algorithms to generate plots.
21 from collections import OrderedDict
22 from copy import deepcopy
27 import plotly.offline as ploff
28 import plotly.graph_objs as plgo
30 from plotly.exceptions import PlotlyError
32 from pal_utils import mean, stdev
61 REGEX_NIC = re.compile(r'(\d*ge\dp\d\D*\d*[a-z]*)-')
64 def generate_plots(spec, data):
65 """Generate all plots specified in the specification file.
67 :param spec: Specification read from the specification file.
68 :param data: Data to process.
69 :type spec: Specification
74 u"plot_nf_reconf_box_name": plot_nf_reconf_box_name,
75 u"plot_perf_box_name": plot_perf_box_name,
76 u"plot_tsa_name": plot_tsa_name,
77 u"plot_http_server_perf_box": plot_http_server_perf_box,
78 u"plot_nf_heatmap": plot_nf_heatmap,
79 u"plot_hdrh_lat_by_percentile": plot_hdrh_lat_by_percentile
82 logging.info(u"Generating the plots ...")
83 for index, plot in enumerate(spec.plots):
85 logging.info(f" Plot nr {index + 1}: {plot.get(u'title', u'')}")
86 plot[u"limits"] = spec.configuration[u"limits"]
87 generator[plot[u"algorithm"]](plot, data)
88 logging.info(u" Done.")
89 except NameError as err:
91 f"Probably algorithm {plot[u'algorithm']} is not defined: "
94 logging.info(u"Done.")
97 def plot_hdrh_lat_by_percentile(plot, input_data):
98 """Generate the plot(s) with algorithm: plot_hdrh_lat_by_percentile
99 specified in the specification file.
101 :param plot: Plot to generate.
102 :param input_data: Data to process.
103 :type plot: pandas.Series
104 :type input_data: InputData
109 f" Creating the data set for the {plot.get(u'type', u'')} "
110 f"{plot.get(u'title', u'')}."
112 if plot.get(u"include", None):
113 data = input_data.filter_tests_by_name(
115 params=[u"name", u"latency", u"parent", u"tags", u"type"]
117 elif plot.get(u"filter", None):
118 data = input_data.filter_data(
120 params=[u"name", u"latency", u"parent", u"tags", u"type"],
121 continue_on_error=True
124 job = list(plot[u"data"].keys())[0]
125 build = str(plot[u"data"][job][0])
126 data = input_data.tests(job, build)
128 if data is None or len(data) == 0:
129 logging.error(u"No data.")
133 u"LAT0": u"No-load.",
134 u"PDR10": u"Low-load, 10% PDR.",
135 u"PDR50": u"Mid-load, 50% PDR.",
136 u"PDR90": u"High-load, 90% PDR.",
137 u"PDR": u"Full-load, 100% PDR.",
138 u"NDR10": u"Low-load, 10% NDR.",
139 u"NDR50": u"Mid-load, 50% NDR.",
140 u"NDR90": u"High-load, 90% NDR.",
141 u"NDR": u"Full-load, 100% NDR."
151 file_links = plot.get(u"output-file-links", None)
152 target_links = plot.get(u"target-links", None)
156 if test[u"type"] not in (u"NDRPDR",):
157 logging.warning(f"Invalid test type: {test[u'type']}")
159 name = re.sub(REGEX_NIC, u"", test[u"parent"].
160 replace(u'-ndrpdr', u'').replace(u'2n1l-', u''))
162 nic = re.search(REGEX_NIC, test[u"parent"]).group(1)
163 except (IndexError, AttributeError, KeyError, ValueError):
165 name_link = f"{nic}-{test[u'name']}".replace(u'-ndrpdr', u'')
167 logging.info(f" Generating the graph: {name_link}")
170 layout = deepcopy(plot[u"layout"])
172 for color, graph in enumerate(graphs):
173 for idx, direction in enumerate((u"direction1", u"direction2")):
177 f"<b>{desc[graph]}</b><br>"
178 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
179 f"Percentile: 0.0%<br>"
182 decoded = hdrh.histogram.HdrHistogram.decode(
183 test[u"latency"][graph][direction][u"hdrh"]
185 for item in decoded.get_recorded_iterator():
186 percentile = item.percentile_level_iterated_to
187 if percentile > 99.9:
189 xaxis.append(percentile)
190 yaxis.append(item.value_iterated_to)
192 f"<b>{desc[graph]}</b><br>"
193 f"Direction: {(u'W-E', u'E-W')[idx % 2]}<br>"
194 f"Percentile: {percentile:.5f}%<br>"
195 f"Latency: {item.value_iterated_to}uSec"
203 legendgroup=desc[graph],
204 showlegend=bool(idx),
207 dash=u"solid" if idx % 2 else u"dash"
214 layout[u"title"][u"text"] = f"<b>Latency:</b> {name}"
215 fig.update_layout(layout)
218 file_name = f"{plot[u'output-file']}-{name_link}.html"
219 logging.info(f" Writing file {file_name}")
223 ploff.plot(fig, show_link=False, auto_open=False,
225 # Add link to the file:
226 if file_links and target_links:
227 with open(file_links, u"a") as file_handler:
230 f"<{target_links}/{file_name.split(u'/')[-1]}>`_\n"
232 except FileNotFoundError as err:
234 f"Not possible to write the link to the file "
235 f"{file_links}\n{err}"
237 except PlotlyError as err:
238 logging.error(f" Finished with error: {repr(err)}")
240 except hdrh.codec.HdrLengthException as err:
241 logging.warning(repr(err))
244 except (ValueError, KeyError) as err:
245 logging.warning(repr(err))
249 def plot_nf_reconf_box_name(plot, input_data):
250 """Generate the plot(s) with algorithm: plot_nf_reconf_box_name
251 specified in the specification file.
253 :param plot: Plot to generate.
254 :param input_data: Data to process.
255 :type plot: pandas.Series
256 :type input_data: InputData
261 f" Creating the data set for the {plot.get(u'type', u'')} "
262 f"{plot.get(u'title', u'')}."
264 data = input_data.filter_tests_by_name(
265 plot, params=[u"result", u"parent", u"tags", u"type"]
268 logging.error(u"No data.")
271 # Prepare the data for the plot
272 y_vals = OrderedDict()
277 if y_vals.get(test[u"parent"], None) is None:
278 y_vals[test[u"parent"]] = list()
279 loss[test[u"parent"]] = list()
281 y_vals[test[u"parent"]].append(test[u"result"][u"time"])
282 loss[test[u"parent"]].append(test[u"result"][u"loss"])
283 except (KeyError, TypeError):
284 y_vals[test[u"parent"]].append(None)
286 # Add None to the lists with missing data
288 nr_of_samples = list()
289 for val in y_vals.values():
290 if len(val) > max_len:
292 nr_of_samples.append(len(val))
293 for val in y_vals.values():
294 if len(val) < max_len:
295 val.extend([None for _ in range(max_len - len(val))])
299 df_y = pd.DataFrame(y_vals)
301 for i, col in enumerate(df_y.columns):
302 tst_name = re.sub(REGEX_NIC, u"",
303 col.lower().replace(u'-ndrpdr', u'').
304 replace(u'2n1l-', u''))
306 traces.append(plgo.Box(
307 x=[str(i + 1) + u'.'] * len(df_y[col]),
308 y=[y if y else None for y in df_y[col]],
311 f"({nr_of_samples[i]:02d} "
312 f"run{u's' if nr_of_samples[i] > 1 else u''}, "
313 f"packets lost average: {mean(loss[col]):.1f}) "
314 f"{u'-'.join(tst_name.split(u'-')[3:-2])}"
320 layout = deepcopy(plot[u"layout"])
321 layout[u"title"] = f"<b>Time Lost:</b> {layout[u'title']}"
322 layout[u"yaxis"][u"title"] = u"<b>Implied Time Lost [s]</b>"
323 layout[u"legend"][u"font"][u"size"] = 14
324 layout[u"yaxis"].pop(u"range")
325 plpl = plgo.Figure(data=traces, layout=layout)
328 file_type = plot.get(u"output-file-type", u".html")
329 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
334 filename=f"{plot[u'output-file']}{file_type}"
336 except PlotlyError as err:
338 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
343 def plot_perf_box_name(plot, input_data):
344 """Generate the plot(s) with algorithm: plot_perf_box_name
345 specified in the specification file.
347 :param plot: Plot to generate.
348 :param input_data: Data to process.
349 :type plot: pandas.Series
350 :type input_data: InputData
355 f" Creating data set for the {plot.get(u'type', u'')} "
356 f"{plot.get(u'title', u'')}."
358 data = input_data.filter_tests_by_name(
359 plot, params=[u"throughput", u"result", u"parent", u"tags", u"type"])
361 logging.error(u"No data.")
364 # Prepare the data for the plot
365 y_vals = OrderedDict()
370 if y_vals.get(test[u"parent"], None) is None:
371 y_vals[test[u"parent"]] = list()
373 if (test[u"type"] in (u"NDRPDR", ) and
374 u"-pdr" in plot.get(u"title", u"").lower()):
375 y_vals[test[u"parent"]].\
376 append(test[u"throughput"][u"PDR"][u"LOWER"])
377 test_type = u"NDRPDR"
378 elif (test[u"type"] in (u"NDRPDR", ) and
379 u"-ndr" in plot.get(u"title", u"").lower()):
380 y_vals[test[u"parent"]]. \
381 append(test[u"throughput"][u"NDR"][u"LOWER"])
382 test_type = u"NDRPDR"
383 elif test[u"type"] in (u"SOAK", ):
384 y_vals[test[u"parent"]].\
385 append(test[u"throughput"][u"LOWER"])
387 elif test[u"type"] in (u"HOSTSTACK", ):
388 if u"LDPRELOAD" in test[u"tags"]:
389 y_vals[test[u"parent"]].append(
390 float(test[u"result"][u"bits_per_second"]) / 1e3
392 elif u"VPPECHO" in test[u"tags"]:
393 y_vals[test[u"parent"]].append(
394 (float(test[u"result"][u"client"][u"tx_data"])
396 ((float(test[u"result"][u"client"][u"time"]) +
397 float(test[u"result"][u"server"][u"time"])) /
400 test_type = u"HOSTSTACK"
403 except (KeyError, TypeError):
404 y_vals[test[u"parent"]].append(None)
406 # Add None to the lists with missing data
408 nr_of_samples = list()
409 for val in y_vals.values():
410 if len(val) > max_len:
412 nr_of_samples.append(len(val))
413 for val in y_vals.values():
414 if len(val) < max_len:
415 val.extend([None for _ in range(max_len - len(val))])
419 df_y = pd.DataFrame(y_vals)
422 for i, col in enumerate(df_y.columns):
423 tst_name = re.sub(REGEX_NIC, u"",
424 col.lower().replace(u'-ndrpdr', u'').
425 replace(u'2n1l-', u''))
427 x=[str(i + 1) + u'.'] * len(df_y[col]),
428 y=[y / 1e6 if y else None for y in df_y[col]],
431 f"({nr_of_samples[i]:02d} "
432 f"run{u's' if nr_of_samples[i] > 1 else u''}) "
437 if test_type in (u"SOAK", ):
438 kwargs[u"boxpoints"] = u"all"
440 traces.append(plgo.Box(**kwargs))
443 val_max = max(df_y[col])
445 y_max.append(int(val_max / 1e6) + 2)
446 except (ValueError, TypeError) as err:
447 logging.error(repr(err))
452 layout = deepcopy(plot[u"layout"])
453 if layout.get(u"title", None):
454 if test_type in (u"HOSTSTACK", ):
455 layout[u"title"] = f"<b>Bandwidth:</b> {layout[u'title']}"
457 layout[u"title"] = f"<b>Throughput:</b> {layout[u'title']}"
459 layout[u"yaxis"][u"range"] = [0, max(y_max)]
460 plpl = plgo.Figure(data=traces, layout=layout)
463 logging.info(f" Writing file {plot[u'output-file']}.html.")
468 filename=f"{plot[u'output-file']}.html"
470 except PlotlyError as err:
472 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
477 def plot_tsa_name(plot, input_data):
478 """Generate the plot(s) with algorithm:
480 specified in the specification file.
482 :param plot: Plot to generate.
483 :param input_data: Data to process.
484 :type plot: pandas.Series
485 :type input_data: InputData
489 plot_title = plot.get(u"title", u"")
491 f" Creating data set for the {plot.get(u'type', u'')} {plot_title}."
493 data = input_data.filter_tests_by_name(
494 plot, params=[u"throughput", u"parent", u"tags", u"type"])
496 logging.error(u"No data.")
499 y_vals = OrderedDict()
503 if y_vals.get(test[u"parent"], None) is None:
504 y_vals[test[u"parent"]] = {
510 if test[u"type"] not in (u"NDRPDR",):
513 if u"-pdr" in plot_title.lower():
515 elif u"-ndr" in plot_title.lower():
520 if u"1C" in test[u"tags"]:
521 y_vals[test[u"parent"]][u"1"]. \
522 append(test[u"throughput"][ttype][u"LOWER"])
523 elif u"2C" in test[u"tags"]:
524 y_vals[test[u"parent"]][u"2"]. \
525 append(test[u"throughput"][ttype][u"LOWER"])
526 elif u"4C" in test[u"tags"]:
527 y_vals[test[u"parent"]][u"4"]. \
528 append(test[u"throughput"][ttype][u"LOWER"])
529 except (KeyError, TypeError):
533 logging.warning(f"No data for the plot {plot.get(u'title', u'')}")
537 for test_name, test_vals in y_vals.items():
538 for key, test_val in test_vals.items():
540 avg_val = sum(test_val) / len(test_val)
541 y_vals[test_name][key] = [avg_val, len(test_val)]
542 ideal = avg_val / (int(key) * 1e6)
543 if test_name not in y_1c_max or ideal > y_1c_max[test_name]:
544 y_1c_max[test_name] = ideal
550 pci_limit = plot[u"limits"][u"pci"][u"pci-g3-x8"]
551 for test_name, test_vals in y_vals.items():
553 if test_vals[u"1"][1]:
557 test_name.replace(u'-ndrpdr', u'').replace(u'2n1l-', u'')
559 vals[name] = OrderedDict()
560 y_val_1 = test_vals[u"1"][0] / 1e6
561 y_val_2 = test_vals[u"2"][0] / 1e6 if test_vals[u"2"][0] \
563 y_val_4 = test_vals[u"4"][0] / 1e6 if test_vals[u"4"][0] \
566 vals[name][u"val"] = [y_val_1, y_val_2, y_val_4]
567 vals[name][u"rel"] = [1.0, None, None]
568 vals[name][u"ideal"] = [
570 y_1c_max[test_name] * 2,
571 y_1c_max[test_name] * 4
573 vals[name][u"diff"] = [
574 (y_val_1 - y_1c_max[test_name]) * 100 / y_val_1, None, None
576 vals[name][u"count"] = [
583 val_max = max(vals[name][u"val"])
584 except ValueError as err:
585 logging.error(repr(err))
588 y_max.append(val_max)
591 vals[name][u"rel"][1] = round(y_val_2 / y_val_1, 2)
592 vals[name][u"diff"][1] = \
593 (y_val_2 - vals[name][u"ideal"][1]) * 100 / y_val_2
595 vals[name][u"rel"][2] = round(y_val_4 / y_val_1, 2)
596 vals[name][u"diff"][2] = \
597 (y_val_4 - vals[name][u"ideal"][2]) * 100 / y_val_4
598 except IndexError as err:
599 logging.warning(f"No data for {test_name}")
600 logging.warning(repr(err))
603 if u"x520" in test_name:
604 limit = plot[u"limits"][u"nic"][u"x520"]
605 elif u"x710" in test_name:
606 limit = plot[u"limits"][u"nic"][u"x710"]
607 elif u"xxv710" in test_name:
608 limit = plot[u"limits"][u"nic"][u"xxv710"]
609 elif u"xl710" in test_name:
610 limit = plot[u"limits"][u"nic"][u"xl710"]
611 elif u"x553" in test_name:
612 limit = plot[u"limits"][u"nic"][u"x553"]
613 elif u"cx556a" in test_name:
614 limit = plot[u"limits"][u"nic"][u"cx556a"]
617 if limit > nic_limit:
620 mul = 2 if u"ge2p" in test_name else 1
621 if u"10ge" in test_name:
622 limit = plot[u"limits"][u"link"][u"10ge"] * mul
623 elif u"25ge" in test_name:
624 limit = plot[u"limits"][u"link"][u"25ge"] * mul
625 elif u"40ge" in test_name:
626 limit = plot[u"limits"][u"link"][u"40ge"] * mul
627 elif u"100ge" in test_name:
628 limit = plot[u"limits"][u"link"][u"100ge"] * mul
631 if limit > lnk_limit:
640 threshold = 1.1 * max(y_max) # 10%
641 except ValueError as err:
645 traces.append(plgo.Scatter(
647 y=[nic_limit, ] * len(x_vals),
648 name=f"NIC: {nic_limit:.2f}Mpps",
657 annotations.append(dict(
664 text=f"NIC: {nic_limit:.2f}Mpps",
672 y_max.append(nic_limit)
675 if lnk_limit < threshold:
676 traces.append(plgo.Scatter(
678 y=[lnk_limit, ] * len(x_vals),
679 name=f"Link: {lnk_limit:.2f}Mpps",
688 annotations.append(dict(
695 text=f"Link: {lnk_limit:.2f}Mpps",
703 y_max.append(lnk_limit)
706 if (pci_limit < threshold and
707 (pci_limit < lnk_limit * 0.95 or lnk_limit > lnk_limit * 1.05)):
708 traces.append(plgo.Scatter(
710 y=[pci_limit, ] * len(x_vals),
711 name=f"PCIe: {pci_limit:.2f}Mpps",
720 annotations.append(dict(
727 text=f"PCIe: {pci_limit:.2f}Mpps",
735 y_max.append(pci_limit)
737 # Perfect and measured:
739 for name, val in vals.items():
742 for idx in range(len(val[u"val"])):
744 if isinstance(val[u"val"][idx], float):
746 f"No. of Runs: {val[u'count'][idx]}<br>"
747 f"Mean: {val[u'val'][idx]:.2f}Mpps<br>"
749 if isinstance(val[u"diff"][idx], float):
750 htext += f"Diff: {round(val[u'diff'][idx]):.0f}%<br>"
751 if isinstance(val[u"rel"][idx], float):
752 htext += f"Speedup: {val[u'rel'][idx]:.2f}"
753 hovertext.append(htext)
760 mode=u"lines+markers",
769 hoverinfo=u"text+name"
776 name=f"{name} perfect",
784 text=[f"Perfect: {y:.2f}Mpps" for y in val[u"ideal"]],
789 except (IndexError, ValueError, KeyError) as err:
790 logging.warning(f"No data for {name}\n{repr(err)}")
794 file_type = plot.get(u"output-file-type", u".html")
795 logging.info(f" Writing file {plot[u'output-file']}{file_type}.")
796 layout = deepcopy(plot[u"layout"])
797 if layout.get(u"title", None):
798 layout[u"title"] = f"<b>Speedup Multi-core:</b> {layout[u'title']}"
799 layout[u"yaxis"][u"range"] = [0, int(max(y_max) * 1.1)]
800 layout[u"annotations"].extend(annotations)
801 plpl = plgo.Figure(data=traces, layout=layout)
808 filename=f"{plot[u'output-file']}{file_type}"
810 except PlotlyError as err:
812 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
817 def plot_http_server_perf_box(plot, input_data):
818 """Generate the plot(s) with algorithm: plot_http_server_perf_box
819 specified in the specification file.
821 :param plot: Plot to generate.
822 :param input_data: Data to process.
823 :type plot: pandas.Series
824 :type input_data: InputData
829 f" Creating the data set for the {plot.get(u'type', u'')} "
830 f"{plot.get(u'title', u'')}."
832 data = input_data.filter_data(plot)
834 logging.error(u"No data.")
837 # Prepare the data for the plot
842 if y_vals.get(test[u"name"], None) is None:
843 y_vals[test[u"name"]] = list()
845 y_vals[test[u"name"]].append(test[u"result"])
846 except (KeyError, TypeError):
847 y_vals[test[u"name"]].append(None)
849 # Add None to the lists with missing data
851 nr_of_samples = list()
852 for val in y_vals.values():
853 if len(val) > max_len:
855 nr_of_samples.append(len(val))
856 for val in y_vals.values():
857 if len(val) < max_len:
858 val.extend([None for _ in range(max_len - len(val))])
862 df_y = pd.DataFrame(y_vals)
864 for i, col in enumerate(df_y.columns):
867 f"({nr_of_samples[i]:02d} " \
868 f"run{u's' if nr_of_samples[i] > 1 else u''}) " \
869 f"{col.lower().replace(u'-ndrpdr', u'')}"
871 name_lst = name.split(u'-')
874 for segment in name_lst:
875 if (len(name) + len(segment) + 1) > 50 and split_name:
878 name += segment + u'-'
881 traces.append(plgo.Box(x=[str(i + 1) + u'.'] * len(df_y[col]),
887 plpl = plgo.Figure(data=traces, layout=plot[u"layout"])
891 f" Writing file {plot[u'output-file']}"
892 f"{plot[u'output-file-type']}."
898 filename=f"{plot[u'output-file']}{plot[u'output-file-type']}"
900 except PlotlyError as err:
902 f" Finished with error: {repr(err)}".replace(u"\n", u" ")
907 def plot_nf_heatmap(plot, input_data):
908 """Generate the plot(s) with algorithm: plot_nf_heatmap
909 specified in the specification file.
911 :param plot: Plot to generate.
912 :param input_data: Data to process.
913 :type plot: pandas.Series
914 :type input_data: InputData
917 regex_cn = re.compile(r'^(\d*)R(\d*)C$')
918 regex_test_name = re.compile(r'^.*-(\d+ch|\d+pl)-'
920 r'(\d+vm\d+t|\d+dcr\d+t|\d+dcr\d+c).*$')
925 f" Creating the data set for the {plot.get(u'type', u'')} "
926 f"{plot.get(u'title', u'')}."
928 data = input_data.filter_data(plot, continue_on_error=True)
929 if data is None or data.empty:
930 logging.error(u"No data.")
936 for tag in test[u"tags"]:
937 groups = re.search(regex_cn, tag)
939 chain = str(groups.group(1))
940 node = str(groups.group(2))
944 groups = re.search(regex_test_name, test[u"name"])
945 if groups and len(groups.groups()) == 3:
947 f"{str(groups.group(1))}-"
948 f"{str(groups.group(2))}-"
949 f"{str(groups.group(3))}"
953 if vals.get(chain, None) is None:
955 if vals[chain].get(node, None) is None:
956 vals[chain][node] = dict(
964 if plot[u"include-tests"] == u"MRR":
965 result = test[u"result"][u"receive-rate"]
966 elif plot[u"include-tests"] == u"PDR":
967 result = test[u"throughput"][u"PDR"][u"LOWER"]
968 elif plot[u"include-tests"] == u"NDR":
969 result = test[u"throughput"][u"NDR"][u"LOWER"]
976 vals[chain][node][u"vals"].append(result)
979 logging.error(u"No data.")
985 txt_chains.append(key_c)
986 for key_n in vals[key_c].keys():
987 txt_nodes.append(key_n)
988 if vals[key_c][key_n][u"vals"]:
989 vals[key_c][key_n][u"nr"] = len(vals[key_c][key_n][u"vals"])
990 vals[key_c][key_n][u"mean"] = \
991 round(mean(vals[key_c][key_n][u"vals"]) / 1000000, 1)
992 vals[key_c][key_n][u"stdev"] = \
993 round(stdev(vals[key_c][key_n][u"vals"]) / 1000000, 1)
994 txt_nodes = list(set(txt_nodes))
996 def sort_by_int(value):
997 """Makes possible to sort a list of strings which represent integers.
999 :param value: Integer as a string.
1001 :returns: Integer representation of input parameter 'value'.
1006 txt_chains = sorted(txt_chains, key=sort_by_int)
1007 txt_nodes = sorted(txt_nodes, key=sort_by_int)
1009 chains = [i + 1 for i in range(len(txt_chains))]
1010 nodes = [i + 1 for i in range(len(txt_nodes))]
1012 data = [list() for _ in range(len(chains))]
1013 for chain in chains:
1016 val = vals[txt_chains[chain - 1]][txt_nodes[node - 1]][u"mean"]
1017 except (KeyError, IndexError):
1019 data[chain - 1].append(val)
1022 my_green = [[0.0, u"rgb(235, 249, 242)"],
1023 [1.0, u"rgb(45, 134, 89)"]]
1025 my_blue = [[0.0, u"rgb(236, 242, 248)"],
1026 [1.0, u"rgb(57, 115, 172)"]]
1028 my_grey = [[0.0, u"rgb(230, 230, 230)"],
1029 [1.0, u"rgb(102, 102, 102)"]]
1032 annotations = list()
1034 text = (u"Test: {name}<br>"
1039 for chain, _ in enumerate(txt_chains):
1041 for node, _ in enumerate(txt_nodes):
1042 if data[chain][node] is not None:
1051 text=str(data[chain][node]),
1059 hover_line.append(text.format(
1060 name=vals[txt_chains[chain]][txt_nodes[node]][u"name"],
1061 nr=vals[txt_chains[chain]][txt_nodes[node]][u"nr"],
1062 val=data[chain][node],
1063 stdev=vals[txt_chains[chain]][txt_nodes[node]][u"stdev"]))
1064 hovertext.append(hover_line)
1072 title=plot.get(u"z-axis", u""),
1086 colorscale=my_green,
1092 for idx, item in enumerate(txt_nodes):
1110 for idx, item in enumerate(txt_chains):
1137 text=plot.get(u"x-axis", u""),
1154 text=plot.get(u"y-axis", u""),
1163 updatemenus = list([
1174 u"colorscale": [my_green, ],
1175 u"reversescale": False
1184 u"colorscale": [my_blue, ],
1185 u"reversescale": False
1194 u"colorscale": [my_grey, ],
1195 u"reversescale": False
1206 layout = deepcopy(plot[u"layout"])
1207 except KeyError as err:
1208 logging.error(f"Finished with error: No layout defined\n{repr(err)}")
1211 layout[u"annotations"] = annotations
1212 layout[u'updatemenus'] = updatemenus
1216 plpl = plgo.Figure(data=traces, layout=layout)
1219 logging.info(f" Writing file {plot[u'output-file']}.html")
1224 filename=f"{plot[u'output-file']}.html"
1226 except PlotlyError as err:
1228 f" Finished with error: {repr(err)}".replace(u"\n", u" ")