[CLI] Suppress hints in quiet output mode#4310
Merged
Wauplin merged 3 commits intoJun 8, 2026
Merged
Conversation
Make `out.hint()` a no-op in json and quiet modes so machine-readable output stays clean, rather than gating per-command. Human and agent modes still emit hints (agent next-command hints are a feature and go to stderr, so they don't pollute parsed stdout). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4310 +/- ##
==========================================
+ Coverage 75.00% 76.30% +1.30%
==========================================
Files 145 173 +28
Lines 13978 20312 +6334
==========================================
+ Hits 10484 15500 +5016
- Misses 3494 4812 +1318 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Keep hints in json mode (treat it like agent) since agents commonly run with --format json and the next-command hints are useful there; hints go to stderr so they never pollute parsed stdout. Only quiet stays silent. Addresses review from @hanouticelina, agreed by @Wauplin (huggingface#4310). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
davanstrien
added a commit
to davanstrien/huggingface_hub
that referenced
this pull request
Jun 9, 2026
…ton) Now that hint suppression is centralized in the `out` singleton (huggingface#4310), the `out.mode not in (json, quiet)` guard on the empty-`ps` hint is redundant: quiet is suppressed centrally, and json gets the hint on stderr (treated like agent). Remove the guard and the now-unused OutputFormat import. Update test_ps_empty_json to parse result.stdout (the hint goes to stderr and never pollutes the JSON), matching the other json.loads tests. Regenerate cli.md so the --detach examples are in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wauplin
added a commit
that referenced
this pull request
Jun 9, 2026
* [CLI] Agent-friendly hints + examples for hf jobs - logs: note that --follow exits when the stream ends regardless of job outcome; add a hint pointing at `hf jobs inspect <id>` for the final status - ps: hint about -a/--all when nothing is running and no filters are set - run/uv run: detach hint points at `logs -f` / `inspect`; add `-d` examples so the detach->poll workflow is discoverable (feeds the auto-generated skill) Hints go to stderr (out convention) so they don't pollute agent-parsed stdout. No --format examples on purpose: agent output is already auto-selected via is_agent(). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Don't show 'no running jobs' hint when only label filters applied The ps empty-state branch checked `filters` but not `labels_filters`, so `hf jobs ps --filter label=...` with no matches wrongly suggested `-a/--all` even when running jobs exist (just excluded by the label). Guard the hint on `not labels_filters` too. Reported by Cursor Bugbot on #4308. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Regenerate CLI reference for hf jobs help/examples changes Ran utils/generate_cli_reference.py --update after editing logs docstring and run/uv-run examples. Fixes check_code_quality. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Only show ps empty-state hint in human/agent modes Keep `--format json` (-> []) and `-q` (-> empty) output clean for machine consumers; fixes test_ps_empty_json / test_ps_empty_quiet. Mirrors the out.mode gating already used in repos.py / buckets.py / _file_listing.py. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Keep namespace in job hints so inspect/logs target the right job The logs --follow hint suggested `hf jobs inspect <id>` with only the bare parsed id, and the run/uv-run detach hints used `<id>` too. For jobs addressed via `namespace/job_id` or `--namespace` (or run under an org), that defaults to the current user -> 404 / wrong job. Qualify the reference: logs uses the parsed namespace when set; detach uses job.owner.name. Reported by Cursor Bugbot on #4308. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * Update src/huggingface_hub/cli/jobs.py Co-authored-by: Lucain <lucainp@gmail.com> * Update src/huggingface_hub/cli/jobs.py Co-authored-by: Lucain <lucainp@gmail.com> * [CLI] Drop redundant ps empty-state hint guard (handled by out singleton) Now that hint suppression is centralized in the `out` singleton (#4310), the `out.mode not in (json, quiet)` guard on the empty-`ps` hint is redundant: quiet is suppressed centrally, and json gets the hint on stderr (treated like agent). Remove the guard and the now-unused OutputFormat import. Update test_ps_empty_json to parse result.stdout (the hint goes to stderr and never pollutes the JSON), matching the other json.loads tests. Regenerate cli.md so the --detach examples are in sync. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Lucain <lucainp@gmail.com>
Contributor
|
This PR has been shipped as part of the v1.19.0 release. |
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
out.hint()is now a no-op inquietmode, so--quietoutput stays clean.human,agent, andjsonmodes all still emit hints to stderr — the"next-command" hints are a feature for agents, and agents commonly run with
--format json, sojsonis treated likeagent. Hints go to stderr, so theynever pollute parsed stdout/json.
Previously every
out.hint()printed in all modes, so a command had to guardhints per-call to keep quiet output clean. Moving the rule into the
outsingleton removes that need.
Context
Follow-up to @Wauplin's review on #4308: "we want as minimal
OutputFormatchecks as possible in the commands logic and delegate that part to the
outsingleton … happy to review a PR if you want to remove hints globally from
json/quiet modes." This is that PR.
Scope narrowed during review: @hanouticelina suggested suppressing hints in
quietonly and keeping them injson(treatingjsonlikeagent, sinceagents tend to run
--format jsonwhere the hints are genuinely useful).@Wauplin agreed.
Implications (intentionally left out of this PR)
To keep this focused, I've not touched the per-command guards this makes
redundant — happy to follow up once we agree the shape:
cli/jobs.py— the empty-pshint ([CLI] Agent-friendly hints + examples for hf jobs #4308) is gated without.mode not in (OutputFormat.json, OutputFormat.quiet); that mode guard canbe dropped (the singleton handles quiet, and json then gets the hint too —
consistent with treating json like agent).
cli/buckets.py— the sync-plan hint is wrapped inif plan and not out.is_quiet():; thenot out.is_quiet()guard becomesredundant (the
if plandata check stays).Test
Updated
test_hintto expect a hint in human/agent/json and no output in quiet.Full CLI suite green.
Note
Low Risk
Small behavior change in CLI stderr output for quiet mode only; no auth, data, or API impact.
Overview
Centralizes hint suppression in the CLI
outsingleton:out.hint()now returns immediately inquietmode so--quietstays free of stderr hints without per-command guards.Human, agent, and json modes are unchanged—hints still go to stderr (including for
--format json, where next-command hints stay useful for agents and do not affect parsed stdout). Thetest_hintexpectation for quiet mode is updated to no output.Reviewed by Cursor Bugbot for commit cad6d03. Bugbot is set up for automated code reviews on this repo. Configure here.