Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/huggingface_hub/cli/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ def spaces_hot_reload(
raise CLIError(f"Unable to read sdk_version from {space_id} cardData")
if version.parse(sdk_version) < version.Version(HOT_RELOADING_MIN_GRADIO):
raise CLIError(f"Hot-reloading requires Gradio >= {HOT_RELOADING_MIN_GRADIO} (found {sdk_version})")
if (current_sha := space_info.sha) is None:
raise CLIError(f"Unexpected `None` running SHA for Space {space_id}")
else:
current_sha = None

if local_file:
local_path = local_file
Expand Down Expand Up @@ -329,6 +333,7 @@ def spaces_hot_reload(
_spaces_hot_reload_summary(
api=api,
space_id=space_id,
current_sha=current_sha,
commit_sha=commit_info.oid,
local_path=local_path if local_file else os.path.basename(local_path),
token=token,
Expand All @@ -338,11 +343,18 @@ def spaces_hot_reload(
def _spaces_hot_reload_summary(
api: HfApi,
space_id: str,
current_sha: str | None,
commit_sha: str,
local_path: str | None,
token: str | None,
) -> None:
space_info = api.space_info(space_id)
while (space_info := api.space_info(space_id)).sha == current_sha:
if current_sha is None:
break
typer.secho("Waiting for up-to-date Space infos", fg=typer.colors.BRIGHT_BLACK)
time.sleep(2)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

StatusLine not finalized after polling loop exits

Low Severity

After the while polling loop exits, status.done(...) is never called. StatusLine.update() writes to stderr without a trailing newline, so if the loop ran at least once, subsequent output (from typer.secho, raise CLIError, etc.) will appear on the same terminal line as the leftover "Waiting for up-to-date Space info..." message. The dev_mode function in the same file properly calls status.done(...) on every exit path from its analogous polling loop.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 2751eae. Configure here.

if space_info.sha != commit_sha:
raise CLIError(f"Expected SHA {commit_sha} after hot-reload but got {space_info.sha}")
if (runtime := space_info.runtime) is None:
raise CLIError(f"Unable to read SpaceRuntime from {space_id} infos")
if (hot_reloading := runtime.hot_reloading) is None:
Expand Down
Loading