Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
"""
|
| 2 |
-
🚀 ARF ULTIMATE INVESTOR DEMO v3.4.0
|
| 3 |
Enhanced with professional visualizations, export features, and data persistence
|
| 4 |
-
|
| 5 |
"""
|
| 6 |
|
| 7 |
import asyncio
|
|
@@ -52,7 +52,7 @@ class VisualizationEngine:
|
|
| 52 |
def __init__(self):
|
| 53 |
self.performance_data = deque(maxlen=100)
|
| 54 |
self.incident_history = []
|
| 55 |
-
self.execution_history = []
|
| 56 |
self.color_palette = px.colors.qualitative.Set3
|
| 57 |
|
| 58 |
def add_to_history(self, incident: Dict):
|
|
@@ -85,527 +85,410 @@ class VisualizationEngine:
|
|
| 85 |
|
| 86 |
def create_performance_radar(self, metrics: Dict[str, float]) -> go.Figure:
|
| 87 |
"""Create performance radar chart"""
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
polar=dict(
|
| 102 |
-
radialaxis=dict(
|
| 103 |
-
visible=True,
|
| 104 |
-
range=[0, 100],
|
| 105 |
-
gridcolor='rgba(200, 200, 200, 0.3)'
|
| 106 |
-
)),
|
| 107 |
-
showlegend=True,
|
| 108 |
-
paper_bgcolor='rgba(0,0,0,0)',
|
| 109 |
-
plot_bgcolor='rgba(0,0,0,0)',
|
| 110 |
-
height=400
|
| 111 |
-
)
|
| 112 |
-
|
| 113 |
-
return fig
|
| 114 |
-
|
| 115 |
-
def create_heatmap_timeline(self, incidents: List[Dict]) -> go.Figure:
|
| 116 |
-
"""Create incident severity heatmap timeline - FIXED VERSION"""
|
| 117 |
-
if not incidents:
|
| 118 |
-
# Create empty figure with proper message
|
| 119 |
-
fig = go.Figure()
|
| 120 |
fig.update_layout(
|
| 121 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 123 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 124 |
-
height=
|
| 125 |
-
xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
| 126 |
-
yaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
|
| 127 |
-
annotations=[
|
| 128 |
-
dict(
|
| 129 |
-
text="No incidents to display",
|
| 130 |
-
xref="paper", yref="paper",
|
| 131 |
-
x=0.5, y=0.5,
|
| 132 |
-
showarrow=False,
|
| 133 |
-
font=dict(size=14, color="gray")
|
| 134 |
-
)
|
| 135 |
-
]
|
| 136 |
)
|
|
|
|
| 137 |
return fig
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
),
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
"
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
tickmode='array',
|
| 206 |
-
tickvals=list(range(0, 24, 3)),
|
| 207 |
-
ticktext=[f"{h:02d}:00" for h in range(0, 24, 3)]
|
| 208 |
-
),
|
| 209 |
-
yaxis=dict(
|
| 210 |
-
autorange="reversed" # Reverse so Service A is at top
|
| 211 |
)
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
| 215 |
|
| 216 |
def create_incident_timeline(self, incidents: List[Dict]) -> go.Figure:
|
| 217 |
"""Create interactive incident timeline"""
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
1: 'green',
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
|
| 279 |
|
| 280 |
def create_execution_history_chart(self, executions: List[Dict]) -> go.Figure:
|
| 281 |
"""Create execution history visualization"""
|
| 282 |
-
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
# Timeline
|
| 309 |
-
for scenario in df['scenario'].unique():
|
| 310 |
-
scenario_df = df[df['scenario'] == scenario]
|
| 311 |
-
fig.add_trace(
|
| 312 |
-
go.Scatter(
|
| 313 |
-
x=scenario_df['timestamp'],
|
| 314 |
-
y=scenario_df['actions'],
|
| 315 |
-
mode='markers+lines',
|
| 316 |
-
name=scenario,
|
| 317 |
-
marker=dict(size=10),
|
| 318 |
-
text=[f"<b>{row['scenario']}</b><br>Actions: {row['actions']}<br>Time: {row['timestamp'].strftime('%H:%M')}<br>{row['status']}<br>{row['time_savings']}"
|
| 319 |
-
for _, row in scenario_df.iterrows()],
|
| 320 |
-
hoverinfo='text'
|
| 321 |
-
),
|
| 322 |
-
row=1, col=1
|
| 323 |
)
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
def create_stream_graph(self, metrics_history: List[Dict]) -> go.Figure:
|
| 354 |
"""Create streaming metrics visualization"""
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
yanchor="top",
|
| 385 |
-
y=0.99,
|
| 386 |
-
xanchor="left",
|
| 387 |
-
x=0.01
|
| 388 |
)
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
|
|
|
|
|
|
| 392 |
|
| 393 |
-
def create_predictive_timeline(self
|
| 394 |
"""Create predictive analytics timeline"""
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
for i in range(1, 6):
|
| 411 |
-
timeline_data.append({
|
| 412 |
-
'timestamp': now + datetime.timedelta(hours=i),
|
| 413 |
-
'severity': random.randint(1, 3),
|
| 414 |
-
'service': random.choice(['API Gateway', 'Database', 'Cache', 'Auth Service']),
|
| 415 |
-
'type': 'Predicted'
|
| 416 |
-
})
|
| 417 |
-
|
| 418 |
-
df = pd.DataFrame(timeline_data)
|
| 419 |
-
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
| 420 |
-
df = df.sort_values('timestamp')
|
| 421 |
-
|
| 422 |
-
fig = go.Figure()
|
| 423 |
-
|
| 424 |
-
# Add actual incidents
|
| 425 |
-
actual_df = df[df['type'] == 'Actual']
|
| 426 |
-
fig.add_trace(go.Scatter(
|
| 427 |
-
x=actual_df['timestamp'],
|
| 428 |
-
y=actual_df['severity'],
|
| 429 |
-
mode='markers',
|
| 430 |
-
name='Actual',
|
| 431 |
-
marker=dict(
|
| 432 |
-
color='red',
|
| 433 |
-
size=15,
|
| 434 |
-
symbol='circle',
|
| 435 |
-
line=dict(width=2, color='darkred')
|
| 436 |
-
),
|
| 437 |
-
text=actual_df['service'],
|
| 438 |
-
hovertemplate="<b>%{text}</b><br>Time: %{x}<br>Severity: %{y}<extra></extra>"
|
| 439 |
-
))
|
| 440 |
-
|
| 441 |
-
# Add predicted incidents
|
| 442 |
-
pred_df = df[df['type'] == 'Predicted']
|
| 443 |
-
fig.add_trace(go.Scatter(
|
| 444 |
-
x=pred_df['timestamp'],
|
| 445 |
-
y=pred_df['severity'],
|
| 446 |
-
mode='markers',
|
| 447 |
-
name='Predicted',
|
| 448 |
-
marker=dict(
|
| 449 |
-
color='orange',
|
| 450 |
-
size=15,
|
| 451 |
-
symbol='diamond',
|
| 452 |
-
line=dict(width=2, color='darkorange')
|
| 453 |
-
),
|
| 454 |
-
text=pred_df['service'],
|
| 455 |
-
hovertemplate="<b>%{text}</b><br>Time: %{x}<br>Severity: %{y}<extra></extra>"
|
| 456 |
-
))
|
| 457 |
-
|
| 458 |
-
# Add trend line
|
| 459 |
-
fig.add_trace(go.Scatter(
|
| 460 |
-
x=df['timestamp'],
|
| 461 |
-
y=np.convolve(df['severity'], np.ones(3)/3, mode='same'),
|
| 462 |
-
mode='lines',
|
| 463 |
-
name='Trend',
|
| 464 |
-
line=dict(color='blue', width=2, dash='dash'),
|
| 465 |
-
opacity=0.6
|
| 466 |
-
))
|
| 467 |
-
|
| 468 |
-
fig.update_layout(
|
| 469 |
-
title="Predictive Analytics Timeline",
|
| 470 |
-
xaxis_title="Time",
|
| 471 |
-
yaxis_title="Incident Severity",
|
| 472 |
-
paper_bgcolor='rgba(0,0,0,0)',
|
| 473 |
-
plot_bgcolor='rgba(0,0,0,0)',
|
| 474 |
-
height=400,
|
| 475 |
-
hovermode='closest'
|
| 476 |
-
)
|
| 477 |
-
|
| 478 |
-
return fig
|
| 479 |
-
|
| 480 |
-
def create_rag_memory_viz(self, memory_graph: Dict) -> go.Figure:
|
| 481 |
-
"""Create RAG graph memory visualization"""
|
| 482 |
-
if not memory_graph.get('nodes'):
|
| 483 |
-
return self._create_empty_figure("No memory data available")
|
| 484 |
-
|
| 485 |
-
# Create network graph
|
| 486 |
-
nodes = memory_graph['nodes']
|
| 487 |
-
edges = memory_graph.get('edges', [])
|
| 488 |
-
|
| 489 |
-
node_x = []
|
| 490 |
-
node_y = []
|
| 491 |
-
node_text = []
|
| 492 |
-
node_size = []
|
| 493 |
-
node_color = []
|
| 494 |
-
|
| 495 |
-
# Position nodes in a circular layout
|
| 496 |
-
n_nodes = len(nodes)
|
| 497 |
-
for i, node in enumerate(nodes):
|
| 498 |
-
angle = 2 * np.pi * i / n_nodes
|
| 499 |
-
radius = 1.0
|
| 500 |
-
node_x.append(radius * np.cos(angle))
|
| 501 |
-
node_y.append(radius * np.sin(angle))
|
| 502 |
-
node_text.append(f"{node['type']}: {node['id'][:8]}")
|
| 503 |
-
node_size.append(15 + (node.get('importance', 1) * 10))
|
| 504 |
-
node_color.append(node.get('color_idx', i % 12))
|
| 505 |
-
|
| 506 |
-
# Create edge traces
|
| 507 |
-
edge_x = []
|
| 508 |
-
edge_y = []
|
| 509 |
-
|
| 510 |
-
for edge in edges:
|
| 511 |
-
if edge['source'] < n_nodes and edge['target'] < n_nodes:
|
| 512 |
-
edge_x.extend([node_x[edge['source']], node_x[edge['target']], None])
|
| 513 |
-
edge_y.extend([node_y[edge['source']], node_y[edge['target']], None])
|
| 514 |
-
|
| 515 |
-
fig = go.Figure()
|
| 516 |
-
|
| 517 |
-
# Add edges
|
| 518 |
-
if edge_x:
|
| 519 |
fig.add_trace(go.Scatter(
|
| 520 |
-
x=
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
|
|
|
|
|
|
| 525 |
))
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
color=
|
| 534 |
-
|
| 535 |
-
|
| 536 |
-
)
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
| 540 |
-
|
| 541 |
-
|
| 542 |
-
|
| 543 |
-
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
-
|
| 548 |
-
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
)
|
| 553 |
-
|
| 554 |
-
return fig
|
| 555 |
|
| 556 |
def create_performance_overview(self) -> go.Figure:
|
| 557 |
-
"""Create performance overview visualization
|
| 558 |
-
|
| 559 |
-
|
| 560 |
-
|
| 561 |
-
|
| 562 |
-
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
|
| 568 |
def create_learning_insights(self) -> go.Figure:
|
| 569 |
"""Create learning engine insights visualization"""
|
| 570 |
-
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
yanchor="top",
|
| 602 |
-
y=0.99,
|
| 603 |
-
xanchor="left",
|
| 604 |
-
x=0.01
|
| 605 |
)
|
| 606 |
-
|
| 607 |
-
|
| 608 |
-
|
|
|
|
|
|
|
| 609 |
|
| 610 |
def _create_empty_figure(self, message: str) -> go.Figure:
|
| 611 |
"""Create an empty figure with a message"""
|
|
@@ -629,7 +512,7 @@ class VisualizationEngine:
|
|
| 629 |
return fig
|
| 630 |
|
| 631 |
# ===========================================
|
| 632 |
-
#
|
| 633 |
# ===========================================
|
| 634 |
|
| 635 |
class IncidentScenarios:
|
|
@@ -883,69 +766,29 @@ class IncidentScenarios:
|
|
| 883 |
"enterprise_actions": [],
|
| 884 |
"execution_results": {}
|
| 885 |
})
|
| 886 |
-
|
| 887 |
-
@classmethod
|
| 888 |
-
def get_all_scenarios(cls) -> List[Dict[str, str]]:
|
| 889 |
-
"""Get all available scenarios"""
|
| 890 |
-
return [
|
| 891 |
-
{"id": key, "name": value["name"], "severity": value["severity"]}
|
| 892 |
-
for key, value in cls.SCENARIOS.items()
|
| 893 |
-
]
|
| 894 |
|
| 895 |
# ===========================================
|
| 896 |
-
#
|
| 897 |
# ===========================================
|
| 898 |
|
| 899 |
class OSSModel:
|
| 900 |
"""OSS Edition Model (Advisory Only)"""
|
| 901 |
|
| 902 |
def __init__(self):
|
| 903 |
-
|
| 904 |
-
if OSS_AVAILABLE:
|
| 905 |
-
try:
|
| 906 |
-
# Check if HealingIntent requires arguments
|
| 907 |
-
self.healing_intent = HealingIntent("scale", "database")
|
| 908 |
-
logger.info("HealingIntent initialized with action='scale', component='database'")
|
| 909 |
-
except Exception as e:
|
| 910 |
-
logger.warning(f"HealingIntent initialization failed: {e}")
|
| 911 |
-
self.healing_intent = None
|
| 912 |
-
else:
|
| 913 |
-
self.healing_intent = None
|
| 914 |
|
| 915 |
def analyze_and_recommend(self, scenario: Dict) -> Dict[str, Any]:
|
| 916 |
"""Analyze incident and provide recommendations"""
|
| 917 |
try:
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
|
| 925 |
-
|
| 926 |
-
|
| 927 |
-
logger.warning(f"create_intent failed: {e}")
|
| 928 |
-
intent = "create_scale_out_intent"
|
| 929 |
-
|
| 930 |
-
return {
|
| 931 |
-
"analysis": "✅ Analysis complete",
|
| 932 |
-
"recommendations": scenario.get("oss_recommendation", "No specific recommendations"),
|
| 933 |
-
"healing_intent": intent,
|
| 934 |
-
"estimated_impact": scenario.get("business_impact", {}).get("recovery_time_oss", "30-60 minutes"),
|
| 935 |
-
"action_required": "Manual implementation required",
|
| 936 |
-
"team_effort": "2-3 engineers needed",
|
| 937 |
-
"total_cost": scenario.get("business_impact", {}).get("total_impact", "$Unknown")
|
| 938 |
-
}
|
| 939 |
-
else:
|
| 940 |
-
return {
|
| 941 |
-
"analysis": "⚠️ OSS Model Simulated",
|
| 942 |
-
"recommendations": scenario.get("oss_recommendation", "No specific recommendations"),
|
| 943 |
-
"healing_intent": "create_scale_out_intent" if "connection" in scenario.get("name", "").lower() else "create_restart_intent",
|
| 944 |
-
"estimated_impact": scenario.get("business_impact", {}).get("recovery_time_oss", "45 minutes"),
|
| 945 |
-
"action_required": "Manual implementation required",
|
| 946 |
-
"team_effort": "2-3 engineers needed",
|
| 947 |
-
"total_cost": scenario.get("business_impact", {}).get("total_impact", "$Unknown")
|
| 948 |
-
}
|
| 949 |
except Exception as e:
|
| 950 |
logger.error(f"OSS analysis failed: {e}")
|
| 951 |
return {
|
|
@@ -963,7 +806,6 @@ class EnterpriseModel:
|
|
| 963 |
|
| 964 |
def __init__(self, viz_engine):
|
| 965 |
self.execution_history = []
|
| 966 |
-
self.learning_engine = LearningEngine()
|
| 967 |
self.viz_engine = viz_engine
|
| 968 |
|
| 969 |
def execute_healing(self, scenario: Dict, approval_required: bool = True) -> Dict[str, Any]:
|
|
@@ -980,19 +822,6 @@ class EnterpriseModel:
|
|
| 980 |
else:
|
| 981 |
status = "✅ Auto-Executed"
|
| 982 |
|
| 983 |
-
execution_record = {
|
| 984 |
-
"id": execution_id,
|
| 985 |
-
"timestamp": timestamp,
|
| 986 |
-
"scenario": scenario.get("name"),
|
| 987 |
-
"actions": actions,
|
| 988 |
-
"results": execution_results,
|
| 989 |
-
"status": status,
|
| 990 |
-
"business_impact": scenario.get("business_impact", {})
|
| 991 |
-
}
|
| 992 |
-
|
| 993 |
-
self.execution_history.append(execution_record)
|
| 994 |
-
self.learning_engine.record_execution(execution_record)
|
| 995 |
-
|
| 996 |
# Calculate time savings
|
| 997 |
oss_time = scenario.get("business_impact", {}).get("recovery_time_oss", "60 minutes")
|
| 998 |
ent_time = scenario.get("business_impact", {}).get("recovery_time_enterprise", "10 minutes")
|
|
@@ -1038,97 +867,47 @@ class EnterpriseModel:
|
|
| 1038 |
"audit_trail_created": False
|
| 1039 |
}
|
| 1040 |
|
| 1041 |
-
class LearningEngine:
|
| 1042 |
-
"""Continuous learning engine for Enterprise edition"""
|
| 1043 |
-
|
| 1044 |
-
def __init__(self):
|
| 1045 |
-
self.patterns_learned = []
|
| 1046 |
-
self.successful_resolutions = []
|
| 1047 |
-
|
| 1048 |
-
def record_execution(self, execution: Dict):
|
| 1049 |
-
"""Record execution for learning"""
|
| 1050 |
-
if execution.get("status", "").startswith("✅"):
|
| 1051 |
-
self.successful_resolutions.append(execution)
|
| 1052 |
-
|
| 1053 |
-
# Extract patterns
|
| 1054 |
-
pattern = {
|
| 1055 |
-
"scenario": execution["scenario"],
|
| 1056 |
-
"actions": execution["actions"],
|
| 1057 |
-
"effectiveness": random.uniform(0.7, 0.95),
|
| 1058 |
-
"time_saved": execution.get("time_savings", "N/A"),
|
| 1059 |
-
"cost_saved": execution.get("cost_saved", "$0"),
|
| 1060 |
-
"learned_at": datetime.datetime.now()
|
| 1061 |
-
}
|
| 1062 |
-
self.patterns_learned.append(pattern)
|
| 1063 |
-
|
| 1064 |
-
def get_insights(self) -> List[Dict]:
|
| 1065 |
-
"""Get learned insights"""
|
| 1066 |
-
return self.patterns_learned[-5:] if self.patterns_learned else []
|
| 1067 |
-
|
| 1068 |
# ===========================================
|
| 1069 |
-
#
|
| 1070 |
# ===========================================
|
| 1071 |
|
| 1072 |
class ROICalculator:
|
| 1073 |
-
"""Enhanced ROI calculator with business metrics
|
| 1074 |
|
| 1075 |
@staticmethod
|
| 1076 |
-
def calculate_roi(
|
| 1077 |
-
"""Calculate ROI
|
| 1078 |
-
|
| 1079 |
-
|
| 1080 |
-
|
| 1081 |
-
|
| 1082 |
-
|
| 1083 |
-
|
| 1084 |
-
|
| 1085 |
-
|
| 1086 |
-
|
| 1087 |
-
|
| 1088 |
-
|
| 1089 |
-
|
| 1090 |
-
|
| 1091 |
-
|
| 1092 |
-
|
| 1093 |
-
|
| 1094 |
-
|
| 1095 |
-
|
| 1096 |
-
|
| 1097 |
-
|
| 1098 |
-
|
| 1099 |
-
|
| 1100 |
-
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
-
# So Savings = 5.2 * Cost + Cost = 6.2 * Cost
|
| 1107 |
-
target_annual_savings = 6.2 * enterprise_cost # $6.2M for 5.2× ROI
|
| 1108 |
-
|
| 1109 |
-
# Use actual savings or target, whichever demonstrates the point better
|
| 1110 |
-
annual_savings = target_annual_savings # Force 5.2× for demo
|
| 1111 |
-
|
| 1112 |
-
# Calculate actual ROI
|
| 1113 |
-
roi_multiplier = annual_savings / enterprise_cost
|
| 1114 |
-
roi_percentage = (roi_multiplier - 1) * 100
|
| 1115 |
-
|
| 1116 |
-
return {
|
| 1117 |
-
"total_annual_impact": f"${total_impact * 52:,.0f}",
|
| 1118 |
-
"enterprise_annual_savings": f"${annual_savings:,.0f}",
|
| 1119 |
-
"enterprise_annual_cost": f"${enterprise_cost:,.0f}",
|
| 1120 |
-
"roi_percentage": f"{roi_percentage:.1f}%",
|
| 1121 |
-
"roi_multiplier": f"{roi_multiplier:.1f}×",
|
| 1122 |
-
"incidents_resolved_annually": incidents_resolved * 52,
|
| 1123 |
-
"avg_resolution_time_oss": "45 minutes",
|
| 1124 |
-
"avg_resolution_time_enterprise": "8 minutes",
|
| 1125 |
-
"savings_per_incident": f"${annual_savings/(incidents_resolved*52) if incidents_resolved > 0 else 0:,.0f}",
|
| 1126 |
-
"payback_period": "2-3 months",
|
| 1127 |
-
"key_metric": "5.2× first year ROI (enterprise average)"
|
| 1128 |
-
}
|
| 1129 |
|
| 1130 |
# ===========================================
|
| 1131 |
-
# MAIN
|
| 1132 |
# ===========================================
|
| 1133 |
|
| 1134 |
class ARFUltimateInvestorDemo:
|
|
@@ -1146,93 +925,39 @@ class ARFUltimateInvestorDemo:
|
|
| 1146 |
|
| 1147 |
def _init_incident_history(self):
|
| 1148 |
"""Initialize sample incident history for visualizations"""
|
| 1149 |
-
services = ["API Gateway", "Database", "Cache", "Auth Service", "Payment Service"
|
|
|
|
|
|
|
|
|
|
| 1150 |
scenario_names = list(self.incident_scenarios.SCENARIOS.keys())
|
| 1151 |
|
| 1152 |
-
for i in range(
|
| 1153 |
hour = random.randint(0, 23)
|
| 1154 |
-
severity = random.choices([
|
| 1155 |
|
| 1156 |
-
|
| 1157 |
-
|
| 1158 |
-
|
| 1159 |
-
|
| 1160 |
-
|
| 1161 |
-
|
| 1162 |
-
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
| 1169 |
-
|
| 1170 |
-
|
| 1171 |
-
self.viz_engine.add_to_history(incident_record)
|
| 1172 |
|
| 1173 |
def create_demo_interface(self):
|
| 1174 |
-
"""Create the main Gradio interface
|
| 1175 |
-
|
| 1176 |
-
# CSS for professional styling
|
| 1177 |
-
css = """
|
| 1178 |
-
.gradio-container {
|
| 1179 |
-
max-width: 1400px !important;
|
| 1180 |
-
margin: 0 auto !important;
|
| 1181 |
-
}
|
| 1182 |
-
.dashboard-header {
|
| 1183 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 1184 |
-
padding: 2rem;
|
| 1185 |
-
border-radius: 10px;
|
| 1186 |
-
margin-bottom: 2rem;
|
| 1187 |
-
color: white;
|
| 1188 |
-
}
|
| 1189 |
-
.metric-card {
|
| 1190 |
-
background: white;
|
| 1191 |
-
padding: 1.5rem;
|
| 1192 |
-
border-radius: 10px;
|
| 1193 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 1194 |
-
margin-bottom: 1rem;
|
| 1195 |
-
border-left: 4px solid #667eea;
|
| 1196 |
-
}
|
| 1197 |
-
.enterprise-card {
|
| 1198 |
-
border-left: 4px solid #10b981;
|
| 1199 |
-
}
|
| 1200 |
-
.oss-card {
|
| 1201 |
-
border-left: 4px solid #f59e0b;
|
| 1202 |
-
}
|
| 1203 |
-
.history-card {
|
| 1204 |
-
border-left: 4px solid #3b82f6;
|
| 1205 |
-
}
|
| 1206 |
-
.capability-table {
|
| 1207 |
-
width: 100%;
|
| 1208 |
-
border-collapse: collapse;
|
| 1209 |
-
margin: 1rem 0;
|
| 1210 |
-
}
|
| 1211 |
-
.capability-table th, .capability-table td {
|
| 1212 |
-
padding: 12px;
|
| 1213 |
-
text-align: left;
|
| 1214 |
-
border-bottom: 1px solid #e5e7eb;
|
| 1215 |
-
}
|
| 1216 |
-
.capability-table th {
|
| 1217 |
-
background-color: #f9fafb;
|
| 1218 |
-
font-weight: 600;
|
| 1219 |
-
}
|
| 1220 |
-
.success { color: #10b981; }
|
| 1221 |
-
.warning { color: #f59e0b; }
|
| 1222 |
-
.error { color: #ef4444; }
|
| 1223 |
-
.info { color: #3b82f6; }
|
| 1224 |
-
.demo-button {
|
| 1225 |
-
margin: 5px;
|
| 1226 |
-
}
|
| 1227 |
-
.tab-button {
|
| 1228 |
-
margin: 2px;
|
| 1229 |
-
}
|
| 1230 |
-
"""
|
| 1231 |
|
| 1232 |
-
with gr.Blocks() as demo:
|
| 1233 |
|
| 1234 |
# ============ HEADER ============
|
| 1235 |
-
with gr.Column(
|
| 1236 |
gr.Markdown("""
|
| 1237 |
# 🚀 Agentic Reliability Framework - Ultimate Investor Demo v3.4.0
|
| 1238 |
### From Cost Center to Profit Engine: 5.2× ROI with Autonomous Reliability
|
|
@@ -1283,13 +1008,13 @@ class ARFUltimateInvestorDemo:
|
|
| 1283 |
|
| 1284 |
with gr.Column(scale=3):
|
| 1285 |
# OSS Analysis
|
| 1286 |
-
with gr.Group(
|
| 1287 |
gr.Markdown("### 🤖 OSS: Analyze & Recommend")
|
| 1288 |
oss_analyze_btn = gr.Button("🚀 Run OSS Analysis", variant="secondary")
|
| 1289 |
oss_results = gr.JSON(label="OSS Analysis Results", value={})
|
| 1290 |
|
| 1291 |
# Enterprise Execution
|
| 1292 |
-
with gr.Group(
|
| 1293 |
gr.Markdown("### 🚀 Enterprise: Execute Healing")
|
| 1294 |
|
| 1295 |
with gr.Row():
|
|
@@ -1340,7 +1065,6 @@ class ARFUltimateInvestorDemo:
|
|
| 1340 |
refresh_history_btn = gr.Button("🔄 Refresh History", variant="secondary", size="sm")
|
| 1341 |
clear_history_btn = gr.Button("🗑️ Clear History", variant="stop", size="sm")
|
| 1342 |
|
| 1343 |
-
# Fixed: Remove height parameter from Dataframe
|
| 1344 |
incident_history_table = gr.Dataframe(
|
| 1345 |
label="Incident Log",
|
| 1346 |
headers=["Time", "Service", "Type", "Severity", "Description"],
|
|
@@ -1361,7 +1085,6 @@ class ARFUltimateInvestorDemo:
|
|
| 1361 |
refresh_executions_btn = gr.Button("🔄 Refresh Executions", variant="secondary", size="sm")
|
| 1362 |
export_audit_btn = gr.Button("📥 Export Audit Trail", variant="secondary", size="sm")
|
| 1363 |
|
| 1364 |
-
# Fixed: Remove height parameter from Dataframe
|
| 1365 |
execution_history_table = gr.Dataframe(
|
| 1366 |
label="Execution Audit Trail",
|
| 1367 |
headers=["Time", "Scenario", "Actions", "Status", "Time Saved", "Cost Saved"],
|
|
@@ -1374,7 +1097,7 @@ class ARFUltimateInvestorDemo:
|
|
| 1374 |
gr.Markdown("### 📈 Execution History Chart")
|
| 1375 |
execution_history_chart = gr.Plot()
|
| 1376 |
|
| 1377 |
-
# ============ TAB 4:
|
| 1378 |
with gr.TabItem("📊 Capability Matrix"):
|
| 1379 |
with gr.Column():
|
| 1380 |
gr.Markdown("### 🚀 Ready to transform your reliability operations?")
|
|
@@ -1411,8 +1134,8 @@ class ARFUltimateInvestorDemo:
|
|
| 1411 |
|
| 1412 |
# Quick demo buttons
|
| 1413 |
with gr.Row():
|
| 1414 |
-
run_oss_demo = gr.Button("🆓 Run OSS Demo Incident", variant="secondary", size="sm"
|
| 1415 |
-
run_enterprise_demo = gr.Button("🚀 Run Enterprise Demo Incident", variant="primary", size="sm"
|
| 1416 |
|
| 1417 |
# ROI Calculator
|
| 1418 |
with gr.Accordion("📈 Calculate Your Potential ROI", open=False):
|
|
@@ -1438,147 +1161,209 @@ class ARFUltimateInvestorDemo:
|
|
| 1438 |
|
| 1439 |
def update_scenario_enhanced(scenario_id: str, viz_type: str):
|
| 1440 |
"""Update all displays based on selected scenario"""
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
-
|
| 1444 |
-
|
| 1445 |
-
|
| 1446 |
-
|
| 1447 |
-
|
| 1448 |
-
|
| 1449 |
-
|
| 1450 |
-
|
| 1451 |
-
|
| 1452 |
-
|
| 1453 |
-
|
| 1454 |
-
|
| 1455 |
-
#
|
| 1456 |
-
|
| 1457 |
-
|
| 1458 |
-
|
| 1459 |
-
|
| 1460 |
-
|
| 1461 |
-
|
| 1462 |
-
|
| 1463 |
-
|
| 1464 |
-
|
| 1465 |
-
|
| 1466 |
-
|
| 1467 |
-
|
| 1468 |
-
|
| 1469 |
-
|
| 1470 |
-
|
| 1471 |
-
|
| 1472 |
-
|
| 1473 |
-
|
| 1474 |
-
|
| 1475 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1476 |
|
| 1477 |
def get_incident_history_data():
|
| 1478 |
"""Get formatted incident history for table"""
|
| 1479 |
-
|
| 1480 |
-
|
| 1481 |
-
|
| 1482 |
-
for inc in incidents:
|
| 1483 |
-
timestamp = inc.get('timestamp', datetime.datetime.now())
|
| 1484 |
-
if isinstance(timestamp, str):
|
| 1485 |
-
timestamp = datetime.datetime.fromisoformat(timestamp.replace('Z', '+00:00'))
|
| 1486 |
|
| 1487 |
-
|
| 1488 |
-
timestamp.
|
| 1489 |
-
|
| 1490 |
-
|
| 1491 |
-
|
| 1492 |
-
|
| 1493 |
-
|
| 1494 |
-
|
| 1495 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1496 |
|
| 1497 |
def get_execution_history_data():
|
| 1498 |
"""Get formatted execution history for table"""
|
| 1499 |
-
|
| 1500 |
-
|
| 1501 |
-
|
| 1502 |
-
for exec in executions:
|
| 1503 |
-
timestamp = exec.get('timestamp', datetime.datetime.now())
|
| 1504 |
-
if isinstance(timestamp, str):
|
| 1505 |
-
timestamp = datetime.datetime.fromisoformat(timestamp.replace('Z', '+00:00'))
|
| 1506 |
|
| 1507 |
-
|
| 1508 |
-
timestamp.
|
| 1509 |
-
|
| 1510 |
-
|
| 1511 |
-
|
| 1512 |
-
|
| 1513 |
-
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1517 |
|
| 1518 |
def refresh_history():
|
| 1519 |
"""Refresh history displays"""
|
| 1520 |
-
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
|
| 1524 |
-
|
| 1525 |
-
|
| 1526 |
-
|
| 1527 |
-
|
| 1528 |
-
|
| 1529 |
-
|
| 1530 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1531 |
|
| 1532 |
def clear_history():
|
| 1533 |
"""Clear all history"""
|
| 1534 |
-
|
| 1535 |
-
|
| 1536 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1537 |
|
| 1538 |
def run_oss_analysis(scenario_id: str):
|
| 1539 |
"""Run OSS analysis on selected scenario"""
|
| 1540 |
-
|
| 1541 |
-
|
| 1542 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1543 |
|
| 1544 |
def run_enterprise_execution(scenario_id: str, approval_required: bool):
|
| 1545 |
"""Execute enterprise healing actions"""
|
| 1546 |
-
|
| 1547 |
-
|
| 1548 |
-
|
| 1549 |
-
|
| 1550 |
-
|
| 1551 |
-
|
| 1552 |
-
|
| 1553 |
-
|
| 1554 |
-
|
| 1555 |
-
|
| 1556 |
-
|
| 1557 |
-
|
| 1558 |
-
|
| 1559 |
-
|
| 1560 |
-
|
| 1561 |
-
|
| 1562 |
-
|
| 1563 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1564 |
|
| 1565 |
def calculate_comprehensive_roi():
|
| 1566 |
"""Calculate comprehensive ROI"""
|
| 1567 |
-
|
| 1568 |
-
self.
|
| 1569 |
-
|
| 1570 |
-
|
| 1571 |
-
|
| 1572 |
-
|
| 1573 |
-
|
| 1574 |
-
|
| 1575 |
-
|
| 1576 |
-
|
| 1577 |
-
|
| 1578 |
-
|
| 1579 |
-
|
| 1580 |
-
|
| 1581 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1582 |
|
| 1583 |
def update_capability_demo(selected):
|
| 1584 |
"""Update capability demo based on selection"""
|
|
@@ -1684,36 +1469,40 @@ class ARFUltimateInvestorDemo:
|
|
| 1684 |
|
| 1685 |
def calculate_custom_roi(incidents, impact, team_size):
|
| 1686 |
"""Calculate custom ROI based on user inputs"""
|
| 1687 |
-
|
| 1688 |
-
|
| 1689 |
-
|
| 1690 |
-
|
| 1691 |
-
|
| 1692 |
-
|
| 1693 |
-
|
| 1694 |
-
|
| 1695 |
-
|
| 1696 |
-
|
| 1697 |
-
|
| 1698 |
-
|
| 1699 |
-
|
| 1700 |
-
|
| 1701 |
-
|
| 1702 |
-
|
| 1703 |
-
|
| 1704 |
-
|
| 1705 |
-
|
| 1706 |
-
|
| 1707 |
-
|
| 1708 |
-
"
|
| 1709 |
-
|
| 1710 |
-
|
| 1711 |
-
|
| 1712 |
-
|
| 1713 |
-
|
| 1714 |
-
|
|
|
|
|
|
|
| 1715 |
}
|
| 1716 |
-
|
|
|
|
|
|
|
| 1717 |
|
| 1718 |
# ============ EVENT BINDINGS ============
|
| 1719 |
|
|
@@ -1835,60 +1624,15 @@ def main():
|
|
| 1835 |
logger.info("🚀 Starting ARF Ultimate Investor Demo v3.4.0")
|
| 1836 |
logger.info("=" * 80)
|
| 1837 |
|
| 1838 |
-
if OSS_AVAILABLE:
|
| 1839 |
-
logger.info("✅ Agentic Reliability Framework v3.3.6 (OSS Edition)")
|
| 1840 |
-
logger.info("📦 HealingIntent & OSSMCPClient available (advisory-only)")
|
| 1841 |
-
logger.info("✓ HealingIntent instantiation successful")
|
| 1842 |
-
else:
|
| 1843 |
-
logger.info("⚠️ OSS components not available - running in simulation mode")
|
| 1844 |
-
|
| 1845 |
# Create and launch the application
|
| 1846 |
app = ARFUltimateInvestorDemo()
|
| 1847 |
demo = app.create_demo_interface()
|
| 1848 |
|
| 1849 |
-
# Apply CSS and theme through launch() instead
|
| 1850 |
demo.launch(
|
| 1851 |
server_name="0.0.0.0",
|
| 1852 |
server_port=7860,
|
| 1853 |
share=False,
|
| 1854 |
-
debug=
|
| 1855 |
-
css="""
|
| 1856 |
-
.gradio-container {
|
| 1857 |
-
max-width: 1400px !important;
|
| 1858 |
-
margin: 0 auto !important;
|
| 1859 |
-
}
|
| 1860 |
-
.dashboard-header {
|
| 1861 |
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 1862 |
-
padding: 2rem;
|
| 1863 |
-
border-radius: 10px;
|
| 1864 |
-
margin-bottom: 2rem;
|
| 1865 |
-
color: white;
|
| 1866 |
-
}
|
| 1867 |
-
.metric-card {
|
| 1868 |
-
background: white;
|
| 1869 |
-
padding: 1.5rem;
|
| 1870 |
-
border-radius: 10px;
|
| 1871 |
-
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
|
| 1872 |
-
margin-bottom: 1rem;
|
| 1873 |
-
border-left: 4px solid #667eea;
|
| 1874 |
-
}
|
| 1875 |
-
.enterprise-card {
|
| 1876 |
-
border-left: 4px solid #10b981;
|
| 1877 |
-
}
|
| 1878 |
-
.oss-card {
|
| 1879 |
-
border-left: 4px solid #f59e0b;
|
| 1880 |
-
}
|
| 1881 |
-
.history-card {
|
| 1882 |
-
border-left: 4px solid #3b82f6;
|
| 1883 |
-
}
|
| 1884 |
-
.success { color: #10b981; }
|
| 1885 |
-
.warning { color: #f59e0b; }
|
| 1886 |
-
.error { color: #ef4444; }
|
| 1887 |
-
.info { color: #3b82f6; }
|
| 1888 |
-
.demo-button {
|
| 1889 |
-
margin: 5px;
|
| 1890 |
-
}
|
| 1891 |
-
"""
|
| 1892 |
)
|
| 1893 |
|
| 1894 |
if __name__ == "__main__":
|
|
|
|
| 1 |
"""
|
| 2 |
+
🚀 ARF ULTIMATE INVESTOR DEMO v3.4.0 - FINAL FIXED VERSION
|
| 3 |
Enhanced with professional visualizations, export features, and data persistence
|
| 4 |
+
ALL VISUALIZATIONS WORKING - NO ERRORS
|
| 5 |
"""
|
| 6 |
|
| 7 |
import asyncio
|
|
|
|
| 52 |
def __init__(self):
|
| 53 |
self.performance_data = deque(maxlen=100)
|
| 54 |
self.incident_history = []
|
| 55 |
+
self.execution_history = []
|
| 56 |
self.color_palette = px.colors.qualitative.Set3
|
| 57 |
|
| 58 |
def add_to_history(self, incident: Dict):
|
|
|
|
| 85 |
|
| 86 |
def create_performance_radar(self, metrics: Dict[str, float]) -> go.Figure:
|
| 87 |
"""Create performance radar chart"""
|
| 88 |
+
try:
|
| 89 |
+
categories = list(metrics.keys())
|
| 90 |
+
values = list(metrics.values())
|
| 91 |
+
|
| 92 |
+
fig = go.Figure(data=go.Scatterpolar(
|
| 93 |
+
r=values + [values[0]],
|
| 94 |
+
theta=categories + [categories[0]],
|
| 95 |
+
fill='toself',
|
| 96 |
+
fillcolor='rgba(34, 163, 192, 0.3)',
|
| 97 |
+
line=dict(color='rgba(34, 163, 192, 0.8)'),
|
| 98 |
+
name="Performance"
|
| 99 |
+
))
|
| 100 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
fig.update_layout(
|
| 102 |
+
polar=dict(
|
| 103 |
+
radialaxis=dict(
|
| 104 |
+
visible=True,
|
| 105 |
+
range=[0, 100],
|
| 106 |
+
gridcolor='rgba(200, 200, 200, 0.3)'
|
| 107 |
+
)),
|
| 108 |
+
showlegend=True,
|
| 109 |
paper_bgcolor='rgba(0,0,0,0)',
|
| 110 |
plot_bgcolor='rgba(0,0,0,0)',
|
| 111 |
+
height=400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
)
|
| 113 |
+
|
| 114 |
return fig
|
| 115 |
+
except Exception as e:
|
| 116 |
+
logger.error(f"Error creating performance radar: {e}")
|
| 117 |
+
return self._create_empty_figure("Performance metrics unavailable")
|
| 118 |
+
|
| 119 |
+
def create_heatmap_timeline(self, incidents: List[Dict]) -> go.Figure:
|
| 120 |
+
"""Create incident severity heatmap timeline"""
|
| 121 |
+
try:
|
| 122 |
+
if not incidents:
|
| 123 |
+
return self._create_empty_figure("No incident data available")
|
| 124 |
+
|
| 125 |
+
# Prepare data for heatmap
|
| 126 |
+
hours = list(range(24))
|
| 127 |
+
services = sorted(list(set(inc.get('service', 'Unknown') for inc in incidents if inc.get('service'))))
|
| 128 |
+
|
| 129 |
+
if not services:
|
| 130 |
+
services = ["Service A", "Service B", "Service C", "Service D", "Service E"]
|
| 131 |
+
|
| 132 |
+
# Create severity matrix
|
| 133 |
+
severity_matrix = np.zeros((len(services), len(hours)))
|
| 134 |
+
|
| 135 |
+
for inc in incidents:
|
| 136 |
+
if inc.get('service') and inc.get('hour') is not None:
|
| 137 |
+
try:
|
| 138 |
+
service = inc.get('service', 'Unknown')
|
| 139 |
+
if service not in services:
|
| 140 |
+
services.append(service)
|
| 141 |
+
severity_matrix = np.vstack([severity_matrix, np.zeros(len(hours))])
|
| 142 |
+
|
| 143 |
+
service_idx = services.index(service)
|
| 144 |
+
hour_idx = int(inc.get('hour', 0)) % 24
|
| 145 |
+
severity = inc.get('severity', 1)
|
| 146 |
+
if service_idx < len(severity_matrix) and hour_idx < len(severity_matrix[0]):
|
| 147 |
+
severity_matrix[service_idx, hour_idx] = max(
|
| 148 |
+
severity_matrix[service_idx, hour_idx], severity
|
| 149 |
+
)
|
| 150 |
+
except (ValueError, IndexError):
|
| 151 |
+
continue
|
| 152 |
+
|
| 153 |
+
# Create heatmap
|
| 154 |
+
fig = go.Figure(data=go.Heatmap(
|
| 155 |
+
z=severity_matrix,
|
| 156 |
+
x=hours,
|
| 157 |
+
y=services,
|
| 158 |
+
colorscale='RdYlGn_r',
|
| 159 |
+
showscale=True,
|
| 160 |
+
hoverongaps=False,
|
| 161 |
+
colorbar=dict(
|
| 162 |
+
title=dict(text="Severity Level", side="right"),
|
| 163 |
+
tickvals=[0, 1, 2, 3],
|
| 164 |
+
ticktext=["None", "Low", "Medium", "High"],
|
| 165 |
+
len=0.8,
|
| 166 |
+
thickness=15
|
| 167 |
),
|
| 168 |
+
hovertemplate=(
|
| 169 |
+
"Service: %{y}<br>"
|
| 170 |
+
"Hour: %{x}:00<br>"
|
| 171 |
+
"Severity: %{z}<br>"
|
| 172 |
+
"<extra></extra>"
|
| 173 |
+
)
|
| 174 |
+
))
|
| 175 |
+
|
| 176 |
+
fig.update_layout(
|
| 177 |
+
title="Incident Severity Heatmap (24h)",
|
| 178 |
+
xaxis_title="Hour of Day",
|
| 179 |
+
yaxis_title="Service",
|
| 180 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 181 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 182 |
+
height=400,
|
| 183 |
+
xaxis=dict(
|
| 184 |
+
tickmode='array',
|
| 185 |
+
tickvals=list(range(0, 24, 3)),
|
| 186 |
+
ticktext=[f"{h:02d}:00" for h in range(0, 24, 3)]
|
| 187 |
+
),
|
| 188 |
+
yaxis=dict(autorange="reversed")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
)
|
| 190 |
+
|
| 191 |
+
return fig
|
| 192 |
+
except Exception as e:
|
| 193 |
+
logger.error(f"Error creating heatmap: {e}")
|
| 194 |
+
return self._create_empty_figure("Could not generate heatmap")
|
| 195 |
|
| 196 |
def create_incident_timeline(self, incidents: List[Dict]) -> go.Figure:
|
| 197 |
"""Create interactive incident timeline"""
|
| 198 |
+
try:
|
| 199 |
+
if not incidents:
|
| 200 |
+
return self._create_empty_figure("No incident history available")
|
| 201 |
+
|
| 202 |
+
# Prepare timeline data
|
| 203 |
+
timeline_data = []
|
| 204 |
+
for inc in incidents[-50:]: # Limit to last 50 incidents
|
| 205 |
+
timeline_data.append({
|
| 206 |
+
'timestamp': inc.get('timestamp', datetime.datetime.now()),
|
| 207 |
+
'service': inc.get('service', 'Unknown'),
|
| 208 |
+
'severity': inc.get('severity', 1),
|
| 209 |
+
'type': inc.get('type', 'incident'),
|
| 210 |
+
'description': inc.get('description', ''),
|
| 211 |
+
'id': inc.get('id', '')
|
| 212 |
+
})
|
| 213 |
+
|
| 214 |
+
df = pd.DataFrame(timeline_data)
|
| 215 |
+
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
| 216 |
+
df = df.sort_values('timestamp')
|
| 217 |
+
|
| 218 |
+
# Map severity to colors and sizes
|
| 219 |
+
severity_colors = {1: 'green', 2: 'orange', 3: 'red'}
|
| 220 |
+
|
| 221 |
+
fig = go.Figure()
|
| 222 |
+
|
| 223 |
+
# Group by service for better visualization
|
| 224 |
+
services = df['service'].unique()[:10] # Limit to 10 services for clarity
|
| 225 |
+
|
| 226 |
+
for service in services:
|
| 227 |
+
service_df = df[df['service'] == service]
|
| 228 |
+
fig.add_trace(go.Scatter(
|
| 229 |
+
x=service_df['timestamp'],
|
| 230 |
+
y=[service] * len(service_df),
|
| 231 |
+
mode='markers',
|
| 232 |
+
name=service,
|
| 233 |
+
marker=dict(
|
| 234 |
+
size=[min(s * 10, 30) for s in service_df['severity']],
|
| 235 |
+
color=[severity_colors.get(s, 'gray') for s in service_df['severity']],
|
| 236 |
+
symbol='circle',
|
| 237 |
+
line=dict(width=1, color='white')
|
| 238 |
+
),
|
| 239 |
+
text=[f"<b>{row['service']}</b><br>Severity: {row['severity']}/3<br>Time: {row['timestamp'].strftime('%H:%M')}"
|
| 240 |
+
for _, row in service_df.iterrows()],
|
| 241 |
+
hoverinfo='text'
|
| 242 |
+
))
|
| 243 |
+
|
| 244 |
+
fig.update_layout(
|
| 245 |
+
title="Incident Timeline (Recent)",
|
| 246 |
+
xaxis_title="Time",
|
| 247 |
+
yaxis_title="Service",
|
| 248 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 249 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 250 |
+
height=400,
|
| 251 |
+
hovermode='closest',
|
| 252 |
+
showlegend=True
|
| 253 |
+
)
|
| 254 |
+
|
| 255 |
+
return fig
|
| 256 |
+
except Exception as e:
|
| 257 |
+
logger.error(f"Error creating incident timeline: {e}")
|
| 258 |
+
return self._create_empty_figure("Could not generate timeline")
|
| 259 |
|
| 260 |
def create_execution_history_chart(self, executions: List[Dict]) -> go.Figure:
|
| 261 |
"""Create execution history visualization"""
|
| 262 |
+
try:
|
| 263 |
+
if not executions:
|
| 264 |
+
return self._create_empty_figure("No execution history available")
|
| 265 |
+
|
| 266 |
+
# Prepare data
|
| 267 |
+
timeline_data = []
|
| 268 |
+
for exec in executions[-20:]: # Limit to last 20 executions
|
| 269 |
+
timeline_data.append({
|
| 270 |
+
'timestamp': exec.get('timestamp', datetime.datetime.now()),
|
| 271 |
+
'scenario': exec.get('scenario', 'Unknown'),
|
| 272 |
+
'actions': exec.get('actions', 0),
|
| 273 |
+
'status': exec.get('status', ''),
|
| 274 |
+
'time_savings': exec.get('time_savings', ''),
|
| 275 |
+
'cost_saved': exec.get('cost_saved', '$0')
|
| 276 |
+
})
|
| 277 |
+
|
| 278 |
+
df = pd.DataFrame(timeline_data)
|
| 279 |
+
df['timestamp'] = pd.to_datetime(df['timestamp'])
|
| 280 |
+
df = df.sort_values('timestamp')
|
| 281 |
+
|
| 282 |
+
fig = make_subplots(
|
| 283 |
+
rows=2, cols=1,
|
| 284 |
+
subplot_titles=('Execution Timeline', 'Cost Savings Over Time'),
|
| 285 |
+
vertical_spacing=0.15,
|
| 286 |
+
row_heights=[0.6, 0.4]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 287 |
)
|
| 288 |
+
|
| 289 |
+
# Timeline - only show if we have data
|
| 290 |
+
if not df.empty:
|
| 291 |
+
# Convert actions to numeric if possible
|
| 292 |
+
df['actions_numeric'] = pd.to_numeric(df['actions'], errors='coerce').fillna(0)
|
| 293 |
+
|
| 294 |
+
fig.add_trace(
|
| 295 |
+
go.Scatter(
|
| 296 |
+
x=df['timestamp'],
|
| 297 |
+
y=df['actions_numeric'],
|
| 298 |
+
mode='lines+markers',
|
| 299 |
+
name='Actions',
|
| 300 |
+
marker=dict(size=8),
|
| 301 |
+
line=dict(color='blue', width=2),
|
| 302 |
+
text=[f"<b>{row['scenario']}</b><br>Actions: {row['actions']}<br>Status: {row['status']}"
|
| 303 |
+
for _, row in df.iterrows()],
|
| 304 |
+
hoverinfo='text'
|
| 305 |
+
),
|
| 306 |
+
row=1, col=1
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
+
# Cost savings
|
| 310 |
+
if not df.empty:
|
| 311 |
+
df['cost_numeric'] = df['cost_saved'].apply(
|
| 312 |
+
lambda x: float(str(x).replace('$', '').replace(',', '').split('.')[0])
|
| 313 |
+
if isinstance(x, str) and '$' in x else 0
|
| 314 |
+
)
|
| 315 |
+
|
| 316 |
+
fig.add_trace(
|
| 317 |
+
go.Bar(
|
| 318 |
+
x=df['timestamp'],
|
| 319 |
+
y=df['cost_numeric'],
|
| 320 |
+
name='Cost Saved',
|
| 321 |
+
marker_color='lightseagreen',
|
| 322 |
+
text=[f"${x:,.0f}" for x in df['cost_numeric']],
|
| 323 |
+
textposition='outside'
|
| 324 |
+
),
|
| 325 |
+
row=2, col=1
|
| 326 |
+
)
|
| 327 |
+
|
| 328 |
+
fig.update_layout(
|
| 329 |
+
height=500,
|
| 330 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 331 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 332 |
+
showlegend=True
|
| 333 |
+
)
|
| 334 |
+
|
| 335 |
+
fig.update_xaxes(title_text="Time", row=1, col=1)
|
| 336 |
+
fig.update_xaxes(title_text="Time", row=2, col=1)
|
| 337 |
+
fig.update_yaxes(title_text="Actions", row=1, col=1)
|
| 338 |
+
fig.update_yaxes(title_text="Cost Saved ($)", row=2, col=1)
|
| 339 |
+
|
| 340 |
+
return fig
|
| 341 |
+
except Exception as e:
|
| 342 |
+
logger.error(f"Error creating execution chart: {e}")
|
| 343 |
+
return self._create_empty_figure("Could not generate execution chart")
|
| 344 |
|
| 345 |
def create_stream_graph(self, metrics_history: List[Dict]) -> go.Figure:
|
| 346 |
"""Create streaming metrics visualization"""
|
| 347 |
+
try:
|
| 348 |
+
if not metrics_history:
|
| 349 |
+
return self._create_empty_figure("No metrics history available")
|
| 350 |
+
|
| 351 |
+
df = pd.DataFrame(metrics_history[-50:])
|
| 352 |
+
|
| 353 |
+
fig = go.Figure()
|
| 354 |
+
|
| 355 |
+
# Add each metric as a separate trace
|
| 356 |
+
colors = px.colors.qualitative.Set3
|
| 357 |
+
for idx, column in enumerate(df.columns):
|
| 358 |
+
if column != 'timestamp' and column in df.columns:
|
| 359 |
+
fig.add_trace(go.Scatter(
|
| 360 |
+
x=df['timestamp'],
|
| 361 |
+
y=df[column],
|
| 362 |
+
mode='lines+markers',
|
| 363 |
+
name=column,
|
| 364 |
+
line=dict(color=colors[idx % len(colors)], width=2),
|
| 365 |
+
marker=dict(size=4)
|
| 366 |
+
))
|
| 367 |
+
|
| 368 |
+
fig.update_layout(
|
| 369 |
+
title="Real-time Metrics Stream",
|
| 370 |
+
xaxis_title="Time",
|
| 371 |
+
yaxis_title="Value",
|
| 372 |
+
hovermode='x unified',
|
| 373 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 374 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 375 |
+
height=400,
|
| 376 |
+
legend=dict(yanchor="top", y=0.99, xanchor="left", x=0.01)
|
|
|
|
|
|
|
|
|
|
| 377 |
)
|
| 378 |
+
|
| 379 |
+
return fig
|
| 380 |
+
except Exception as e:
|
| 381 |
+
logger.error(f"Error creating stream graph: {e}")
|
| 382 |
+
return self._create_empty_figure("Could not generate stream graph")
|
| 383 |
|
| 384 |
+
def create_predictive_timeline(self) -> go.Figure:
|
| 385 |
"""Create predictive analytics timeline"""
|
| 386 |
+
try:
|
| 387 |
+
# Create sample data for demo
|
| 388 |
+
now = datetime.datetime.now()
|
| 389 |
+
|
| 390 |
+
# Actual incidents (past)
|
| 391 |
+
actual_times = [now - datetime.timedelta(hours=i) for i in range(24, 0, -4)]
|
| 392 |
+
actual_services = ['API Gateway', 'Database', 'Cache', 'Auth Service', 'Payment Service', 'Order Service']
|
| 393 |
+
|
| 394 |
+
# Predicted incidents (future)
|
| 395 |
+
pred_times = [now + datetime.timedelta(hours=i) for i in range(1, 25, 4)]
|
| 396 |
+
pred_services = ['Database', 'Cache', 'API Gateway', 'Auth Service', 'Payment Service', 'Order Service']
|
| 397 |
+
|
| 398 |
+
fig = go.Figure()
|
| 399 |
+
|
| 400 |
+
# Add actual incidents
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 401 |
fig.add_trace(go.Scatter(
|
| 402 |
+
x=actual_times,
|
| 403 |
+
y=[random.randint(1, 3) for _ in actual_times],
|
| 404 |
+
mode='markers',
|
| 405 |
+
name='Actual',
|
| 406 |
+
marker=dict(color='red', size=15, symbol='circle', line=dict(width=2, color='darkred')),
|
| 407 |
+
text=actual_services[:len(actual_times)],
|
| 408 |
+
hovertemplate="<b>%{text}</b><br>Time: %{x}<br>Severity: %{y}<extra></extra>"
|
| 409 |
))
|
| 410 |
+
|
| 411 |
+
# Add predicted incidents
|
| 412 |
+
fig.add_trace(go.Scatter(
|
| 413 |
+
x=pred_times,
|
| 414 |
+
y=[random.randint(1, 3) for _ in pred_times],
|
| 415 |
+
mode='markers',
|
| 416 |
+
name='Predicted',
|
| 417 |
+
marker=dict(color='orange', size=15, symbol='diamond', line=dict(width=2, color='darkorange')),
|
| 418 |
+
text=pred_services[:len(pred_times)],
|
| 419 |
+
hovertemplate="<b>%{text}</b><br>Time: %{x}<br>Severity: %{y}<extra></extra>"
|
| 420 |
+
))
|
| 421 |
+
|
| 422 |
+
fig.update_layout(
|
| 423 |
+
title="Predictive Analytics Timeline",
|
| 424 |
+
xaxis_title="Time",
|
| 425 |
+
yaxis_title="Incident Severity",
|
| 426 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 427 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 428 |
+
height=400,
|
| 429 |
+
hovermode='closest'
|
| 430 |
+
)
|
| 431 |
+
|
| 432 |
+
return fig
|
| 433 |
+
except Exception as e:
|
| 434 |
+
logger.error(f"Error creating predictive timeline: {e}")
|
| 435 |
+
return self._create_empty_figure("Predictive analytics unavailable")
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
def create_performance_overview(self) -> go.Figure:
|
| 438 |
+
"""Create performance overview visualization"""
|
| 439 |
+
try:
|
| 440 |
+
metrics = {
|
| 441 |
+
"System Uptime": 99.95,
|
| 442 |
+
"Auto-Heal Success": 94.2,
|
| 443 |
+
"MTTR Reduction": 85.7,
|
| 444 |
+
"Cost Savings": 92.5,
|
| 445 |
+
"Incident Prevention": 78.3,
|
| 446 |
+
"ROI Multiplier": 88.5
|
| 447 |
+
}
|
| 448 |
+
return self.create_performance_radar(metrics)
|
| 449 |
+
except Exception as e:
|
| 450 |
+
logger.error(f"Error creating performance overview: {e}")
|
| 451 |
+
return self._create_empty_figure("Performance overview unavailable")
|
| 452 |
|
| 453 |
def create_learning_insights(self) -> go.Figure:
|
| 454 |
"""Create learning engine insights visualization"""
|
| 455 |
+
try:
|
| 456 |
+
patterns = [
|
| 457 |
+
{"pattern": "DB Connection Leak", "occurrences": 42, "auto_fixed": 38},
|
| 458 |
+
{"pattern": "Cache Stampede", "occurrences": 28, "auto_fixed": 25},
|
| 459 |
+
{"pattern": "Rate Limit Exceeded", "occurrences": 35, "auto_fixed": 32},
|
| 460 |
+
{"pattern": "Memory Leak", "occurrences": 19, "auto_fixed": 17},
|
| 461 |
+
{"pattern": "Cascading Failure", "occurrences": 12, "auto_fixed": 11}
|
| 462 |
+
]
|
| 463 |
+
|
| 464 |
+
fig = go.Figure(data=[
|
| 465 |
+
go.Bar(
|
| 466 |
+
name='Total Occurrences',
|
| 467 |
+
x=[p['pattern'] for p in patterns],
|
| 468 |
+
y=[p['occurrences'] for p in patterns],
|
| 469 |
+
marker_color='indianred'
|
| 470 |
+
),
|
| 471 |
+
go.Bar(
|
| 472 |
+
name='Auto-Fixed',
|
| 473 |
+
x=[p['pattern'] for p in patterns],
|
| 474 |
+
y=[p['auto_fixed'] for p in patterns],
|
| 475 |
+
marker_color='lightseagreen'
|
| 476 |
+
)
|
| 477 |
+
])
|
| 478 |
+
|
| 479 |
+
fig.update_layout(
|
| 480 |
+
title="Learning Engine: Patterns Discovered & Auto-Fixed",
|
| 481 |
+
barmode='group',
|
| 482 |
+
paper_bgcolor='rgba(0,0,0,0)',
|
| 483 |
+
plot_bgcolor='rgba(0,0,0,0)',
|
| 484 |
+
height=400,
|
| 485 |
+
legend=dict(yanchor="top", y=0.99, xanchor="left", x=0.01)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 486 |
)
|
| 487 |
+
|
| 488 |
+
return fig
|
| 489 |
+
except Exception as e:
|
| 490 |
+
logger.error(f"Error creating learning insights: {e}")
|
| 491 |
+
return self._create_empty_figure("Learning insights unavailable")
|
| 492 |
|
| 493 |
def _create_empty_figure(self, message: str) -> go.Figure:
|
| 494 |
"""Create an empty figure with a message"""
|
|
|
|
| 512 |
return fig
|
| 513 |
|
| 514 |
# ===========================================
|
| 515 |
+
# INCIDENT SCENARIOS DATABASE
|
| 516 |
# ===========================================
|
| 517 |
|
| 518 |
class IncidentScenarios:
|
|
|
|
| 766 |
"enterprise_actions": [],
|
| 767 |
"execution_results": {}
|
| 768 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 769 |
|
| 770 |
# ===========================================
|
| 771 |
+
# SIMPLE OSS & ENTERPRISE MODELS
|
| 772 |
# ===========================================
|
| 773 |
|
| 774 |
class OSSModel:
|
| 775 |
"""OSS Edition Model (Advisory Only)"""
|
| 776 |
|
| 777 |
def __init__(self):
|
| 778 |
+
self.healing_intent = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 779 |
|
| 780 |
def analyze_and_recommend(self, scenario: Dict) -> Dict[str, Any]:
|
| 781 |
"""Analyze incident and provide recommendations"""
|
| 782 |
try:
|
| 783 |
+
return {
|
| 784 |
+
"analysis": "✅ Analysis complete",
|
| 785 |
+
"recommendations": scenario.get("oss_recommendation", "No specific recommendations"),
|
| 786 |
+
"healing_intent": "create_scale_out_intent",
|
| 787 |
+
"estimated_impact": scenario.get("business_impact", {}).get("recovery_time_oss", "30-60 minutes"),
|
| 788 |
+
"action_required": "Manual implementation required",
|
| 789 |
+
"team_effort": "2-3 engineers needed",
|
| 790 |
+
"total_cost": scenario.get("business_impact", {}).get("total_impact", "$Unknown")
|
| 791 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 792 |
except Exception as e:
|
| 793 |
logger.error(f"OSS analysis failed: {e}")
|
| 794 |
return {
|
|
|
|
| 806 |
|
| 807 |
def __init__(self, viz_engine):
|
| 808 |
self.execution_history = []
|
|
|
|
| 809 |
self.viz_engine = viz_engine
|
| 810 |
|
| 811 |
def execute_healing(self, scenario: Dict, approval_required: bool = True) -> Dict[str, Any]:
|
|
|
|
| 822 |
else:
|
| 823 |
status = "✅ Auto-Executed"
|
| 824 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
# Calculate time savings
|
| 826 |
oss_time = scenario.get("business_impact", {}).get("recovery_time_oss", "60 minutes")
|
| 827 |
ent_time = scenario.get("business_impact", {}).get("recovery_time_enterprise", "10 minutes")
|
|
|
|
| 867 |
"audit_trail_created": False
|
| 868 |
}
|
| 869 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 870 |
# ===========================================
|
| 871 |
+
# ROI CALCULATOR FOR 5.2× ROI
|
| 872 |
# ===========================================
|
| 873 |
|
| 874 |
class ROICalculator:
|
| 875 |
+
"""Enhanced ROI calculator with business metrics"""
|
| 876 |
|
| 877 |
@staticmethod
|
| 878 |
+
def calculate_roi() -> Dict[str, Any]:
|
| 879 |
+
"""Calculate ROI - SIMPLIFIED VERSION"""
|
| 880 |
+
try:
|
| 881 |
+
# Simplified calculation for demo
|
| 882 |
+
enterprise_cost = 1000000 # $1M annual cost
|
| 883 |
+
annual_savings = 6200000 # $6.2M savings (5.2× ROI)
|
| 884 |
+
|
| 885 |
+
roi_multiplier = annual_savings / enterprise_cost
|
| 886 |
+
roi_percentage = (roi_multiplier - 1) * 100
|
| 887 |
+
|
| 888 |
+
return {
|
| 889 |
+
"total_annual_impact": "$2,960,100",
|
| 890 |
+
"enterprise_annual_savings": f"${annual_savings:,.0f}",
|
| 891 |
+
"enterprise_annual_cost": f"${enterprise_cost:,.0f}",
|
| 892 |
+
"roi_percentage": f"{roi_percentage:.1f}%",
|
| 893 |
+
"roi_multiplier": f"{roi_multiplier:.1f}×",
|
| 894 |
+
"incidents_resolved_annually": 260,
|
| 895 |
+
"avg_resolution_time_oss": "45 minutes",
|
| 896 |
+
"avg_resolution_time_enterprise": "8 minutes",
|
| 897 |
+
"savings_per_incident": "$23,846",
|
| 898 |
+
"payback_period": "2-3 months",
|
| 899 |
+
"key_metric": "5.2× first year ROI (enterprise average)"
|
| 900 |
+
}
|
| 901 |
+
except Exception as e:
|
| 902 |
+
logger.error(f"ROI calculation failed: {e}")
|
| 903 |
+
return {
|
| 904 |
+
"error": "ROI calculation unavailable",
|
| 905 |
+
"roi_multiplier": "5.2×",
|
| 906 |
+
"enterprise_annual_savings": "$6,200,000"
|
| 907 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 908 |
|
| 909 |
# ===========================================
|
| 910 |
+
# MAIN APPLICATION - SIMPLIFIED
|
| 911 |
# ===========================================
|
| 912 |
|
| 913 |
class ARFUltimateInvestorDemo:
|
|
|
|
| 925 |
|
| 926 |
def _init_incident_history(self):
|
| 927 |
"""Initialize sample incident history for visualizations"""
|
| 928 |
+
services = ["API Gateway", "Database", "Cache", "Auth Service", "Payment Service",
|
| 929 |
+
"Order Service", "User Service", "Session Service", "External API",
|
| 930 |
+
"Product Catalog", "Search Service", "Notification Service", "Inventory Service"]
|
| 931 |
+
|
| 932 |
scenario_names = list(self.incident_scenarios.SCENARIOS.keys())
|
| 933 |
|
| 934 |
+
for i in range(30): # Create 30 sample incidents
|
| 935 |
hour = random.randint(0, 23)
|
| 936 |
+
severity = random.choices([1, 2, 3], weights=[0.5, 0.3, 0.2])[0]
|
| 937 |
|
| 938 |
+
scenario = random.choice(scenario_names)
|
| 939 |
+
scenario_data = self.incident_scenarios.get_scenario(scenario)
|
| 940 |
+
|
| 941 |
+
incident_record = {
|
| 942 |
+
"timestamp": datetime.datetime.now() - datetime.timedelta(hours=random.randint(1, 48)),
|
| 943 |
+
"hour": hour,
|
| 944 |
+
"service": random.choice(services),
|
| 945 |
+
"severity": severity,
|
| 946 |
+
"type": scenario_data.get("name", "incident"),
|
| 947 |
+
"description": scenario_data.get("description", ""),
|
| 948 |
+
"scenario_id": scenario,
|
| 949 |
+
"id": str(uuid.uuid4())[:8]
|
| 950 |
+
}
|
| 951 |
+
|
| 952 |
+
self.viz_engine.add_to_history(incident_record)
|
|
|
|
| 953 |
|
| 954 |
def create_demo_interface(self):
|
| 955 |
+
"""Create the main Gradio interface"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 956 |
|
| 957 |
+
with gr.Blocks(title="🚀 ARF Ultimate Investor Demo v3.4.0") as demo:
|
| 958 |
|
| 959 |
# ============ HEADER ============
|
| 960 |
+
with gr.Column():
|
| 961 |
gr.Markdown("""
|
| 962 |
# 🚀 Agentic Reliability Framework - Ultimate Investor Demo v3.4.0
|
| 963 |
### From Cost Center to Profit Engine: 5.2× ROI with Autonomous Reliability
|
|
|
|
| 1008 |
|
| 1009 |
with gr.Column(scale=3):
|
| 1010 |
# OSS Analysis
|
| 1011 |
+
with gr.Group():
|
| 1012 |
gr.Markdown("### 🤖 OSS: Analyze & Recommend")
|
| 1013 |
oss_analyze_btn = gr.Button("🚀 Run OSS Analysis", variant="secondary")
|
| 1014 |
oss_results = gr.JSON(label="OSS Analysis Results", value={})
|
| 1015 |
|
| 1016 |
# Enterprise Execution
|
| 1017 |
+
with gr.Group():
|
| 1018 |
gr.Markdown("### 🚀 Enterprise: Execute Healing")
|
| 1019 |
|
| 1020 |
with gr.Row():
|
|
|
|
| 1065 |
refresh_history_btn = gr.Button("🔄 Refresh History", variant="secondary", size="sm")
|
| 1066 |
clear_history_btn = gr.Button("🗑️ Clear History", variant="stop", size="sm")
|
| 1067 |
|
|
|
|
| 1068 |
incident_history_table = gr.Dataframe(
|
| 1069 |
label="Incident Log",
|
| 1070 |
headers=["Time", "Service", "Type", "Severity", "Description"],
|
|
|
|
| 1085 |
refresh_executions_btn = gr.Button("🔄 Refresh Executions", variant="secondary", size="sm")
|
| 1086 |
export_audit_btn = gr.Button("📥 Export Audit Trail", variant="secondary", size="sm")
|
| 1087 |
|
|
|
|
| 1088 |
execution_history_table = gr.Dataframe(
|
| 1089 |
label="Execution Audit Trail",
|
| 1090 |
headers=["Time", "Scenario", "Actions", "Status", "Time Saved", "Cost Saved"],
|
|
|
|
| 1097 |
gr.Markdown("### 📈 Execution History Chart")
|
| 1098 |
execution_history_chart = gr.Plot()
|
| 1099 |
|
| 1100 |
+
# ============ TAB 4: CAPABILITY MATRIX ============
|
| 1101 |
with gr.TabItem("📊 Capability Matrix"):
|
| 1102 |
with gr.Column():
|
| 1103 |
gr.Markdown("### 🚀 Ready to transform your reliability operations?")
|
|
|
|
| 1134 |
|
| 1135 |
# Quick demo buttons
|
| 1136 |
with gr.Row():
|
| 1137 |
+
run_oss_demo = gr.Button("🆓 Run OSS Demo Incident", variant="secondary", size="sm")
|
| 1138 |
+
run_enterprise_demo = gr.Button("🚀 Run Enterprise Demo Incident", variant="primary", size="sm")
|
| 1139 |
|
| 1140 |
# ROI Calculator
|
| 1141 |
with gr.Accordion("📈 Calculate Your Potential ROI", open=False):
|
|
|
|
| 1161 |
|
| 1162 |
def update_scenario_enhanced(scenario_id: str, viz_type: str):
|
| 1163 |
"""Update all displays based on selected scenario"""
|
| 1164 |
+
try:
|
| 1165 |
+
scenario = self.incident_scenarios.get_scenario(scenario_id)
|
| 1166 |
+
|
| 1167 |
+
# Update metrics display
|
| 1168 |
+
metrics = scenario.get("current_metrics", {})
|
| 1169 |
+
business_impact_data = scenario.get("business_impact", {})
|
| 1170 |
+
|
| 1171 |
+
# Create visualization based on type
|
| 1172 |
+
if viz_type == "Radar Chart":
|
| 1173 |
+
viz = self.viz_engine.create_performance_radar(metrics)
|
| 1174 |
+
elif viz_type == "Heatmap":
|
| 1175 |
+
viz = self.viz_engine.create_heatmap_timeline(self.viz_engine.incident_history)
|
| 1176 |
+
elif viz_type == "Incident Timeline":
|
| 1177 |
+
viz = self.viz_engine.create_incident_timeline(self.viz_engine.incident_history)
|
| 1178 |
+
else: # Stream
|
| 1179 |
+
# Create sample stream data
|
| 1180 |
+
stream_data = []
|
| 1181 |
+
for i in range(24):
|
| 1182 |
+
data_point = {"timestamp": f"{i:02d}:00"}
|
| 1183 |
+
for key, value in metrics.items():
|
| 1184 |
+
if isinstance(value, (int, float)):
|
| 1185 |
+
variation = random.uniform(-0.1, 0.1) * value
|
| 1186 |
+
data_point[key] = max(0, value + variation)
|
| 1187 |
+
stream_data.append(data_point)
|
| 1188 |
+
viz = self.viz_engine.create_stream_graph(stream_data)
|
| 1189 |
+
|
| 1190 |
+
# Update heatmap
|
| 1191 |
+
incident_heatmap = self.viz_engine.create_heatmap_timeline(self.viz_engine.incident_history)
|
| 1192 |
+
|
| 1193 |
+
return {
|
| 1194 |
+
metrics_display: metrics,
|
| 1195 |
+
business_impact: business_impact_data,
|
| 1196 |
+
visualization_output: viz,
|
| 1197 |
+
heatmap_output: incident_heatmap
|
| 1198 |
+
}
|
| 1199 |
+
except Exception as e:
|
| 1200 |
+
logger.error(f"Error updating scenario: {e}")
|
| 1201 |
+
empty_fig = self.viz_engine._create_empty_figure("Visualization unavailable")
|
| 1202 |
+
return {
|
| 1203 |
+
metrics_display: {},
|
| 1204 |
+
business_impact: {},
|
| 1205 |
+
visualization_output: empty_fig,
|
| 1206 |
+
heatmap_output: empty_fig
|
| 1207 |
+
}
|
| 1208 |
|
| 1209 |
def get_incident_history_data():
|
| 1210 |
"""Get formatted incident history for table"""
|
| 1211 |
+
try:
|
| 1212 |
+
incidents = self.viz_engine.get_incident_history(limit=20)
|
| 1213 |
+
formatted_data = []
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1214 |
|
| 1215 |
+
for inc in incidents:
|
| 1216 |
+
timestamp = inc.get('timestamp', datetime.datetime.now())
|
| 1217 |
+
if isinstance(timestamp, str):
|
| 1218 |
+
try:
|
| 1219 |
+
timestamp = datetime.datetime.fromisoformat(timestamp.replace('Z', '+00:00'))
|
| 1220 |
+
except:
|
| 1221 |
+
timestamp = datetime.datetime.now()
|
| 1222 |
+
|
| 1223 |
+
desc = inc.get('description', '')
|
| 1224 |
+
if len(desc) > 50:
|
| 1225 |
+
desc = desc[:47] + '...'
|
| 1226 |
+
|
| 1227 |
+
formatted_data.append([
|
| 1228 |
+
timestamp.strftime('%H:%M'),
|
| 1229 |
+
inc.get('service', 'Unknown'),
|
| 1230 |
+
inc.get('type', 'incident'),
|
| 1231 |
+
f"{inc.get('severity', 1)}/3",
|
| 1232 |
+
desc
|
| 1233 |
+
])
|
| 1234 |
+
|
| 1235 |
+
return formatted_data
|
| 1236 |
+
except Exception as e:
|
| 1237 |
+
logger.error(f"Error getting incident history: {e}")
|
| 1238 |
+
return []
|
| 1239 |
|
| 1240 |
def get_execution_history_data():
|
| 1241 |
"""Get formatted execution history for table"""
|
| 1242 |
+
try:
|
| 1243 |
+
executions = self.viz_engine.get_execution_history(limit=20)
|
| 1244 |
+
formatted_data = []
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1245 |
|
| 1246 |
+
for exec in executions:
|
| 1247 |
+
timestamp = exec.get('timestamp', datetime.datetime.now())
|
| 1248 |
+
if isinstance(timestamp, str):
|
| 1249 |
+
try:
|
| 1250 |
+
timestamp = datetime.datetime.fromisoformat(timestamp.replace('Z', '+00:00'))
|
| 1251 |
+
except:
|
| 1252 |
+
timestamp = datetime.datetime.now()
|
| 1253 |
+
|
| 1254 |
+
formatted_data.append([
|
| 1255 |
+
timestamp.strftime('%H:%M'),
|
| 1256 |
+
exec.get('scenario', 'Unknown'),
|
| 1257 |
+
str(exec.get('actions', 0)),
|
| 1258 |
+
exec.get('status', ''),
|
| 1259 |
+
exec.get('time_savings', 'N/A'),
|
| 1260 |
+
exec.get('cost_saved', '$0')
|
| 1261 |
+
])
|
| 1262 |
+
|
| 1263 |
+
return formatted_data
|
| 1264 |
+
except Exception as e:
|
| 1265 |
+
logger.error(f"Error getting execution history: {e}")
|
| 1266 |
+
return []
|
| 1267 |
|
| 1268 |
def refresh_history():
|
| 1269 |
"""Refresh history displays"""
|
| 1270 |
+
try:
|
| 1271 |
+
incident_data = get_incident_history_data()
|
| 1272 |
+
execution_data = get_execution_history_data()
|
| 1273 |
+
incident_timeline = self.viz_engine.create_incident_timeline(self.viz_engine.incident_history)
|
| 1274 |
+
execution_chart = self.viz_engine.create_execution_history_chart(self.viz_engine.execution_history)
|
| 1275 |
+
|
| 1276 |
+
return {
|
| 1277 |
+
incident_history_table: incident_data,
|
| 1278 |
+
execution_history_table: execution_data,
|
| 1279 |
+
incident_timeline_viz: incident_timeline,
|
| 1280 |
+
execution_history_chart: execution_chart
|
| 1281 |
+
}
|
| 1282 |
+
except Exception as e:
|
| 1283 |
+
logger.error(f"Error refreshing history: {e}")
|
| 1284 |
+
empty_fig = self.viz_engine._create_empty_figure("History unavailable")
|
| 1285 |
+
return {
|
| 1286 |
+
incident_history_table: [],
|
| 1287 |
+
execution_history_table: [],
|
| 1288 |
+
incident_timeline_viz: empty_fig,
|
| 1289 |
+
execution_history_chart: empty_fig
|
| 1290 |
+
}
|
| 1291 |
|
| 1292 |
def clear_history():
|
| 1293 |
"""Clear all history"""
|
| 1294 |
+
try:
|
| 1295 |
+
self.viz_engine.incident_history.clear()
|
| 1296 |
+
self.viz_engine.execution_history.clear()
|
| 1297 |
+
return refresh_history()
|
| 1298 |
+
except Exception as e:
|
| 1299 |
+
logger.error(f"Error clearing history: {e}")
|
| 1300 |
+
return refresh_history()
|
| 1301 |
|
| 1302 |
def run_oss_analysis(scenario_id: str):
|
| 1303 |
"""Run OSS analysis on selected scenario"""
|
| 1304 |
+
try:
|
| 1305 |
+
scenario = self.incident_scenarios.get_scenario(scenario_id)
|
| 1306 |
+
analysis = self.oss_model.analyze_and_recommend(scenario)
|
| 1307 |
+
return {oss_results: analysis}
|
| 1308 |
+
except Exception as e:
|
| 1309 |
+
logger.error(f"Error in OSS analysis: {e}")
|
| 1310 |
+
return {oss_results: {"error": "Analysis failed"}}
|
| 1311 |
|
| 1312 |
def run_enterprise_execution(scenario_id: str, approval_required: bool):
|
| 1313 |
"""Execute enterprise healing actions"""
|
| 1314 |
+
try:
|
| 1315 |
+
scenario = self.incident_scenarios.get_scenario(scenario_id)
|
| 1316 |
+
results = self.enterprise_model.execute_healing(scenario, approval_required)
|
| 1317 |
+
|
| 1318 |
+
# Update ROI
|
| 1319 |
+
roi = self.roi_calculator.calculate_roi()
|
| 1320 |
+
|
| 1321 |
+
# Update visualizations
|
| 1322 |
+
predictive_viz = self.viz_engine.create_predictive_timeline()
|
| 1323 |
+
|
| 1324 |
+
# Also update history
|
| 1325 |
+
history_update = refresh_history()
|
| 1326 |
+
|
| 1327 |
+
return {
|
| 1328 |
+
enterprise_results: results,
|
| 1329 |
+
roi_results: roi,
|
| 1330 |
+
predictive_timeline: predictive_viz,
|
| 1331 |
+
**history_update
|
| 1332 |
+
}
|
| 1333 |
+
except Exception as e:
|
| 1334 |
+
logger.error(f"Error in enterprise execution: {e}")
|
| 1335 |
+
return {
|
| 1336 |
+
enterprise_results: {"error": "Execution failed"},
|
| 1337 |
+
roi_results: self.roi_calculator.calculate_roi(),
|
| 1338 |
+
predictive_timeline: self.viz_engine._create_empty_figure("Visualization unavailable"),
|
| 1339 |
+
incident_history_table: [],
|
| 1340 |
+
execution_history_table: [],
|
| 1341 |
+
incident_timeline_viz: self.viz_engine._create_empty_figure("Visualization unavailable"),
|
| 1342 |
+
execution_history_chart: self.viz_engine._create_empty_figure("Visualization unavailable")
|
| 1343 |
+
}
|
| 1344 |
|
| 1345 |
def calculate_comprehensive_roi():
|
| 1346 |
"""Calculate comprehensive ROI"""
|
| 1347 |
+
try:
|
| 1348 |
+
roi = self.roi_calculator.calculate_roi()
|
| 1349 |
+
|
| 1350 |
+
# Update performance radar with ROI metrics
|
| 1351 |
+
performance_viz = self.viz_engine.create_performance_overview()
|
| 1352 |
+
learning_viz = self.viz_engine.create_learning_insights()
|
| 1353 |
+
|
| 1354 |
+
return {
|
| 1355 |
+
roi_results: roi,
|
| 1356 |
+
performance_radar: performance_viz,
|
| 1357 |
+
learning_insights: learning_viz
|
| 1358 |
+
}
|
| 1359 |
+
except Exception as e:
|
| 1360 |
+
logger.error(f"Error calculating ROI: {e}")
|
| 1361 |
+
empty_fig = self.viz_engine._create_empty_figure("Visualization unavailable")
|
| 1362 |
+
return {
|
| 1363 |
+
roi_results: {"error": "ROI calculation failed"},
|
| 1364 |
+
performance_radar: empty_fig,
|
| 1365 |
+
learning_insights: empty_fig
|
| 1366 |
+
}
|
| 1367 |
|
| 1368 |
def update_capability_demo(selected):
|
| 1369 |
"""Update capability demo based on selection"""
|
|
|
|
| 1469 |
|
| 1470 |
def calculate_custom_roi(incidents, impact, team_size):
|
| 1471 |
"""Calculate custom ROI based on user inputs"""
|
| 1472 |
+
try:
|
| 1473 |
+
annual_impact = incidents * 12 * impact
|
| 1474 |
+
enterprise_cost = team_size * 150000 # $150k per engineer
|
| 1475 |
+
enterprise_savings = annual_impact * 0.82 # 82% savings
|
| 1476 |
+
|
| 1477 |
+
if enterprise_cost > 0:
|
| 1478 |
+
roi_multiplier = enterprise_savings / enterprise_cost
|
| 1479 |
+
else:
|
| 1480 |
+
roi_multiplier = 0
|
| 1481 |
+
|
| 1482 |
+
# Determine recommendation
|
| 1483 |
+
if roi_multiplier >= 5.2:
|
| 1484 |
+
recommendation = "✅ Strong Enterprise ROI - 5.2×+ expected"
|
| 1485 |
+
elif roi_multiplier >= 2:
|
| 1486 |
+
recommendation = "✅ Good Enterprise ROI - 2-5× expected"
|
| 1487 |
+
elif roi_multiplier >= 1:
|
| 1488 |
+
recommendation = "⚠️ Marginal ROI - Consider OSS edition"
|
| 1489 |
+
else:
|
| 1490 |
+
recommendation = "❌ Negative ROI - Use OSS edition"
|
| 1491 |
+
|
| 1492 |
+
return {
|
| 1493 |
+
"custom_roi": {
|
| 1494 |
+
"your_annual_impact": f"${annual_impact:,.0f}",
|
| 1495 |
+
"your_team_cost": f"${enterprise_cost:,.0f}",
|
| 1496 |
+
"potential_savings": f"${enterprise_savings:,.0f}",
|
| 1497 |
+
"your_roi_multiplier": f"{roi_multiplier:.1f}×",
|
| 1498 |
+
"payback_period": f"{12/roi_multiplier:.1f} months" if roi_multiplier > 0 else "N/A",
|
| 1499 |
+
"recommendation": recommendation,
|
| 1500 |
+
"comparison": f"Industry average: 5.2× ROI"
|
| 1501 |
+
}
|
| 1502 |
}
|
| 1503 |
+
except Exception as e:
|
| 1504 |
+
logger.error(f"Error calculating custom ROI: {e}")
|
| 1505 |
+
return {"custom_roi": {"error": "Calculation failed"}}
|
| 1506 |
|
| 1507 |
# ============ EVENT BINDINGS ============
|
| 1508 |
|
|
|
|
| 1624 |
logger.info("🚀 Starting ARF Ultimate Investor Demo v3.4.0")
|
| 1625 |
logger.info("=" * 80)
|
| 1626 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1627 |
# Create and launch the application
|
| 1628 |
app = ARFUltimateInvestorDemo()
|
| 1629 |
demo = app.create_demo_interface()
|
| 1630 |
|
|
|
|
| 1631 |
demo.launch(
|
| 1632 |
server_name="0.0.0.0",
|
| 1633 |
server_port=7860,
|
| 1634 |
share=False,
|
| 1635 |
+
debug=False # Set to False to reduce noise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1636 |
)
|
| 1637 |
|
| 1638 |
if __name__ == "__main__":
|