[codex] Replace curl subprocess with huggingface_hub in _get_hf_username - #349
Open
rahulrao85 wants to merge 1 commit into
Open
[codex] Replace curl subprocess with huggingface_hub in _get_hf_username#349rahulrao85 wants to merge 1 commit into
rahulrao85 wants to merge 1 commit into
Conversation
The _get_hf_username function was using subprocess + curl to resolve the Hugging Face username from a token. This is non-portable (curl is not available on Windows by default) and introduces an unnecessary external dependency. Replace with HfApi().whoami(token=hf_token) from the huggingface_hub SDK, which is already a project dependency and handles IPv6 Happy Eyeballs internally. Signed-off-by: Rahul Rao <rahulrao85@gmail.com>
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.
Summary
Replace the
subprocess.run(['curl', ...])call in_get_hf_username()withhuggingface_hub.HfApi().whoami(token=hf_token).Motivation
curlis not available on Windows by default — breaks the agent on Windowshuggingface_hub— no new dependency neededHfApi().whoami()handles IPv6 Happy Eyeballs internally (the reasoncurl -4was used)Validation
from huggingface_hub import HfApiconfirmed importable with the project'shuggingface-hub>=1.12.0dependency_get_hf_username(hf_token: str | None = None) -> str"unknown"on any failure