Update flask_server.py

This commit is contained in:
MacRimi
2025-10-09 20:18:49 +02:00
parent eb954fb10d
commit a4cb9a8923

View File

@@ -1717,6 +1717,9 @@ def get_detailed_gpu_info(gpu):
print(f"[v0] Collected {len(json_objects)} JSON objects total", flush=True)
try:
print(f"[v0] Starting JSON parsing...", flush=True)
if not any('clients' in obj for obj in json_objects):
try:
stderr_output = process.stderr.read()
@@ -1790,9 +1793,9 @@ def get_detailed_gpu_info(gpu):
else:
print(f"[v0] WARNING: No 'clients' section in selected JSON", flush=True)
print(f"[v0] Parsing engines section...", flush=True)
# Parse global engines section
if 'engines' in best_json:
print(f"[v0] Parsing engines section...", flush=True)
engines = best_json['engines']
for engine_name, engine_data in engines.items():
@@ -1803,6 +1806,7 @@ def get_detailed_gpu_info(gpu):
if clean_name in engine_totals:
engine_totals[clean_name] = busy_value
print(f"[v0] Calculating final engine values...", flush=True)
# Use client engine totals if available, otherwise use global engines
final_engines = client_engine_totals if any(v > 0 for v in client_engine_totals.values()) else engine_totals
@@ -1815,6 +1819,7 @@ def get_detailed_gpu_info(gpu):
max_utilization = max(final_engines.values())
detailed_info['utilization_gpu'] = f"{max_utilization:.1f}%"
print(f"[v0] Parsing frequency...", flush=True)
# Parse frequency
if 'frequency' in best_json:
freq_data = best_json['frequency']
@@ -1822,6 +1827,7 @@ def get_detailed_gpu_info(gpu):
detailed_info['clock_graphics'] = f"{actual_freq} MHz"
data_retrieved = True
print(f"[v0] Parsing power...", flush=True)
# Parse power
if 'power' in best_json:
power_data = best_json['power']
@@ -1831,6 +1837,7 @@ def get_detailed_gpu_info(gpu):
detailed_info['power_limit'] = f"{package_power:.2f} W"
data_retrieved = True
print(f"[v0] Finalizing Intel GPU data...", flush=True)
if data_retrieved:
detailed_info['has_monitoring_tool'] = True
print(f"[v0] Intel GPU monitoring successful", flush=True)
@@ -1849,6 +1856,14 @@ def get_detailed_gpu_info(gpu):
except:
pass
print(f"[v0] JSON parsing completed successfully", flush=True)
except Exception as parse_error:
print(f"[v0] CRITICAL ERROR during JSON parsing: {parse_error}", flush=True)
import traceback
traceback.print_exc()
print(f"[v0] Returning partial data due to parsing error", flush=True)
except Exception as e:
print(f"[v0] Error running intel_gpu_top: {e}", flush=True)
import traceback