petter2025's picture
Update demo/orchestrator.py
e992ee3 verified
raw
history blame
6.42 kB
"""
Enhanced demo orchestrator with real ARF integration patterns
"""
import streamlit as st
import time
import json
from datetime import datetime
from typing import Dict, Any, List, Optional
# Import mock ARF components
from .scenarios import get_scenario_data
from .mock_arf import (
create_mock_healing_intent,
run_rag_similarity_search,
calculate_pattern_confidence,
simulate_arf_analysis
)
def run_enhanced_incident_demo(scenario_name: str, execution_mode: str = "advisory"):
"""
Run enhanced incident demo with ARF integration
"""
# Get scenario data
scenario = get_scenario_data(scenario_name)
if not scenario:
st.error(f"Scenario '{scenario_name}' not found")
return
# Display incident header
st.markdown(f"### πŸ”₯ {scenario['name']}")
st.caption(scenario['description'])
# Create columns for metrics and business impact
col1, col2 = st.columns(2)
with col1:
st.markdown("#### πŸ“Š Current Metrics")
metrics = scenario.get('metrics', {})
# Create metrics display
metrics_cols = st.columns(2)
for idx, (key, value) in enumerate(metrics.items()):
with metrics_cols[idx % 2]:
if isinstance(value, (int, float)):
if key == "cache_hit_rate":
st.metric(label=key.replace('_', ' ').title(),
value=f"{value}%",
delta="-65%" if value < 20 else None)
elif key == "database_load":
st.metric(label=key.replace('_', ' ').title(),
value=f"{value}%",
delta="+40%" if value > 80 else None)
else:
st.metric(label=key.replace('_', ' ').title(), value=str(value))
with col2:
st.markdown("#### πŸ’° Business Impact")
impact = scenario.get('business_impact', {})
if impact.get('revenue_loss_per_hour'):
st.metric(
label="Revenue Loss/Hour",
value=f"${impact['revenue_loss_per_hour']:,.0f}",
delta_color="inverse"
)
if impact.get('sla_violation'):
st.error("⚠️ SLA Violation Detected")
if impact.get('affected_users'):
st.metric(
label="Affected Users",
value=f"{impact['affected_users']:,.0f}",
delta_color="inverse"
)
# Run ARF analysis
with st.spinner("🧠 ARF Analysis in progress..."):
time.sleep(1.5)
# Simulate ARF analysis pipeline
arf_analysis = simulate_arf_analysis(scenario)
# Run RAG similarity search
similar_incidents = run_rag_similarity_search(scenario)
# Calculate pattern confidence
pattern_confidence = calculate_pattern_confidence(scenario, similar_incidents)
# Create HealingIntent
healing_intent = create_mock_healing_intent(
scenario=scenario,
similar_incidents=similar_incidents,
confidence=pattern_confidence
)
# Display enhanced timeline with ARF integration
from ..ui.components import create_arf_enhanced_timeline
create_arf_enhanced_timeline(scenario, [healing_intent])
# Show HealingIntent visualizer
from ..ui.components import create_healing_intent_visualizer
create_healing_intent_visualizer(healing_intent)
# Show RAG similarity panel
from ..ui.components import create_rag_similarity_panel
create_rag_similarity_panel(
query=f"{scenario['name']} - {scenario['description']}",
similar_incidents=similar_incidents
)
# Show execution mode differences
from ..ui.components import create_execution_mode_toggle
selected_mode = create_execution_mode_toggle(execution_mode)
# Action buttons based on mode
st.markdown("---")
st.markdown("### ⚑ Take Action")
col1, col2, col3 = st.columns(3)
with col1:
if st.button("πŸ†“ Run OSS Analysis", use_container_width=True):
st.info("""
**OSS Analysis Results:**
- Incident identified: Cache miss storm
- Recommended action: Scale Redis cluster
- Confidence: 85%
- Similar incidents found: 3
*Note: OSS edition provides analysis only.*
""")
with col2:
if st.button("πŸš€ Execute Enterprise Healing", use_container_width=True):
if execution_mode == "advisory":
st.warning("""
**Enterprise Upgrade Required**
To execute healing actions, upgrade to Enterprise Edition:
- Autonomous healing capabilities
- Approval workflows
- Audit trails
- Compliance reporting
[Upgrade Now](https://arf.dev/enterprise)
""")
elif execution_mode == "approval":
st.success("""
**Healing Action Submitted for Approval**
βœ… HealingIntent created
πŸ“‹ Sent to approval workflow
πŸ‘€ Awaiting human review
πŸ• Estimated approval time: 2-5 minutes
""")
else: # autonomous
st.success("""
**Autonomous Healing Executed**
βœ… Redis cluster scaled from 3 to 5 nodes
βœ… Cache TTL adjusted to 300s
βœ… Database connections optimized
⚑ Resolution time: 8.2 minutes
πŸ’° Cost avoided: $7,225
""")
with col3:
if st.button("πŸ” Require Manual Approval", use_container_width=True):
st.info("""
**Approval Workflow Enabled**
This incident will require manual approval before execution:
1. SRE team notified via PagerDuty
2. Approval required from team lead
3. Audit trail recorded
4. Compliance checks run
*Enterprise feature: Human-in-the-loop safety*
""")