tazwarrrr commited on
Commit
27c4e2c
·
1 Parent(s): 11aa436

fixing bugs23

Browse files
backend/agents/analyzer.py CHANGED
@@ -124,7 +124,10 @@ def run(cuda_code: str) -> AnalyzerResult:
124
  "complexity_score": 5
125
  }
126
 
127
- workload_type = WorkloadType(data.get("workload_type", "unknown"))
 
 
 
128
  prediction = generate_prediction(workload_type, line_count)
129
 
130
  return AnalyzerResult(
 
124
  "complexity_score": 5
125
  }
126
 
127
+ try:
128
+ workload_type = WorkloadType(data.get("workload_type", "unknown"))
129
+ except ValueError:
130
+ workload_type = WorkloadType.UNKNOWN
131
  prediction = generate_prediction(workload_type, line_count)
132
 
133
  return AnalyzerResult(
backend/tools/hipify_wrapper.py CHANGED
@@ -31,7 +31,7 @@ class HipifyWrapper:
31
  capture_output=True, timeout=5, check=False
32
  )
33
  return result.returncode == 0
34
- except (FileNotFoundError, subprocess.TimeoutExpired):
35
  return False
36
 
37
  def _run_real_hipify(self, cuda_code: str) -> tuple[str, list[dict]] | None:
 
31
  capture_output=True, timeout=5, check=False
32
  )
33
  return result.returncode == 0
34
+ except (OSError, subprocess.SubprocessError):
35
  return False
36
 
37
  def _run_real_hipify(self, cuda_code: str) -> tuple[str, list[dict]] | None:
backend/tools/llm_client.py CHANGED
@@ -124,7 +124,11 @@ class LLMClient:
124
  return response.choices[0].message.content
125
 
126
  except Exception as e:
127
- raise RuntimeError(f"LLM request failed: {str(e)}") from e
 
 
 
 
128
 
129
  # ------------------------------------------------------------------
130
  # Utility / introspection
 
124
  return response.choices[0].message.content
125
 
126
  except Exception as e:
127
+ message = str(e)
128
+ lowered = message.lower()
129
+ if "rate limit" in lowered or "429" in lowered or "quota" in lowered:
130
+ raise RuntimeError(f"LLM request rate-limited: {message}") from e
131
+ raise RuntimeError(f"LLM request failed: {message}") from e
132
 
133
  # ------------------------------------------------------------------
134
  # Utility / introspection
backend/tools/rocprof_wrapper.py CHANGED
@@ -19,6 +19,7 @@ class RocprofWrapper:
19
  if not self.rocm_available:
20
  return True, "Mock compilation successful (ROCm not available)"
21
 
 
22
  try:
23
  with tempfile.NamedTemporaryFile(mode='w', suffix='.hip', delete=False) as f:
24
  f.write(hip_code)
@@ -39,9 +40,6 @@ class RocprofWrapper:
39
  result = subprocess.run(
40
  cmd, capture_output=True, text=True, timeout=60, env=env, check=False)
41
 
42
- # Cleanup
43
- os.unlink(temp_file)
44
-
45
  if result.returncode == 0:
46
  return True, f"Compilation successful: {output_file}"
47
  else:
@@ -51,6 +49,12 @@ class RocprofWrapper:
51
  return False, "Compilation timed out"
52
  except (OSError, subprocess.SubprocessError) as e:
53
  return False, f"Compilation error: {str(e)}"
 
 
 
 
 
 
54
 
55
  def run_with_profiling(self, executable_path: str, args: List[str] = None) -> Dict:
56
  """Run executable with rocprof profiling"""
@@ -68,6 +72,14 @@ class RocprofWrapper:
68
  result = subprocess.run(
69
  cmd, capture_output=True, text=True, timeout=120, check=False)
70
 
 
 
 
 
 
 
 
 
71
  # Parse rocprof output
72
  profiling_data = self._parse_rocprof_output(
73
  result.stdout, result.stderr)
@@ -75,9 +87,9 @@ class RocprofWrapper:
75
  return profiling_data
76
 
