Skip to content

[CLI] Migrate extensions, lfs-enable-largefiles, version to out singleton#4284

Merged
hanouticelina merged 1 commit into
mainfrom
cli-migrate-lfs-extensions-system-out
May 27, 2026
Merged

[CLI] Migrate extensions, lfs-enable-largefiles, version to out singleton#4284
hanouticelina merged 1 commit into
mainfrom
cli-migrate-lfs-extensions-system-out

Conversation

@hanouticelina

@hanouticelina hanouticelina commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Part of #3979. Migrates the last few stragglers that still used print() directly: hf extensions install, hf extensions remove, hf lfs-enable-largefiles, and hf version.

  • hf extensions installout.result("<Type> extension installed", source=..., command=...) + an out.hint("Run it with: hf <name>") for the follow-up.
  • hf extensions removeout.result("Extension removed", name=...).
  • hf lfs-enable-largefilesout.result("Local repo set up for largefiles", path=...).
  • hf version (the subcommand) → out.result("hf version", version=...). The global --version flag in hf.py keeps its raw print(__version__) because it fires as an eager Typer callback before out is set up.

hf extensions ls and hf extensions search were already migrated in #4057 — this PR just cleans up the leftover write paths in the same module.

Examples

$ hf version
✓ hf version
  version: 1.17.0.dev0

$ hf version --format json
{"version": "1.17.0.dev0"}

$ hf version --format quiet
1.17.0.dev0

$ hf version --format agent
version=1.17.0.dev0
$ hf lfs-enable-largefiles ./my-repo
✓ Local repo set up for largefiles
  path: /Users/celina/my-repo

$ hf lfs-enable-largefiles ./my-repo --format json
{"path": "/Users/celina/my-repo"}
$ hf extensions install gradio-app/hf-gradio
✓ Python extension installed
  source: gradio-app/hf-gradio
  command: hf gradio
Hint: Run it with: hf gradio

$ hf extensions remove gradio
✓ Extension removed
  name: gradio

Note

Low Risk
Output-only changes with no behavior to auth, uploads, or extension install logic beyond formatting.

Overview
Finishes the CLI output migration (#3979) by replacing the last direct print() calls in extensions, lfs-enable-largefiles, and the version subcommand with the shared out helpers.

hf extensions install now reports success via out.result (type, source, command) and uses out.hint for the run command. hf extensions remove and hf lfs-enable-largefiles use out.result with structured fields. hf version prints through out.result so --format (json, quiet, agent) works like other commands; the global --version flag is unchanged and still prints raw text before out is initialized.

Reviewed by Cursor Bugbot for commit d8cceae. Configure here.

…n` to `out`

- `lfs_enable_largefiles` → `out.result("Local repo set up for largefiles", path=...)`
- `extensions install` → structured `out.result(... source=..., command=...)`
  + `out.hint("Run it with: hf <name>")` for the actionable follow-up.
- `extensions remove` → `out.result("Extension removed", name=...)`.
- `hf version` (the subcommand) → `out.result("hf version", version=...)`. The
  global `--version` flag in `hf.py` keeps a raw `print` because it fires as an
  eager typer callback before `out` is wired up.
@hanouticelina hanouticelina requested a review from Wauplin May 27, 2026 15:51

@Wauplin Wauplin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last commands to migrate? 🙌

@bot-ci-comment

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@hanouticelina

Copy link
Copy Markdown
Collaborator Author

Last commands to migrate? 🙌

yes!

@hanouticelina hanouticelina merged commit 5c7920e into main May 27, 2026
25 of 26 checks passed
@hanouticelina hanouticelina deleted the cli-migrate-lfs-extensions-system-out branch May 27, 2026 16:00
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.17.0 release.

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.

2 participants