feat(publish): read HF token from ~/.config/leadforge/credentials#89
Merged
Conversation
Add _resolve_token() and _read_token_from_credentials_file() helpers to scripts/publish_hf.py. Token lookup priority: 1. --token CLI arg 2. HF_TOKEN / HUGGING_FACE_HUB_TOKEN env var 3. ~/.config/leadforge/credentials (KEY=VALUE file, new fallback) 4. huggingface_hub stored login cache Placeholder values (lines starting with 'REPLACE_WITH') are ignored. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds a credentials-file fallback for the Hugging Face token used by scripts/publish_hf.py, so users can avoid setting env vars or relying on the huggingface-cli keyring.
Changes:
- New
_read_token_from_credentials_file()parses~/.config/leadforge/credentials(KEY=VALUE), skipping blanks/comments and ignoringREPLACE_WITH*placeholders. - New
_resolve_token()applies the priority chain: CLI arg → env var → credentials file → None. main()resolves the token once and threads it through_upload()and_go_public().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
pr-agent-context report: No unresolved review comments, failing checks, or actionable patch coverage gaps were found on PR #89 in repository https://github.com/leadforge-dev/leadforge. Treat this PR as all clear unless new signals appear.Run metadata: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a
~/.config/leadforge/credentialsfile as a fallback token source inscripts/publish_hf.py.Token resolution order (highest priority first)
--tokenCLI argHF_TOKEN/HUGGING_FACE_HUB_TOKENenv var~/.config/leadforge/credentials(new —KEY=VALUEfile)huggingface_hub's own credential cache (huggingface-cli login)Placeholder values starting with
REPLACE_WITHare silently ignored so the unedited template file doesn't accidentally match.New helpers
_read_token_from_credentials_file()— parses the file, skips blanks and comments_resolve_token(cli_token)— runs the four-step priority chain;main()calls this once and threadstokenthrough to both_upload()and_go_public()Context
~/.config/leadforge/credentialswas created in the previous session with anHF_TOKEN=REPLACE_WITH_YOUR_HUGGINGFACE_TOKENplaceholder. The user fills in the real token once; every subsequentpublish_hf.pyinvocation picks it up automatically without touching env vars or the keyring.🤖 Generated with Claude Code