result_type = result_node["type"]
if result_type == "unknown":
# Device or something else not supported.
- # Also could be MRR with all trials negative, write as a failure.
- self.data["passed"] = False
- self.data["message"] = "No result exported."
- # TODO: Raise real Robot error after writing this JSON.
return
# Compute avg and stdev for mrr (rate and bandwidth).
bandwidth_unit="bps"):
"""Store mrr value to proper place so it is dumped into json.
- Raises an error if the arguments would lead to invalid json.
+ The value is appended only when unit is not empty.
:param mrr_value: Forwarding rate from MRR trial.
:param mrr_unit: Unit of measurement for the rate.
:type mrr_unit: str
:type bandwidth_value: Optional[float]
:type bandwidth_unit: Optional[str]
- :raises RuntimeError: If mrr_unit is missing or any value is negative.
"""
if not mrr_unit:
- raise RuntimeError(f"Cannot be falsey: {mrr_unit=}")
+ return
data = get_export_data()
data["result"]["type"] = "mrr"
+
for node_val, node_unit, node_name in ((mrr_value, mrr_unit, "rate"),
(bandwidth_value, bandwidth_unit, "bandwidth")):
if node_val is not None:
- node_val = float(node_val)
- if node_val < 0:
- raise RuntimeError(f"Cannot be negative: {node_val=}")
node = descend(descend(data["result"], "receive_rate"), node_name)
node["unit"] = str(node_unit)
values_list = descend(node, "values", list)
- values_list.append(node_val)
+ values_list.append(float(node_val))
def export_search_bound(text, value, unit, bandwidth=None):