fix: make TDgpt model downloads fallback#35355
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request introduces a centralized Hugging Face model download utility with a fallback mechanism that reverts to the official endpoint if a mirror fails. It updates several service scripts and the model downloader CLI to utilize this new utility, while also improving boolean argument parsing and error handling. Review feedback highlights a logic error in is_official_endpoint regarding environment variable precedence and suggests removing endpoint from kwargs to avoid potential TypeError during the download call.
There was a problem hiding this comment.
Pull request overview
This PR improves reliability of TDgpt model downloads by introducing a shared Hugging Face download helper that supports endpoint overrides and automatic fallback to the official Hugging Face endpoint when a mirror/custom endpoint fails.
Changes:
- Added
hf_download.pyhelper with robust boolean parsing, endpoint resolution, and mirror→official fallback logic. - Updated
model_downloader.pyand multipletsfmservice/*-server.pyscripts to use the shared helper instead of directly callinghuggingface_hub.snapshot_download. - Added focused pytest coverage for endpoint resolution/fallback behavior and invalid CLI boolean handling.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/tdgpt/taosanalytics/misc/hf_download.py | New shared helper for endpoint selection and fallback download behavior. |
| tools/tdgpt/taosanalytics/misc/model_downloader.py | Uses shared helper; fixes CLI boolean parsing + exit code. |
| tools/tdgpt/taosanalytics/tsfmservice/chronos-server.py | Switches model download to helper with fallback support. |
| tools/tdgpt/taosanalytics/tsfmservice/moirai-server.py | Switches model download to helper with fallback support. |
| tools/tdgpt/taosanalytics/tsfmservice/moment-server.py | Switches model download to helper with fallback support. |
| tools/tdgpt/taosanalytics/tsfmservice/timemoe-server.py | Switches model download to helper with fallback support. |
| tools/tdgpt/taosanalytics/tsfmservice/timesfm-server.py | Switches model download to helper with fallback support. |
| tools/tdgpt/tests/hf_download_test.py | New unit tests validating endpoint precedence and fallback behavior. |
| tools/tdgpt/tests/model_downloader_test.py | New test ensuring invalid boolean CLI arg exits cleanly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Test Plan