Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
e392b76
1
Parent(s):
3b12fe9
added sentry error sdk for logging space exceptions
Browse files- app.py +20 -0
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -10,6 +10,10 @@ import sys
|
|
| 10 |
from datetime import datetime
|
| 11 |
import re
|
| 12 |
from PIL import Image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
# --- Configuration ---
|
| 15 |
#AUTFORGE_SCRIPT_PATH = "auto_forge.py" # Make sure this points to your script
|
|
@@ -25,6 +29,19 @@ DISPLAY_COL_MAP = {
|
|
| 25 |
" Color": "Color (Hex)",
|
| 26 |
}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
def ensure_required_cols(df, *, in_display_space):
|
| 30 |
"""
|
|
@@ -426,6 +443,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 426 |
visible=True,
|
| 427 |
)
|
| 428 |
except Exception as e:
|
|
|
|
| 429 |
gr.Error(f"Error saving CSV for download: {e}")
|
| 430 |
return None
|
| 431 |
|
|
@@ -578,6 +596,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 578 |
try:
|
| 579 |
df_to_save.to_csv(temp_filament_csv, index=False)
|
| 580 |
except Exception as e:
|
|
|
|
| 581 |
err_msg = f"Error saving temporary filament CSV: {e}"
|
| 582 |
gr.Error(err_msg)
|
| 583 |
return create_empty_error_outputs(err_msg)
|
|
@@ -613,6 +632,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 613 |
|
| 614 |
command.extend(["--input_image", script_input_image_path])
|
| 615 |
except Exception as e:
|
|
|
|
| 616 |
err_msg = f"Error handling input image: {e}"
|
| 617 |
gr.Error(err_msg)
|
| 618 |
return create_empty_error_outputs(err_msg)
|
|
|
|
| 10 |
from datetime import datetime
|
| 11 |
import re
|
| 12 |
from PIL import Image
|
| 13 |
+
import os, logging
|
| 14 |
+
import sentry_sdk
|
| 15 |
+
from sentry_sdk import capture_exception
|
| 16 |
+
from sentry_sdk.integrations.logging import LoggingIntegration
|
| 17 |
|
| 18 |
# --- Configuration ---
|
| 19 |
#AUTFORGE_SCRIPT_PATH = "auto_forge.py" # Make sure this points to your script
|
|
|
|
| 29 |
" Color": "Color (Hex)",
|
| 30 |
}
|
| 31 |
|
| 32 |
+
sentry_sdk.init(
|
| 33 |
+
dsn=os.getenv("SENTRY_DSN"),
|
| 34 |
+
traces_sample_rate=0.1, # performance traces, optional
|
| 35 |
+
integrations=[
|
| 36 |
+
LoggingIntegration(
|
| 37 |
+
level=logging.INFO, # capture warnings/info in breadcrumbs
|
| 38 |
+
event_level=logging.ERROR,
|
| 39 |
+
),
|
| 40 |
+
],
|
| 41 |
+
release=os.getenv("HF_SPACE_VERSION", "dev"),
|
| 42 |
+
environment="hf_space",
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
|
| 46 |
def ensure_required_cols(df, *, in_display_space):
|
| 47 |
"""
|
|
|
|
| 443 |
visible=True,
|
| 444 |
)
|
| 445 |
except Exception as e:
|
| 446 |
+
capture_exception(e)
|
| 447 |
gr.Error(f"Error saving CSV for download: {e}")
|
| 448 |
return None
|
| 449 |
|
|
|
|
| 596 |
try:
|
| 597 |
df_to_save.to_csv(temp_filament_csv, index=False)
|
| 598 |
except Exception as e:
|
| 599 |
+
capture_exception(e)
|
| 600 |
err_msg = f"Error saving temporary filament CSV: {e}"
|
| 601 |
gr.Error(err_msg)
|
| 602 |
return create_empty_error_outputs(err_msg)
|
|
|
|
| 632 |
|
| 633 |
command.extend(["--input_image", script_input_image_path])
|
| 634 |
except Exception as e:
|
| 635 |
+
capture_exception(e)
|
| 636 |
err_msg = f"Error handling input image: {e}"
|
| 637 |
gr.Error(err_msg)
|
| 638 |
return create_empty_error_outputs(err_msg)
|
requirements.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
autoforge==1.7.2
|
|
|
|
|
|
| 1 |
autoforge==1.7.2
|
| 2 |
+
sentry-sdk[huggingface_hub]
|