Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
323973b
1
Parent(s):
a0e83f7
sentry more logging
Browse files
app.py
CHANGED
@@ -24,7 +24,6 @@ else:
|
|
24 |
|
25 |
logging.basicConfig(level=logging.INFO)
|
26 |
logger = logging.getLogger(__name__)
|
27 |
-
sentry_sdk.capture_message("🎉 Sentry is wired up!")
|
28 |
|
29 |
import gradio as gr
|
30 |
import pandas as pd
|
@@ -386,6 +385,11 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
386 |
gr.Error(
|
387 |
f"CSV must contain columns: {', '.join(expected_cols)}. Found: {loaded_script_df.columns.tolist()}"
|
388 |
)
|
|
|
|
|
|
|
|
|
|
|
389 |
current_script_df = filament_df_state.value
|
390 |
if (
|
391 |
current_script_df is not None
|
@@ -411,6 +415,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
411 |
)
|
412 |
except Exception as e:
|
413 |
gr.Error(f"Error loading CSV: {e}")
|
|
|
414 |
current_script_df = filament_df_state.value
|
415 |
if current_script_df is not None and not current_script_df.empty:
|
416 |
return current_script_df.rename(
|
@@ -437,6 +442,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
437 |
gr.Error(
|
438 |
f"Cannot save. DataFrame missing required script columns. Expected: {required_cols}. Found: {df_to_save.columns.tolist()}"
|
439 |
)
|
|
|
440 |
return None
|
441 |
temp_dir = os.path.join(GRADIO_OUTPUT_BASE_DIR, "_temp_downloads")
|
442 |
os.makedirs(temp_dir, exist_ok=True)
|
@@ -580,6 +586,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
580 |
not input_image_path
|
581 |
): # Covers None and empty string from gr.Image(type="filepath")
|
582 |
gr.Error("Input Image is required! Please upload an image.")
|
|
|
583 |
return create_empty_error_outputs("Error: Input Image is required!")
|
584 |
|
585 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + "_" + str(uuid.uuid4())
|
@@ -593,6 +600,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
593 |
or current_filaments_df_state_val.empty
|
594 |
):
|
595 |
gr.Error("Filament table is empty. Please add filaments.")
|
|
|
|
|
|
|
596 |
return create_empty_error_outputs("Error: Filament table is empty.")
|
597 |
|
598 |
temp_filament_csv = os.path.join(run_output_dir_val, "materials.csv")
|
@@ -604,6 +614,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
604 |
f"Error: Filament data is missing columns: {', '.join(missing_cols)}."
|
605 |
)
|
606 |
gr.Error(err_msg)
|
|
|
|
|
|
|
607 |
return create_empty_error_outputs(err_msg)
|
608 |
try:
|
609 |
df_to_save.to_csv(temp_filament_csv, index=False)
|
@@ -678,7 +691,9 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
678 |
)
|
679 |
|
680 |
yield create_empty_error_outputs(log_output) # clear UI and show header
|
681 |
-
|
|
|
|
|
682 |
process = subprocess.Popen(
|
683 |
command,
|
684 |
stdout=subprocess.PIPE,
|
@@ -757,7 +772,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
757 |
|
758 |
return_code = process.wait()
|
759 |
if return_code != 0:
|
760 |
-
err = RuntimeError(f"Autoforge exited with code {return_code}")
|
761 |
capture_exception(err) # send to Sentry
|
762 |
raise err # also fail the Gradio call
|
763 |
log_output += (
|
|
|
24 |
|
25 |
logging.basicConfig(level=logging.INFO)
|
26 |
logger = logging.getLogger(__name__)
|
|
|
27 |
|
28 |
import gradio as gr
|
29 |
import pandas as pd
|
|
|
385 |
gr.Error(
|
386 |
f"CSV must contain columns: {', '.join(expected_cols)}. Found: {loaded_script_df.columns.tolist()}"
|
387 |
)
|
388 |
+
capture_exception(
|
389 |
+
Exception(
|
390 |
+
f"CSV must contain columns: {', '.join(expected_cols)}. Found: {loaded_script_df.columns.tolist()}"
|
391 |
+
)
|
392 |
+
)
|
393 |
current_script_df = filament_df_state.value
|
394 |
if (
|
395 |
current_script_df is not None
|
|
|
415 |
)
|
416 |
except Exception as e:
|
417 |
gr.Error(f"Error loading CSV: {e}")
|
418 |
+
capture_exception(e)
|
419 |
current_script_df = filament_df_state.value
|
420 |
if current_script_df is not None and not current_script_df.empty:
|
421 |
return current_script_df.rename(
|
|
|
442 |
gr.Error(
|
443 |
f"Cannot save. DataFrame missing required script columns. Expected: {required_cols}. Found: {df_to_save.columns.tolist()}"
|
444 |
)
|
445 |
+
capture_exception(Exception(f"Missing columns: {df_to_save.columns.tolist()}"))
|
446 |
return None
|
447 |
temp_dir = os.path.join(GRADIO_OUTPUT_BASE_DIR, "_temp_downloads")
|
448 |
os.makedirs(temp_dir, exist_ok=True)
|
|
|
586 |
not input_image_path
|
587 |
): # Covers None and empty string from gr.Image(type="filepath")
|
588 |
gr.Error("Input Image is required! Please upload an image.")
|
589 |
+
capture_exception(Exception("Input Image is required!"))
|
590 |
return create_empty_error_outputs("Error: Input Image is required!")
|
591 |
|
592 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + "_" + str(uuid.uuid4())
|
|
|
600 |
or current_filaments_df_state_val.empty
|
601 |
):
|
602 |
gr.Error("Filament table is empty. Please add filaments.")
|
603 |
+
capture_exception(
|
604 |
+
Exception("Filament table is empty. Please add filaments.")
|
605 |
+
)
|
606 |
return create_empty_error_outputs("Error: Filament table is empty.")
|
607 |
|
608 |
temp_filament_csv = os.path.join(run_output_dir_val, "materials.csv")
|
|
|
614 |
f"Error: Filament data is missing columns: {', '.join(missing_cols)}."
|
615 |
)
|
616 |
gr.Error(err_msg)
|
617 |
+
capture_exception(
|
618 |
+
Exception(f"Filament data is missing columns: {', '.join(missing_cols)}.")
|
619 |
+
)
|
620 |
return create_empty_error_outputs(err_msg)
|
621 |
try:
|
622 |
df_to_save.to_csv(temp_filament_csv, index=False)
|
|
|
691 |
)
|
692 |
|
693 |
yield create_empty_error_outputs(log_output) # clear UI and show header
|
694 |
+
sentry_sdk.capture_message(
|
695 |
+
f"Autoforge process started with command: {' '.join(command)}"
|
696 |
+
)
|
697 |
process = subprocess.Popen(
|
698 |
command,
|
699 |
stdout=subprocess.PIPE,
|
|
|
772 |
|
773 |
return_code = process.wait()
|
774 |
if return_code != 0:
|
775 |
+
err = RuntimeError(f"Autoforge exited with code {return_code} \n {log_output}")
|
776 |
capture_exception(err) # send to Sentry
|
777 |
raise err # also fail the Gradio call
|
778 |
log_output += (
|