Spaces:
Paused
Paused
use @spaces.GPU function directly as click handler
Browse files
app.py
CHANGED
|
@@ -66,8 +66,8 @@ def analyze_logs(
|
|
| 66 |
anomaly_percentile: float,
|
| 67 |
range_min: float,
|
| 68 |
range_max: float,
|
| 69 |
-
progress
|
| 70 |
-
)
|
| 71 |
"""Analyze log content and return results.
|
| 72 |
|
| 73 |
This function is decorated with @spaces.GPU to run on ZeroGPU.
|
|
@@ -157,12 +157,12 @@ def analyze_logs(
|
|
| 157 |
logger.info(f"Token reduction: {input_tokens:,} → {output_tokens:,} ({reduction:.0f}%)")
|
| 158 |
logger.info("=" * 60)
|
| 159 |
|
| 160 |
-
return result.output, label
|
| 161 |
|
| 162 |
except Exception as e:
|
| 163 |
logger.error(f"Error during analysis: {str(e)}", exc_info=True)
|
| 164 |
error_msg = f"Analysis failed: {str(e)}"
|
| 165 |
-
return error_msg, "Error"
|
| 166 |
finally:
|
| 167 |
temp_path.unlink(missing_ok=True)
|
| 168 |
logger.info("Temporary file cleaned up")
|
|
@@ -345,12 +345,10 @@ result = analyzer.analyze_file(Path("system.log"))
|
|
| 345 |
load_sample_btn.click(fn=load_sample_log, outputs=[log_input])
|
| 346 |
clear_btn.click(fn=lambda: "", outputs=[log_input])
|
| 347 |
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
return gr.update(value=output, label=label)
|
| 351 |
-
|
| 352 |
analyze_btn.click(
|
| 353 |
-
fn=
|
| 354 |
inputs=[log_input, window_size, k_neighbors, mode_select, anomaly_percentile, range_min, range_max],
|
| 355 |
outputs=[output_text],
|
| 356 |
)
|
|
|
|
| 66 |
anomaly_percentile: float,
|
| 67 |
range_min: float,
|
| 68 |
range_max: float,
|
| 69 |
+
progress=gr.Progress(),
|
| 70 |
+
):
|
| 71 |
"""Analyze log content and return results.
|
| 72 |
|
| 73 |
This function is decorated with @spaces.GPU to run on ZeroGPU.
|
|
|
|
| 157 |
logger.info(f"Token reduction: {input_tokens:,} → {output_tokens:,} ({reduction:.0f}%)")
|
| 158 |
logger.info("=" * 60)
|
| 159 |
|
| 160 |
+
return gr.update(value=result.output, label=label)
|
| 161 |
|
| 162 |
except Exception as e:
|
| 163 |
logger.error(f"Error during analysis: {str(e)}", exc_info=True)
|
| 164 |
error_msg = f"Analysis failed: {str(e)}"
|
| 165 |
+
return gr.update(value=error_msg, label="Error")
|
| 166 |
finally:
|
| 167 |
temp_path.unlink(missing_ok=True)
|
| 168 |
logger.info("Temporary file cleaned up")
|
|
|
|
| 345 |
load_sample_btn.click(fn=load_sample_log, outputs=[log_input])
|
| 346 |
clear_btn.click(fn=lambda: "", outputs=[log_input])
|
| 347 |
|
| 348 |
+
# Use analyze_logs directly - it's decorated with @spaces.GPU
|
| 349 |
+
# Don't wrap it in another function or ZeroGPU won't allocate GPU properly
|
|
|
|
|
|
|
| 350 |
analyze_btn.click(
|
| 351 |
+
fn=analyze_logs,
|
| 352 |
inputs=[log_input, window_size, k_neighbors, mode_select, anomaly_percentile, range_min, range_max],
|
| 353 |
outputs=[output_text],
|
| 354 |
)
|