Add HuggingFace token warning and authentication docs#1323
Add HuggingFace token warning and authentication docs#1323henrykironde merged 2 commits intoweecology:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1323 +/- ##
=======================================
Coverage 86.97% 86.97%
=======================================
Files 24 24
Lines 3009 3009
=======================================
Hits 2617 2617
Misses 392 392
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi, thanks for working on this! |
|
Thanks @vickysharma-prog for the contribution and @musaqlain for the suggestions. |
|
@henrykironde I noticed #1325 also covers the warning implementation. I'm adding the runtime warning and tests to this PR as well to keep everything in one place. |
|
@henrykironde Added a runtime warning for a missing HuggingFace token, along with tests. The warning is emitted once per process when no token is found and points users to the documentation for setup instructions. Changes in this update:
Squashed into a single commit for a clean history. Happy to address any feedback! |
5552a1f to
572b416
Compare
| $env:HF_TOKEN="your_token_here" | ||
| ``` | ||
|
|
||
| **Python:** |
There was a problem hiding this comment.
The Python version part can be dropped.
|
|
||
| When downloading models from HuggingFace Hub, you may see a warning about unauthenticated requests. Setting a HuggingFace token provides higher rate limits and faster downloads. | ||
|
|
||
| ### Get Your Token |
There was a problem hiding this comment.
I think we can remove the detailed token setup instructions and instead direct users to the Hugging Face documentation. There’s no need to include multiple lines for such a simple setup and clarification.
For more details, see the Hugging Face token documentation.
henrykironde
left a comment
There was a problem hiding this comment.
Thanks @vickysharma-prog — I’ve reviewed Copilot’s PR as well.
I agree that we should keep the documentation in docs/getting_started/install.md as you’ve done. However, we need to simplify it. I’d suggest borrowing from Copilot’s more streamlined approach and combining that with your steps to create a cleaner, simpler version in this file. We can place it just above the GPU instructions.
As for the additional file/code changes to catch exceptions and raise warnings, I think that’s overkill. We should drop that.
|
This PR closes #1325 |
|
Thanks @henrykironde for the review! |
|
@henrykironde Updated simplified the docs and removed the warning code/tests as suggested. Ready for re-review! |
|
Hi @henrykironde, just a gentle follow-up I've simplified the docs and removed the warning code as you suggested. Let me know if anything else is needed! |
henrykironde
left a comment
There was a problem hiding this comment.
Thanks for the PR @vickysharma-prog
Description
Adds HuggingFace token authentication docs and a runtime warning for missing tokens.
Changes
Documentation (
docs/getting_started/install.md):Runtime Warning (
src/deepforest/main.py):_warn_if_no_hf_token()helperload_model()when no token is foundTests (
tests/test_main.py):Related Issue(s)
Fixes #1322
AI-Assisted Development
AI tools used (if applicable):
None – written manually following existing codebase patterns.