[CLI] Migrate hf cache to out singleton#4070
Conversation
|
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. |
|
@cursoragent review |
|
The PR already exists and I don't need to update its title or body — my commit is already pushed. Here's my review summary: I reviewed the PR and found two functional issues that I fixed: 1. 2. All 221 CLI tests pass, |
…failures - out.result() in rm, prune, verify now passes structured data kwargs so json/quiet modes emit useful output instead of empty strings - verify mismatch/missing/extra details now use out.error() instead of out.text() so they are visible in all output modes (text is a no-op in json/quiet) - update test assertions to use result.output (stdout+stderr) for error messages that now go to stderr via out.error() Co-authored-by: célina <[email protected]>
|
@cursoragent revert 2f95baa |
… verify failures" This reverts commit 2f95baa.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 09df44d. Configure here.
…uggingface_hub into cli-migrate-commands-part3
|
@Wauplin one thing i noticed is that in x hf cache rm model/m42-health/Llama3-Med42-70B --json --yes
Delete repo: /Users/hcelina/.cache/huggingface/hub/models--m42-health--Llama3-Med42-70B
Cache deletion done. Saved 8.8K.
{"repos_deleted": 1, "revisions_deleted": 1, "freed": "8.8K"} # in json mode we only want the dictI don't think we should disable info logging in |
Wauplin
left a comment
There was a problem hiding this comment.
Tested locally and approved! Minor comment + out.confirm can be handled separately
one thing i noticed is that in json or agent, library level logger.info() messages can leak into stdout.
I don't think we should disable info logging in _output.py since set_mode() is called at import time. instead, we disable it in the _set_output_mode callback when mode is not human. what do you think?
Yes indeed I see the problem. What do you think of redirecting logger.info() to stderr instead of stdout when in agent/json mode? so that the agent still have the info but we do not pollute the stdout. (and yes agree in doing it at runtime in _set_output_mode).
Otherwise I'm ok to disable logs entirely, I'm just unsure what we will be missing.
| ) | ||
| return | ||
|
|
||
| if not yes and not typer.confirm("Proceed with deletion?", default=False): |
There was a problem hiding this comment.
note: change typer.confirm with out.confirm (once implemented) so that in agent mode with gracefully raise error (mentioned in #3979)
| ) | ||
| return | ||
|
|
||
| if not yes and not typer.confirm("Proceed?"): |
Co-authored-by: Lucain <[email protected]>
|
@Wauplin actually I'm dumb (and tricked by Opus 🙃), > hf cache rm model/bartowski/Qwen2.5-Coder-14B-GGUF --yes --format json 2>/dev/null
{"repos_deleted": 1, "revisions_deleted": 1, "freed": "15.7G"} |
|
This PR has been shipped as part of the v1.11.0 release. |



Part of #3979
This PR migrates all
cachesubcommands (ls,rm,prune,verify) to theoutsingleton.it introduces some notable breaking changes, in addition to those that affects all migrated commands (e.g.
-q/--quietreplaced by--format quiet, errors and warnings goes to stderr instead of stdout):hf cache ls --format json:idfield added (e.g.model/unsloth/Qwen3.5-35B-A3B-GGUF)size_on_disk(int, bytes) replaced bysize(formatted string, e.g."1.2 GB")last_accessedandlast_modifiedchanged from float timestamps to formatted strings (e.g."3 days ago")Note
Medium Risk
This changes
hf cacheCLI flags and output formats (including--quietremoval and different JSON/table fields), which can break user scripts and tests that parse stdout/stderr.Overview
Migrates all
hf cachesubcommands (ls,rm,prune,verify) to theoutoutput singleton and standardizes output handling via--format [agent|auto|human|json|quiet].This replaces the legacy
--quietflag with--format quiet, updateslsrendering to go throughout.table(including revised JSON/table fields such as addingidand emitting human-formattedsize/time strings), and routes warnings/errors/success messages throughout(changing stdout/stderr behavior).Docs and CLI tests are updated to reflect the new
--formatoption and the adjusted output assertions.Reviewed by Cursor Bugbot for commit 09df44d. Bugbot is set up for automated code reviews on this repo. Configure here.