Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
9f2e1e5
1
Parent(s):
8513b12
more sentry logging and removing dummy button
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import uuid
|
|
| 2 |
import os
|
| 3 |
import logging
|
| 4 |
import sentry_sdk
|
| 5 |
-
from sentry_sdk import capture_exception
|
| 6 |
from sentry_sdk.integrations.logging import LoggingIntegration
|
| 7 |
from sentry_sdk.integrations.starlette import StarletteIntegration
|
| 8 |
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
|
@@ -124,15 +124,6 @@ def rgba_to_hex(col: str) -> str:
|
|
| 124 |
r, g, b = (int(float(x)) for x in m.groups()[:3])
|
| 125 |
return "#{:02X}{:02X}{:02X}".format(r, g, b)
|
| 126 |
|
| 127 |
-
def sentry_wrap(fn):
|
| 128 |
-
def _inner(*args, **kwargs):
|
| 129 |
-
try:
|
| 130 |
-
return fn(*args, **kwargs)
|
| 131 |
-
except Exception as exc:
|
| 132 |
-
capture_exception(exc) # send to Sentry
|
| 133 |
-
flush(timeout=2) # make sure the event is really sent
|
| 134 |
-
raise # let Gradio show its own error dialog
|
| 135 |
-
return _inner
|
| 136 |
|
| 137 |
# --- Helper Functions ---
|
| 138 |
def get_script_args_info(exclude_args=None):
|
|
@@ -277,8 +268,6 @@ def get_script_args_info(exclude_args=None):
|
|
| 277 |
]
|
| 278 |
return [arg for arg in all_args_info if arg["name"] not in exclude_args]
|
| 279 |
|
| 280 |
-
def boom():
|
| 281 |
-
raise RuntimeError("Sentry test – should appear in dashboard")
|
| 282 |
|
| 283 |
# Initial filament data
|
| 284 |
initial_filament_data = {
|
|
@@ -549,8 +538,6 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 549 |
visible=False,
|
| 550 |
)
|
| 551 |
with gr.Row():
|
| 552 |
-
test_btn = gr.Button("Trigger Sentry test error")
|
| 553 |
-
test_btn.click(boom)
|
| 554 |
with gr.Accordion("Adjust Autoforge Parameters", open=False):
|
| 555 |
args_for_accordion = get_script_args_info(
|
| 556 |
exclude_args=["--input_image"]
|
|
@@ -708,8 +695,14 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 708 |
)
|
| 709 |
|
| 710 |
yield create_empty_error_outputs(log_output) # clear UI and show header
|
| 711 |
-
|
| 712 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 713 |
)
|
| 714 |
process = subprocess.Popen(
|
| 715 |
command,
|
|
@@ -797,6 +790,15 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 797 |
if return_code == 0
|
| 798 |
else f"\nAutoforge process failed with exit code {return_code}."
|
| 799 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 800 |
|
| 801 |
# make sure we show the final preview (if any)
|
| 802 |
final_preview = _maybe_new_preview() or os.path.join(
|
|
|
|
| 2 |
import os
|
| 3 |
import logging
|
| 4 |
import sentry_sdk
|
| 5 |
+
from sentry_sdk import capture_exception, push_scope, capture_message
|
| 6 |
from sentry_sdk.integrations.logging import LoggingIntegration
|
| 7 |
from sentry_sdk.integrations.starlette import StarletteIntegration
|
| 8 |
from sentry_sdk.integrations.fastapi import FastApiIntegration
|
|
|
|
| 124 |
r, g, b = (int(float(x)) for x in m.groups()[:3])
|
| 125 |
return "#{:02X}{:02X}{:02X}".format(r, g, b)
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
# --- Helper Functions ---
|
| 129 |
def get_script_args_info(exclude_args=None):
|
|
|
|
| 268 |
]
|
| 269 |
return [arg for arg in all_args_info if arg["name"] not in exclude_args]
|
| 270 |
|
|
|
|
|
|
|
| 271 |
|
| 272 |
# Initial filament data
|
| 273 |
initial_filament_data = {
|
|
|
|
| 538 |
visible=False,
|
| 539 |
)
|
| 540 |
with gr.Row():
|
|
|
|
|
|
|
| 541 |
with gr.Accordion("Adjust Autoforge Parameters", open=False):
|
| 542 |
args_for_accordion = get_script_args_info(
|
| 543 |
exclude_args=["--input_image"]
|
|
|
|
| 695 |
)
|
| 696 |
|
| 697 |
yield create_empty_error_outputs(log_output) # clear UI and show header
|
| 698 |
+
cmd_str = " ".join(command)
|
| 699 |
+
sentry_sdk.capture_event(
|
| 700 |
+
{
|
| 701 |
+
"message": "Autoforge process started",
|
| 702 |
+
"level": "info",
|
| 703 |
+
"fingerprint": ["autoforge-process-start"], # every start groups here
|
| 704 |
+
"extra": {"command": cmd_str}, # still searchable
|
| 705 |
+
}
|
| 706 |
)
|
| 707 |
process = subprocess.Popen(
|
| 708 |
command,
|
|
|
|
| 790 |
if return_code == 0
|
| 791 |
else f"\nAutoforge process failed with exit code {return_code}."
|
| 792 |
)
|
| 793 |
+
log_str = " ".join(log_output)
|
| 794 |
+
sentry_sdk.capture_event(
|
| 795 |
+
{
|
| 796 |
+
"message": "Autoforge process finished",
|
| 797 |
+
"level": "info",
|
| 798 |
+
"fingerprint": ["autoforge-process-finished"], # every start groups here
|
| 799 |
+
"extra": {"log": log_str}, # still searchable
|
| 800 |
+
}
|
| 801 |
+
)
|
| 802 |
|
| 803 |
# make sure we show the final preview (if any)
|
| 804 |
final_preview = _maybe_new_preview() or os.path.join(
|