Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,9 +11,11 @@ import traceback
|
|
| 11 |
try:
|
| 12 |
from fpdf2 import FPDF
|
| 13 |
FPDF_AVAILABLE = True
|
|
|
|
| 14 |
except ImportError:
|
| 15 |
FPDF_AVAILABLE = False
|
| 16 |
FPDF = None
|
|
|
|
| 17 |
|
| 18 |
# Check library versions for debugging
|
| 19 |
debug_msg = "Library Versions:\n"
|
|
@@ -216,7 +218,7 @@ def filter_and_visualize(selected_lab, selected_type, selected_date_range):
|
|
| 216 |
plt.ylabel("Number of Logs")
|
| 217 |
plt.xticks(rotation=45)
|
| 218 |
plot_daily = io.BytesIO()
|
| 219 |
-
plt.savefig(plot_daily, format="png",
|
| 220 |
plt.close()
|
| 221 |
plot_daily.seek(0)
|
| 222 |
except Exception as e:
|
|
@@ -383,9 +385,7 @@ try:
|
|
| 383 |
anomaly_output = gr.Textbox(label="Anomaly Alerts")
|
| 384 |
|
| 385 |
with gr.Row():
|
| 386 |
-
download_btn = gr.Button("Download PDF Report", visible=
|
| 387 |
-
if not FPDF_AVAILABLE:
|
| 388 |
-
gr.Markdown("⚠️ PDF download feature disabled: Please install fpdf2 to enable.")
|
| 389 |
|
| 390 |
error_box = gr.Textbox(label="Status/Error Message", visible=True, interactive=False)
|
| 391 |
|
|
|
|
| 11 |
try:
|
| 12 |
from fpdf2 import FPDF
|
| 13 |
FPDF_AVAILABLE = True
|
| 14 |
+
print("FPDF2 successfully loaded.") # Debug log to confirm fpdf2 installation
|
| 15 |
except ImportError:
|
| 16 |
FPDF_AVAILABLE = False
|
| 17 |
FPDF = None
|
| 18 |
+
print("FPDF2 not installed. PDF download feature will be disabled.")
|
| 19 |
|
| 20 |
# Check library versions for debugging
|
| 21 |
debug_msg = "Library Versions:\n"
|
|
|
|
| 218 |
plt.ylabel("Number of Logs")
|
| 219 |
plt.xticks(rotation=45)
|
| 220 |
plot_daily = io.BytesIO()
|
| 221 |
+
plt.savefig(plot_daily, format="png", bbox RACinches="tight")
|
| 222 |
plt.close()
|
| 223 |
plot_daily.seek(0)
|
| 224 |
except Exception as e:
|
|
|
|
| 385 |
anomaly_output = gr.Textbox(label="Anomaly Alerts")
|
| 386 |
|
| 387 |
with gr.Row():
|
| 388 |
+
download_btn = gr.Button("Download PDF Report", visible=True) # Always visible since fpdf2 should be installed
|
|
|
|
|
|
|
| 389 |
|
| 390 |
error_box = gr.Textbox(label="Status/Error Message", visible=True, interactive=False)
|
| 391 |
|