Skip to content

docs: give manage-spaces walkthrough steps real headings#4108

Merged
Wauplin merged 1 commit intohuggingface:mainfrom
davanstrien:docs/mount-volumes-heading
Apr 15, 2026
Merged

docs: give manage-spaces walkthrough steps real headings#4108
Wauplin merged 1 commit intohuggingface:mainfrom
davanstrien:docs/mount-volumes-heading

Conversation

@davanstrien
Copy link
Copy Markdown
Member

@davanstrien davanstrien commented Apr 15, 2026

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.md already 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

  • Doc-builder preview: each step renders as an H3 with a sidebar entry
  • #mount-volumes-in-your-space and the other step anchors jump to the right section
  • The hub-docs#2377 preview now resolves its link correctly

🤖 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.md by 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.

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

Copy link
Copy Markdown
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me

@Wauplin Wauplin merged commit d6f252c into huggingface:main Apr 15, 2026
3 checks passed
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]>
@huggingface-hub-bot
Copy link
Copy Markdown
Contributor

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

2 participants