77
  except subprocess.TimeoutExpired:
78
- return {"error": "Profiling timed out", "execution_time_ms": 0}
79
  except (OSError, subprocess.SubprocessError) as e:
80
- return {"error": f"Profiling error: {str(e)}", "execution_time_ms": 0}
81
 
82
  def _parse_rocprof_output(self, stdout: str, _stderr: str) -> Dict:
83
  """Parse rocprof output to extract metrics"""
 
19
  if not self.rocm_available:
20
  return True, "Mock compilation successful (ROCm not available)"
21
 
22
+ temp_file = None
23
  try:
24
  with tempfile.NamedTemporaryFile(mode='w', suffix='.hip', delete=False) as f:
25
  f.write(hip_code)
 
40
  result = subprocess.run(
41
  cmd, capture_output=True, text=True, timeout=60, env=env, check=False)
42
 
 
 
 
43
  if result.returncode == 0:
44
  return True, f"Compilation successful: {output_file}"
45
  else:
 
49
  return False, "Compilation timed out"
50
  except (OSError, subprocess.SubprocessError) as e:
51
  return False, f"Compilation error: {str(e)}"
52
+ finally:
53
+ try:
54
+ if temp_file and os.path.exists(temp_file):
55
+ os.unlink(temp_file)
56
+ except OSError:
57
+ pass
58
 
59
  def run_with_profiling(self, executable_path: str, args: List[str] = None) -> Dict:
60
  """Run executable with rocprof profiling"""
 
72
  result = subprocess.run(
73
  cmd, capture_output=True, text=True, timeout=120, check=False)
74
 
75
+ if result.returncode != 0:
76
+ detail = result.stderr.strip() or result.stdout.strip() or "rocprof exited with a non-zero status"
77
+ return {
78
+ "success": False,
79
+ "error": f"Profiling failed: {detail}",
80
+ "execution_time_ms": 0,
81
+ }
82
+
83
  # Parse rocprof output
84
  profiling_data = self._parse_rocprof_output(
85
  result.stdout, result.stderr)
 
87
  return profiling_data
88
 
89
  except subprocess.TimeoutExpired:
90
+ return {"success": False, "error": "Profiling timed out", "execution_time_ms": 0}
91
  except (OSError, subprocess.SubprocessError) as e:
92
+ return {"success": False, "error": f"Profiling error: {str(e)}", "execution_time_ms": 0}
93
 
94
  def _parse_rocprof_output(self, stdout: str, _stderr: str) -> Dict:
95
  """Parse rocprof output to extract metrics"""
frontend/src/App.jsx CHANGED
@@ -714,11 +714,19 @@ export default function App() {
714
 
715
  // Extract benchmark data from the coordinator's done event
716
  if (ev.agent === 'coordinator' && ev.status === 'done') {
717
- const r = ev.result ?? ev
 
 
 
 
 
 
 
 
718
  setBenchmark({
719
  total_changes: r.total_changes ?? r.changes_made ?? '—',
720
- bugs_found: r.bugs_found ?? r.critical_bugs ?? '—',
721
- compiled_successfully: r.compiled_successfully ?? r.compiled ?? false,
722
  data_source: r.data_source ?? 'unknown',
723
  })
724
  }
 
714
 
715
  // Extract benchmark data from the coordinator's done event
716
  if (ev.agent === 'coordinator' && ev.status === 'done') {
717
+ let report = ev.result ?? null
718
+ if (!report && ev.detail) {
719
+ try {
720
+ report = JSON.parse(ev.detail)
721
+ } catch (_) {
722
+ report = null
723
+ }
724
+ }
725
+ const r = report ?? ev
726
  setBenchmark({
727
  total_changes: r.total_changes ?? r.changes_made ?? '—',
728
+ bugs_found: r.bugs_found ?? r.critical_bugs ?? r.static_risk_report?.critical_count ?? '—',
729
+ compiled_successfully: r.compiled_successfully ?? r.compiled ?? r.migration_success ?? false,
730
  data_source: r.data_source ?? 'unknown',
731
  })
732
  }