- def _process_stats(data: list, param: str) -> list:
- """Process statistical data provided by plot.ly box graph.
-
- :param data: Statistical data provided by plot.ly box graph.
- :param param: Parameter saying if the data come from "tput" or
- "lat" graph.
- :type data: list
- :type param: str
- :returns: Listo of tuples where the first value is the
- statistic's name and the secont one it's value.
- :rtype: list
- """
- if len(data) == 7:
- stats = ("max", "upper fence", "q3", "median", "q1",
- "lower fence", "min")
- elif len(data) == 9:
- stats = ("outlier", "max", "upper fence", "q3", "median",
- "q1", "lower fence", "min", "outlier")
- elif len(data) == 1:
- if param == "lat":
- stats = ("average latency at 50% PDR", )
- elif param == "bandwidth":
- stats = ("bandwidth", )
- else:
- stats = ("throughput", )
- else:
- return list()
- unit = " [us]" if param == "lat" else str()
- return [(f"{stat}{unit}", f"{value['y']:,.0f}")
- for stat, value in zip(stats, data)]
-
- customdata = graph_data[0].get("customdata", dict())
- datapoint = customdata.get("metadata", dict())
- hdrh_data = customdata.get("hdrh", dict())
-
- list_group_items = list()
- for k, v in datapoint.items():
- if k == "csit-ref":
- if len(graph_data) > 1:
- continue
- list_group_item = dbc.ListGroupItem([
- dbc.Badge(k),
- html.A(v, href=f"{C.URL_JENKINS}{v}", target="_blank")
- ])
- else:
- list_group_item = dbc.ListGroupItem([dbc.Badge(k), v])
- list_group_items.append(list_group_item)
-
- graph = list()
- if trigger.idx == "tput":
- title = "Throughput"
- elif trigger.idx == "bandwidth":
- title = "Bandwidth"
- elif trigger.idx == "lat":
- title = "Latency"
- if len(graph_data) == 1:
- if hdrh_data:
- graph = [dbc.Card(
- class_name="gy-2 p-0",
- children=[
- dbc.CardHeader(hdrh_data.pop("name")),
- dbc.CardBody(dcc.Graph(
- id="hdrh-latency-graph",
- figure=graph_hdrh_latency(
- hdrh_data, self._graph_layout
- )
- ))
- ])
- ]
- else:
- raise PreventUpdate
-
- for k, v in _process_stats(graph_data, trigger.idx):
- list_group_items.append(dbc.ListGroupItem([dbc.Badge(k), v]))
-
- metadata = [
- dbc.Card(
- class_name="gy-2 p-0",
- children=[
- dbc.CardHeader(children=[
- dcc.Clipboard(
- target_id="tput-lat-metadata",
- title="Copy",
- style={"display": "inline-block"}
- ),
- title
- ]),
- dbc.CardBody(
- dbc.ListGroup(list_group_items, flush=True),
- id="tput-lat-metadata",
- class_name="p-0"
- )
- ]
- )
- ]
-
- return metadata, graph, True