Skip to content

[codex] Replace curl subprocess with huggingface_hub in _get_hf_username - #349

Open
rahulrao85 wants to merge 1 commit into
huggingface:mainfrom
rahulrao85:fix/manager-curl-to-hfapi
Open

[codex] Replace curl subprocess with huggingface_hub in _get_hf_username#349
rahulrao85 wants to merge 1 commit into
huggingface:mainfrom
rahulrao85:fix/manager-curl-to-hfapi

Conversation

@rahulrao85

Copy link
Copy Markdown

Summary

Replace the subprocess.run(['curl', ...]) call in _get_hf_username() with huggingface_hub.HfApi().whoami(token=hf_token).

Motivation

  • curl is not available on Windows by default — breaks the agent on Windows
  • The project already depends on huggingface_hub — no new dependency needed
  • HfApi().whoami() handles IPv6 Happy Eyeballs internally (the reason curl -4 was used)

Validation

  • from huggingface_hub import HfApi confirmed importable with the project's huggingface-hub>=1.12.0 dependency
  • Function signature unchanged: _get_hf_username(hf_token: str | None = None) -> str
  • Maintains same fallback behavior: returns "unknown" on any failure

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant