-
Notifications
You must be signed in to change notification settings - Fork 982
[CLI] Space hot-reload: wait for up-to-date infos #4049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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, | ||
|
|
@@ -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) | ||
cbensimon marked this conversation as resolved.
Show resolved
Hide resolved
cbensimon marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. StatusLine not finalized after polling loop exitsLow Severity After the 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}") | ||
cbensimon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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: | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.