Spaces:
Running
Running
ming
commited on
Commit
·
bf6cabf
1
Parent(s):
7f2a99f
Improve HuggingFace model error handling and startup robustness
Browse files- Add better error logging for HuggingFace model initialization failures
- Improve startup sequence to not crash if HuggingFace model fails to load
- Add warning message when V2 endpoints are disabled due to model loading failure
- Make application more resilient to HuggingFace model loading issues
This should fix the HuggingFace Spaces deployment startup issues.
- app/main.py +1 -0
- app/services/hf_streaming_summarizer.py +3 -0
app/main.py
CHANGED
|
@@ -107,6 +107,7 @@ async def startup_event():
|
|
| 107 |
logger.info(f"✅ HuggingFace model warmup completed in {hf_time:.2f}s")
|
| 108 |
except Exception as e:
|
| 109 |
logger.warning(f"⚠️ HuggingFace model warmup failed: {e}")
|
|
|
|
| 110 |
else:
|
| 111 |
logger.info("⏭️ Skipping V2 HuggingFace warmup (disabled)")
|
| 112 |
|
|
|
|
| 107 |
logger.info(f"✅ HuggingFace model warmup completed in {hf_time:.2f}s")
|
| 108 |
except Exception as e:
|
| 109 |
logger.warning(f"⚠️ HuggingFace model warmup failed: {e}")
|
| 110 |
+
logger.warning("V2 endpoints will be disabled until model loads successfully")
|
| 111 |
else:
|
| 112 |
logger.info("⏭️ Skipping V2 HuggingFace warmup (disabled)")
|
| 113 |
|
app/services/hf_streaming_summarizer.py
CHANGED
|
@@ -63,6 +63,9 @@ class HFStreamingSummarizer:
|
|
| 63 |
|
| 64 |
except Exception as e:
|
| 65 |
logger.error(f"❌ Failed to initialize HuggingFace model: {e}")
|
|
|
|
|
|
|
|
|
|
| 66 |
self.tokenizer = None
|
| 67 |
self.model = None
|
| 68 |
|
|
|
|
| 63 |
|
| 64 |
except Exception as e:
|
| 65 |
logger.error(f"❌ Failed to initialize HuggingFace model: {e}")
|
| 66 |
+
logger.error(f"Model ID: {settings.hf_model_id}")
|
| 67 |
+
logger.error(f"Cache dir: {settings.hf_cache_dir}")
|
| 68 |
+
logger.error(f"Device map: {settings.hf_device_map}")
|
| 69 |
self.tokenizer = None
|
| 70 |
self.model = None
|
| 71 |
|