huggingface_hub
dbc5df62 - [CLI] Agent-friendly hints + examples for hf jobs (#4308)

Commit
51 days ago
[CLI] Agent-friendly hints + examples for hf jobs (#4308) * [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>
Author
Parents
Loading