petter2025 commited on
Commit
aa09497
·
verified ·
1 Parent(s): 770a358

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -4
app.py CHANGED
@@ -1,14 +1,29 @@
1
  import gradio as gr
2
  import asyncio
3
  import json
 
 
4
  from agentic_reliability_framework.runtime.engine import EnhancedReliabilityEngine
5
 
6
- # Initialize the engine (loads agents, policies, etc.)
7
- engine = EnhancedReliabilityEngine()
 
 
 
 
 
 
 
 
 
 
8
 
9
  async def analyze(component, latency, error_rate, throughput, cpu_util, memory_util):
10
  """Call the ARF v4 engine with telemetry data."""
 
 
11
  try:
 
12
  result = await engine.process_event_enhanced(
13
  component=component,
14
  latency=float(latency),
@@ -17,9 +32,11 @@ async def analyze(component, latency, error_rate, throughput, cpu_util, memory_u
17
  cpu_util=float(cpu_util) if cpu_util else None,
18
  memory_util=float(memory_util) if memory_util else None
19
  )
 
20
  return json.dumps(result, indent=2)
21
  except Exception as e:
22
- return f"Error: {str(e)}"
 
23
 
24
  def sync_analyze(*args):
25
  """Synchronous wrapper for Gradio."""
@@ -70,4 +87,5 @@ with gr.Blocks(title="ARF v4 – Reliability Lab", theme="soft") as demo:
70
  [💼 Enterprise](mailto:petter2025us@outlook.com)
71
  """)
72
 
73
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
 
1
  import gradio as gr
2
  import asyncio
3
  import json
4
+ import logging
5
+ import traceback
6
  from agentic_reliability_framework.runtime.engine import EnhancedReliabilityEngine
7
 
8
+ # Configure logging to show details
9
+ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
10
+ logger = logging.getLogger(__name__)
11
+
12
+ # Initialize the engine
13
+ try:
14
+ logger.info("Initializing EnhancedReliabilityEngine...")
15
+ engine = EnhancedReliabilityEngine()
16
+ logger.info("Engine initialized successfully.")
17
+ except Exception as e:
18
+ logger.error(f"Failed to initialize engine: {e}\n{traceback.format_exc()}")
19
+ engine = None
20
 
21
  async def analyze(component, latency, error_rate, throughput, cpu_util, memory_util):
22
  """Call the ARF v4 engine with telemetry data."""
23
+ if engine is None:
24
+ return json.dumps({"error": "Engine failed to initialize. Check logs."}, indent=2)
25
  try:
26
+ logger.info(f"Analyzing: component={component}, latency={latency}, error_rate={error_rate}, throughput={throughput}, cpu={cpu_util}, mem={memory_util}")
27
  result = await engine.process_event_enhanced(
28
  component=component,
29
  latency=float(latency),
 
32
  cpu_util=float(cpu_util) if cpu_util else None,
33
  memory_util=float(memory_util) if memory_util else None
34
  )
35
+ logger.info("Analysis completed successfully.")
36
  return json.dumps(result, indent=2)
37
  except Exception as e:
38
+ logger.error(f"Error during analysis: {e}\n{traceback.format_exc()}")
39
+ return json.dumps({"error": str(e), "traceback": traceback.format_exc()}, indent=2)
40
 
41
  def sync_analyze(*args):
42
  """Synchronous wrapper for Gradio."""
 
87
  [💼 Enterprise](mailto:petter2025us@outlook.com)
88
  """)
89
 
90
+ if __name__ == "__main__":
91
+ demo.launch(server_name="0.0.0.0", server_port=7860)