Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
651d505
1
Parent(s):
2253dd0
sentry fix
Browse files
app.py
CHANGED
@@ -4,18 +4,26 @@ import sentry_sdk
|
|
4 |
from sentry_sdk import capture_exception
|
5 |
from sentry_sdk.integrations.logging import LoggingIntegration
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
import gradio as gr
|
21 |
import pandas as pd
|
@@ -747,6 +755,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
747 |
time.sleep(0.05) # keep CPU load low
|
748 |
|
749 |
return_code = process.wait()
|
|
|
|
|
|
|
|
|
750 |
log_output += (
|
751 |
"\nAutoforge process completed successfully!"
|
752 |
if return_code == 0
|
|
|
4 |
from sentry_sdk import capture_exception
|
5 |
from sentry_sdk.integrations.logging import LoggingIntegration
|
6 |
|
7 |
+
dsn = os.getenv("SENTRY_DSN")
|
8 |
+
if not dsn:
|
9 |
+
print("WARNING: SENTRY_DSN not set – Sentry disabled")
|
10 |
+
else:
|
11 |
+
sentry_sdk.init(
|
12 |
+
dsn=dsn,
|
13 |
+
traces_sample_rate=0.1,
|
14 |
+
integrations=[
|
15 |
+
LoggingIntegration(
|
16 |
+
level=logging.INFO, # breadcrumb level
|
17 |
+
event_level=logging.ERROR,
|
18 |
+
),
|
19 |
+
],
|
20 |
+
release=os.getenv("HF_SPACE_VERSION", "dev"),
|
21 |
+
environment="hf_space",
|
22 |
+
)
|
23 |
+
|
24 |
+
logging.basicConfig(level=logging.INFO)
|
25 |
+
logger = logging.getLogger(__name__)
|
26 |
+
sentry_sdk.capture_message("🎉 Sentry is wired up!")
|
27 |
|
28 |
import gradio as gr
|
29 |
import pandas as pd
|
|
|
755 |
time.sleep(0.05) # keep CPU load low
|
756 |
|
757 |
return_code = process.wait()
|
758 |
+
if return_code != 0:
|
759 |
+
err = RuntimeError(f"Autoforge exited with code {return_code}")
|
760 |
+
capture_exception(err) # send to Sentry
|
761 |
+
raise err # also fail the Gradio call
|
762 |
log_output += (
|
763 |
"\nAutoforge process completed successfully!"
|
764 |
if return_code == 0
|