Skip to content

Commit 1a8d320

Browse files
committed
Skip spaces version check + add write auth check
1 parent 16fb0e2 commit 1a8d320

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/huggingface_hub/cli/spaces.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@
5757
)
5858

5959

60-
HOT_RELOADING_MIN_GRADIO = "6.0.0"
61-
HOT_RELOADING_MIN_PYSPACES = "0.44.0"
60+
HOT_RELOADING_MIN_GRADIO = "6.1.0"
6261

6362

6463
_EXPAND_PROPERTIES = sorted(get_args(ExpandSpaceProperty_T))
@@ -167,13 +166,13 @@ def spaces_hot_reload(
167166
if (sdk_version := card_data.sdk_version) is None:
168167
raise CLIError(f"Unable to read sdk_version from {space_id} cardData")
169168
if (sdk_version := version.parse(sdk_version)) < version.Version(HOT_RELOADING_MIN_GRADIO):
170-
raise CLIError(f"Hot-reloading requires Gradio 6+ (found {sdk_version})")
171-
if (runtime := space_info.runtime) is None:
172-
raise CLIError(f"Unable to read SpaceRuntime for Space {space_id}")
173-
if (spaces_version := runtime.pyspaces_version) is None:
174-
raise CLIError(f"Unable to read pySpacesVersion from {space_id} SpaceRuntime")
175-
if (spaces_version := version.parse(spaces_version)) < version.Version(HOT_RELOADING_MIN_PYSPACES):
176-
raise CLIError(f"Hot-reloading requires spaces >= 0.44.0 (found {spaces_version})")
169+
raise CLIError(f"Hot-reloading requires Gradio >= {HOT_RELOADING_MIN_GRADIO} (found {sdk_version})")
170+
api.auth_check(
171+
repo_type="spaces",
172+
repo_id=space_id,
173+
write=True,
174+
)
175+
177176
if local_path:
178177
filepath = local_path
179178
elif local:

src/huggingface_hub/hf_api.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10111,7 +10111,12 @@ def list_daily_papers(
1011110111
yield PaperInfo(**paper)
1011210112

1011310113
def auth_check(
10114-
self, repo_id: str, *, repo_type: Optional[str] = None, token: Union[bool, str, None] = None
10114+
self,
10115+
repo_id: str,
10116+
*,
10117+
repo_type: Optional[str] = None,
10118+
token: Union[bool, str, None] = None,
10119+
write: bool = False,
1011510120
) -> None:
1011610121
"""
1011710122
Check if the provided user token has access to a specific repository on the Hugging Face Hub.
@@ -10171,6 +10176,7 @@ def auth_check(
1017110176
if repo_type not in constants.REPO_TYPES:
1017210177
raise ValueError(f"Invalid repo type, must be one of {constants.REPO_TYPES}")
1017310178
path = f"{self.endpoint}/api/{repo_type}s/{repo_id}/auth-check"
10179+
path = f"{path}/write" if write else path
1017410180
r = get_session().get(path, headers=headers)
1017510181
hf_raise_for_status(r)
1017610182

0 commit comments

Comments
 (0)