chore: add hf retries to files#322
Conversation
📝 WalkthroughWalkthroughCentralizes HTTP error handling and transient-retry logic in the HuggingFace backend. Introduces internal utilities to map errors, parse retry delays, and run HuggingFace API calls with automatic retry. Applies retry infrastructure to metadata and config retrieval, streaming downloads, and validates with test helpers and new test cases. ChangesHuggingFace Transient Retry Handling
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
services/core/files/src/nmp/core/files/app/backends/huggingface.py (1)
178-192: 📐 Maintainability & Code Quality | 💤 Low valueLine 192 is unreachable.
The loop always either returns on line 181, raises on line 183, or raises on line 190. This
raisecan never execute. Harmless defensive code, but could be removed or replaced with an assertion to clarify intent.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/core/files/src/nmp/core/files/app/backends/huggingface.py` around lines 178 - 192, The final raise in _run_hf_request is unreachable because the loop always returns or raises; remove the trailing "raise HuggingfaceBackendError(...)" and replace it with an explicit assertion to document intent (e.g., assert False or raise AssertionError("unreachable in _run_hf_request")). Update surrounding references to _HF_TRANSIENT_RETRY_ATTEMPTS, EntryNotFoundError, HfHubHTTPError, _map_hf_http_error, HuggingfaceUnavailableError, and _sleep_before_retry as needed to ensure control flow is still clear.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@services/core/files/src/nmp/core/files/app/backends/huggingface.py`:
- Around line 178-192: The final raise in _run_hf_request is unreachable because
the loop always returns or raises; remove the trailing "raise
HuggingfaceBackendError(...)" and replace it with an explicit assertion to
document intent (e.g., assert False or raise AssertionError("unreachable in
_run_hf_request")). Update surrounding references to
_HF_TRANSIENT_RETRY_ATTEMPTS, EntryNotFoundError, HfHubHTTPError,
_map_hf_http_error, HuggingfaceUnavailableError, and _sleep_before_retry as
needed to ensure control flow is still clear.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 78b3df66-4bfd-4a24-ba49-ef418aa09363
📒 Files selected for processing (2)
services/core/files/src/nmp/core/files/app/backends/huggingface.pyservices/core/files/tests/test_huggingface_backend.py
|
Summary by CodeRabbit
Refactor
Tests