petter2025 commited on
Commit
a24bd74
Β·
verified Β·
1 Parent(s): 5c30134

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -13
app.py CHANGED
@@ -1109,16 +1109,30 @@ async def run_oss_analysis(scenario_name: str):
1109
  )
1110
 
1111
  # ===========================================
1112
- # REAL ENTERPRISE EXECUTION HANDLER
1113
  # ===========================================
1114
  def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value):
1115
- """Execute enterprise healing with real ARF"""
 
 
1116
  scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
1117
 
1118
  # Determine mode
1119
  mode = "Approval" if approval_required else "Autonomous"
1120
  if "Advisory" in mcp_mode_value:
1121
- return gr.HTML.update(value="<div style='padding: 20px; background: #fef2f2; border-radius: 14px;'><p>❌ Cannot execute in Advisory mode. Switch to Approval or Autonomous mode.</p></div>"), {}, []
 
 
 
 
 
 
 
 
 
 
 
 
1122
 
1123
  # Calculate savings based on scenario
1124
  impact = scenario.get("business_impact", {})
@@ -1153,13 +1167,13 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)
1153
  """
1154
 
1155
  enterprise_results = {
 
1156
  "execution_mode": mode,
1157
  "scenario": scenario_name,
1158
  "timestamp": datetime.datetime.now().isoformat(),
1159
- "status": "awaiting_approval",
1160
  "actions_queued": [
1161
  "Scale resources based on ML recommendations",
1162
- "Implement circuit breaker pattern",
1163
  "Deploy enhanced monitoring",
1164
  "Update RAG memory with outcome"
1165
  ],
@@ -1208,14 +1222,14 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)
1208
  """
1209
 
1210
  enterprise_results = {
 
1211
  "execution_mode": mode,
1212
  "scenario": scenario_name,
1213
  "timestamp": datetime.datetime.now().isoformat(),
1214
- "status": "executed",
1215
  "actions_executed": [
1216
  "βœ… Scaled resources based on ML recommendations",
1217
  "βœ… Implemented circuit breaker pattern",
1218
- "βœ… Deployed enhanced monitoring",
1219
  "βœ… Updated RAG memory with outcome"
1220
  ],
1221
  "business_impact": {
@@ -1247,11 +1261,12 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)
1247
  """
1248
 
1249
  enterprise_results = {
 
1250
  "execution_mode": mode,
1251
  "scenario": scenario_name,
1252
  "timestamp": datetime.datetime.now().isoformat(),
1253
- "status": "failed",
1254
- "error": execution_result.get("message", "Unknown error")
1255
  }
1256
 
1257
  except Exception as e:
@@ -1270,18 +1285,18 @@ def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value)
1270
  """
1271
 
1272
  enterprise_results = {
 
1273
  "execution_mode": mode,
1274
  "scenario": scenario_name,
1275
  "timestamp": datetime.datetime.now().isoformat(),
1276
- "status": "error",
1277
- "error": str(e)
1278
  }
1279
 
1280
  # Update execution table
1281
  execution_table_data = get_audit_manager().get_execution_table()
1282
 
1283
- return approval_html, enterprise_results, execution_table_data
1284
-
1285
  # ===========================================
1286
  # CREATE DEMO INTERFACE
1287
  # ===========================================
 
1109
  )
1110
 
1111
  # ===========================================
1112
+ # REAL ENTERPRISE EXECUTION HANDLER - FIXED VERSION
1113
  # ===========================================
1114
  def execute_enterprise_healing(scenario_name, approval_required, mcp_mode_value):
1115
+ """Execute enterprise healing with real ARF - FIXED VERSION"""
1116
+ import gradio as gr
1117
+
1118
  scenario = get_components()["INCIDENT_SCENARIOS"].get(scenario_name, {})
1119
 
1120
  # Determine mode
1121
  mode = "Approval" if approval_required else "Autonomous"
1122
  if "Advisory" in mcp_mode_value:
1123
+ approval_html = """
1124
+ <div style='padding: 20px; background: #fef2f2; border-radius: 14px;'>
1125
+ <p>❌ Cannot execute in Advisory mode. Switch to Approval or Autonomous mode.</p>
1126
+ </div>
1127
+ """
1128
+ enterprise_results = {
1129
+ "status": "❌ Cannot Execute",
1130
+ "error": "Advisory mode only supports analysis, not execution",
1131
+ "requires_mode_change": True,
1132
+ "suggested_mode": "approval"
1133
+ }
1134
+ execution_table_data = get_audit_manager().get_execution_table()
1135
+ return gr.HTML.update(value=approval_html), enterprise_results, execution_table_data
1136
 
1137
  # Calculate savings based on scenario
1138
  impact = scenario.get("business_impact", {})
 
1167
  """
1168
 
1169
  enterprise_results = {
1170
+ "status": "⏳ Awaiting Approval",
1171
  "execution_mode": mode,
1172
  "scenario": scenario_name,
1173
  "timestamp": datetime.datetime.now().isoformat(),
 
1174
  "actions_queued": [
1175
  "Scale resources based on ML recommendations",
1176
+ "Implement circuit breaker pattern",
1177
  "Deploy enhanced monitoring",
1178
  "Update RAG memory with outcome"
1179
  ],
 
1222
  """
1223
 
1224
  enterprise_results = {
1225
+ "status": "βœ… Execution Successful",
1226
  "execution_mode": mode,
1227
  "scenario": scenario_name,
1228
  "timestamp": datetime.datetime.now().isoformat(),
 
1229
  "actions_executed": [
1230
  "βœ… Scaled resources based on ML recommendations",
1231
  "βœ… Implemented circuit breaker pattern",
1232
+ "βœ… Deployed enhanced monitoring",
1233
  "βœ… Updated RAG memory with outcome"
1234
  ],
1235
  "business_impact": {
 
1261
  """
1262
 
1263
  enterprise_results = {
1264
+ "status": "❌ Execution Failed",
1265
  "execution_mode": mode,
1266
  "scenario": scenario_name,
1267
  "timestamp": datetime.datetime.now().isoformat(),
1268
+ "error": execution_result.get("message", "Unknown error"),
1269
+ "suggestion": "Check logs and try again in approval mode"
1270
  }
1271
 
1272
  except Exception as e:
 
1285
  """
1286
 
1287
  enterprise_results = {
1288
+ "status": "❌ Execution Error",
1289
  "execution_mode": mode,
1290
  "scenario": scenario_name,
1291
  "timestamp": datetime.datetime.now().isoformat(),
1292
+ "error": str(e),
1293
+ "suggestion": "Try running OSS analysis first"
1294
  }
1295
 
1296
  # Update execution table
1297
  execution_table_data = get_audit_manager().get_execution_table()
1298
 
1299
+ return gr.HTML.update(value=approval_html), enterprise_results, execution_table_data
 
1300
  # ===========================================
1301
  # CREATE DEMO INTERFACE
1302
  # ===========================================