Convert source-level metrics into ModelExplorer node data for duration.
(df: pd.DataFrame)
| 203 | |
| 204 | |
| 205 | def get_model_node_data(df: pd.DataFrame) -> ndb.ModelNodeData: |
| 206 | """ |
| 207 | Convert source-level metrics into ModelExplorer node data for duration. |
| 208 | """ |
| 209 | durations = df["duration"].fillna(0).astype(int) |
| 210 | |
| 211 | duration_results: Dict[str, ndb.NodeDataResult] = {} |
| 212 | |
| 213 | for src, dur in zip(df["ext_key"], durations): |
| 214 | node_id = f"main/op{int(src)}" |
| 215 | duration_results[node_id] = ndb.NodeDataResult(value=int(dur)) |
| 216 | |
| 217 | gradient = [ |
| 218 | ndb.GradientItem(stop=0.0, bgColor="#ffffff"), |
| 219 | ndb.GradientItem(stop=0.1, bgColor="#33FF00"), |
| 220 | ndb.GradientItem(stop=0.2, bgColor="#66FF00"), |
| 221 | ndb.GradientItem(stop=0.5, bgColor="#FFFF00"), |
| 222 | ndb.GradientItem(stop=0.7, bgColor="#FF6600"), |
| 223 | ndb.GradientItem(stop=1.0, bgColor="#FF0000"), |
| 224 | ] |
| 225 | |
| 226 | return ndb.ModelNodeData( |
| 227 | graphsData={ |
| 228 | "main": ndb.GraphNodeData(results=duration_results, gradient=gradient) |
| 229 | } |
| 230 | ) |
| 231 | |
| 232 | |
| 233 | def build_overlay_data(trace_path: Path, tables_path: Path) -> ndb.ModelNodeData: |
no outgoing calls
no test coverage detected