Spaces:
Runtime error
Runtime error
Add explicit demo verification logging
Browse files
app.py
CHANGED
|
@@ -927,14 +927,20 @@ else:
|
|
| 927 |
demo = None
|
| 928 |
|
| 929 |
# Final check: ensure demo is set for Spaces
|
| 930 |
-
if IS_SPACES
|
| 931 |
-
|
| 932 |
-
|
| 933 |
-
|
| 934 |
-
gr.
|
| 935 |
-
|
| 936 |
-
|
| 937 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 938 |
|
| 939 |
# For local execution only (not on Spaces)
|
| 940 |
if __name__ == "__main__":
|
|
|
|
| 927 |
demo = None
|
| 928 |
|
| 929 |
# Final check: ensure demo is set for Spaces
|
| 930 |
+
if IS_SPACES:
|
| 931 |
+
if demo is None:
|
| 932 |
+
logger.error("CRITICAL: Demo is None on Spaces! Creating fallback demo.")
|
| 933 |
+
try:
|
| 934 |
+
with gr.Blocks() as fallback_demo:
|
| 935 |
+
gr.Markdown("# Error: Demo was not created properly\n\nPlease check the logs for details.")
|
| 936 |
+
demo = fallback_demo
|
| 937 |
+
except Exception as e:
|
| 938 |
+
logger.error(f"Failed to create fallback demo: {e}")
|
| 939 |
+
else:
|
| 940 |
+
logger.info(f"✅ Demo is ready for Spaces. Final check: demo={demo}, type={type(demo)}")
|
| 941 |
+
# Explicitly ensure demo is accessible
|
| 942 |
+
if hasattr(demo, 'launch'):
|
| 943 |
+
logger.info("Demo has launch method - ready to use")
|
| 944 |
|
| 945 |
# For local execution only (not on Spaces)
|
| 946 |
if __name__ == "__main__":
|