Skip to content

[CLI] Suppress hints in quiet output mode#4310

Merged
Wauplin merged 3 commits into
huggingface:mainfrom
davanstrien:cli-suppress-hints-json-quiet
Jun 8, 2026
Merged

[CLI] Suppress hints in quiet output mode#4310
Wauplin merged 3 commits into
huggingface:mainfrom
davanstrien:cli-suppress-hints-json-quiet

Conversation

@davanstrien

@davanstrien davanstrien commented Jun 4, 2026

Copy link
Copy Markdown
Member

What

out.hint() is now a no-op in quiet mode, so --quiet output stays clean.
human, agent, and json modes all still emit hints to stderr — the
"next-command" hints are a feature for agents, and agents commonly run with
--format json, so json is treated like agent. Hints go to stderr, so they
never pollute parsed stdout/json.

Previously every out.hint() printed in all modes, so a command had to guard
hints per-call to keep quiet output clean. Moving the rule into the out
singleton removes that need.

Context

Follow-up to @Wauplin's review on #4308: "we want as minimal OutputFormat
checks as possible in the commands logic and delegate that part to the out
singleton … 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
quiet only and keeping them in json (treating json like agent, since
agents tend to run --format json where 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-ps hint ([CLI] Agent-friendly hints + examples for hf jobs #4308) is gated with
    out.mode not in (OutputFormat.json, OutputFormat.quiet); that mode guard can
    be 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 in
    if plan and not out.is_quiet():; the not out.is_quiet() guard becomes
    redundant (the if plan data check stays).

Test

Updated test_hint to 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 out singleton: out.hint() now returns immediately in quiet mode so --quiet stays 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). The test_hint expectation 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.

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>
@bot-ci-comment

bot-ci-comment Bot commented Jun 4, 2026

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.

@davanstrien davanstrien requested a review from Wauplin June 4, 2026 09:00
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.30%. Comparing base (1daa48b) to head (cad6d03).
⚠️ Report is 404 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/huggingface_hub/cli/_output.py Outdated
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 davanstrien changed the title [CLI] Suppress hints in json/quiet output modes [CLI] Suppress hints in quiet output mode Jun 8, 2026

@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.

Thanks :)

@Wauplin Wauplin merged commit 02dc408 into huggingface:main Jun 8, 2026
20 of 22 checks passed
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>
@huggingface-hub-bot

Copy link
Copy Markdown
Contributor

This PR has been shipped as part of the v1.19.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.

3 participants