docs: give manage-spaces walkthrough steps real headings#4108
Merged
Wauplin merged 1 commit intohuggingface:mainfrom Apr 15, 2026
Merged
docs: give manage-spaces walkthrough steps real headings#4108Wauplin merged 1 commit intohuggingface:mainfrom
Wauplin merged 1 commit intohuggingface:mainfrom
Conversation
Steps 1-6 in "A simple example" were bold pseudo-headings and didn't generate anchors. That broke `#mount-volumes-in-your-space` deep-links used from hub-docs#2377 and storage-buckets-access.md. Promoting to H3 gives each step an auto-generated anchor and a sidebar entry. Drop the leading `N.` numbers — step order is preserved by document position. `Bonus:` subsections stay bold since they are variants of their parent step, not peers. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
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. |
4 tasks
davanstrien
added a commit
to davanstrien/huggingface_hub
that referenced
this pull request
Apr 15, 2026
- Promote "Debug a failing Space" heading to ### (matches PR huggingface#4108 style) - Add hint when run logs are empty, suggesting --build as alternative - Add tests covering the empty-logs hint for both run and build modes - Regenerate CLI reference docs to include hf spaces logs command
Wauplin
added a commit
that referenced
this pull request
Apr 15, 2026
* [Spaces] Add fetch_space_logs + hf spaces logs command Agents and scripts currently have no way to read Space build/run logs programmatically — the endpoint is only reachable via raw curl. This adds a public API to close that gap. - HfApi.fetch_space_logs(repo_id, *, build=False, follow=False) yields log lines as Iterable[str]. build=True switches to container build logs; default is the running app's stdout/stderr. - `hf spaces logs <repo_id> [--build] [-f] [-n N]` mirrors the Python API at the CLI level, with 404/403 mapped to clean CLIError messages. The helper trusts the "stream close = done" server contract (confirmed against moon-landing's SpaceLogs.svelte onClose handler) and does not poll SpaceStage; read timeout + bounded retries handle the misbehaving-upstream case. Structure mirrors _fetch_running_job_sse but without the status-check backstop. Tests use the mock-based pattern from hf jobs logs (no new VCR cassettes). Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Update generated CLI reference for hf spaces logs Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Fix: catch HfHubHTTPError instead of httpx.HTTPStatusError hf_raise_for_status() raises HfHubHTTPError (inherits HTTPError), not httpx.HTTPStatusError. The previous handler was dead code, causing 404/403 errors to fall through to the retry loop instead of raising immediately. Spotted by cursor bugbot on PR review. Note: the same bug exists in _fetch_running_job_sse — not fixed here to keep the diff focused, but worth a follow-up. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Update docs/source/en/guides/manage-spaces.md Co-authored-by: Lucain <[email protected]> * Refactor: share SSE streaming loop between Spaces and Jobs Extracts `HfApi._stream_sse_events` to unify the retry/backoff/dedup loop previously duplicated across `_fetch_space_logs_sse` and `_fetch_running_job_sse`. Addresses Wauplin and Cursor Bugbot review comments on PR #4091. Also fixes a dead `except httpx.HTTPStatusError` handler that affected both Spaces and Jobs: `hf_raise_for_status` raises `HfHubHTTPError` (subclass of `httpx.HTTPError`, not `HTTPStatusError`), so 404/403 in follow mode used to fall through to the broad retry arm and stall for ~25s. The new helper catches `HfHubHTTPError` before the broad arm, so permanent errors fail fast. Live-verified: `hf spaces logs missing/x -f` now errors in <1s instead of ~25s. CLI cleanups on `hf spaces logs` per Wauplin: - Switch from `print()` to `out.text(line.strip())` (new mode-aware printer from #3979). - Drop the redundant local `HfHubHTTPError` block — it's already handled by the global CLI error mapper. Also tightens `_fetch_running_job_sse` typing by splitting the legacy `double_check_job_has_finished_on_status_code_or_error` mixed tuple into `tolerated_status_codes: tuple[int, ...]` and `tolerated_exception_types: tuple[type[Exception], ...]`, eliminating a runtime type-discrimination step. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Drop dead `httpx.ReadTimeout` entry from fetch_job_metrics The entry in `tolerated_exception_types` was never consulted: the SSE helper's `is_no_new_line_timeout` check short-circuits the tolerated tuple lookup for any ReadTimeout, so the tuple entry was dead code (pre-existing on `main` before #4091, preserved faithfully through the refactor). ReadTimeout tolerance continues to work via the `is_no_new_line_timeout` path. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]> * Update src/huggingface_hub/cli/spaces.py Co-authored-by: Lucain <[email protected]> * Update tests/test_cli.py Co-authored-by: Lucain <[email protected]> * Update tests/test_cli.py Co-authored-by: Lucain <[email protected]> * Address review feedback on fetch_space_logs - Promote "Debug a failing Space" heading to ### (matches PR #4108 style) - Add hint when run logs are empty, suggesting --build as alternative - Add tests covering the empty-logs hint for both run and build modes - Regenerate CLI reference docs to include hf spaces logs command * Update tests/test_cli.py --------- Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]> Co-authored-by: Lucain <[email protected]>
Contributor
|
This PR has been shipped as part of the v1.11.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.
Summary
Steps 1–6 under "A simple example" were
**bold pseudo-headings**, which doc-builder doesn't turn into anchors. Promote them to###so each step gets a real slug (#configure-secrets-and-variables,#mount-volumes-in-your-space, etc.) and a sidebar entry.Why: deep-linkable anchors are how this guide gets cross-referenced from other docs — and increasingly, how both humans and LLM agents discover the right section without scrolling a long page. huggingface/hub-docs#2377 and
hub-docs/docs/hub/storage-buckets-access.mdalready reference#mount-volumes-in-your-space; today those links silently resolve to page-top. This fixes them and makes every other step linkable for free.Leading
N.numbers and trailing periods dropped — step order is preserved by document position.**Bonus: ...**subsections intentionally left as bold since they're variants of their parent step, not peers. Translations (de/ko) left untouched.Test plan
#mount-volumes-in-your-spaceand the other step anchors jump to the right section🤖 Generated with Claude Code
Note
Low Risk
Low risk documentation-only change; main impact is updated section slugs/anchors which may affect deep links if any relied on the old (non-heading) formatting.
Overview
Updates
docs/source/en/guides/manage-spaces.mdby promoting steps 1–6 in the “A simple example” walkthrough from bold pseudo-headings to real###headings (and dropping the leading numbering/trailing periods).This makes each step generate a proper doc-builder slug/anchor (and likely sidebar entry) for reliable deep linking (e.g.,
#mount-volumes-in-your-space).Reviewed by Cursor Bugbot for commit 1a724d3. Bugbot is set up for automated code reviews on this repo. Configure here.