Skip to content

Commit c0c6af4

Browse files
abidlabsWauplin
andcommitted
Fix set_space_volume / delete_space_volume return types (#4061)
* fix: parse Space volumes mutation response or fetch runtime PUT/DELETE /spaces/.../volumes may return JSON without a top-level stage. HfApi.set_space_volumes and delete_space_volumes now fall back to get_space_runtime when the body is empty or not a full runtime payload. Made-with: Cursor * refactor: parse SpaceRuntime from mutation response with try/except fallback Made-with: Cursor * test: collapse Space volumes mutation tests into one case Made-with: Cursor * test: keep single Space volumes regression (non-runtime JSON payload) Made-with: Cursor * just return None --------- Co-authored-by: Lucain Pouget <lucainp@gmail.com>
1 parent 6d1a377 commit c0c6af4

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

src/huggingface_hub/hf_api.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8165,7 +8165,7 @@ def set_space_volumes(
81658165
volumes: list[Volume],
81668166
*,
81678167
token: bool | str | None = None,
8168-
) -> SpaceRuntime:
8168+
) -> None:
81698169
"""Set volumes for a Space.
81708170

81718171
Sets (or replaces) the list of volumes mounted in the Space. Each volume gives the Space's container access
@@ -8184,9 +8184,6 @@ def set_space_volumes(
81848184
https://huggingface.co/docs/huggingface_hub/quick-start#authentication).
81858185
To disable authentication, pass `False`.
81868186

8187-
Returns:
8188-
[`SpaceRuntime`]: Runtime information about a Space including Space stage and hardware.
8189-
81908187
Raises:
81918188
[`BadRequestError`]:
81928189
If the Space is a static Space (volumes are not supported on static Spaces).
@@ -8211,15 +8208,14 @@ def set_space_volumes(
82118208
json=payload,
82128209
)
82138210
hf_raise_for_status(r)
8214-
return SpaceRuntime(r.json())
82158211

82168212
@validate_hf_hub_args
82178213
def delete_space_volumes(
82188214
self,
82198215
repo_id: str,
82208216
*,
82218217
token: bool | str | None = None,
8222-
) -> SpaceRuntime:
8218+
) -> None:
82238219
"""Remove all volumes from a Space.
82248220

82258221
Args:
@@ -8231,9 +8227,6 @@ def delete_space_volumes(
82318227
https://huggingface.co/docs/huggingface_hub/quick-start#authentication).
82328228
To disable authentication, pass `False`.
82338229

8234-
Returns:
8235-
[`SpaceRuntime`]: Runtime information about a Space including Space stage and hardware.
8236-
82378230
Raises:
82388231
[`BadRequestError`]:
82398232
If the Space has no volumes attached.
@@ -8250,7 +8243,6 @@ def delete_space_volumes(
82508243
headers=self._build_hf_headers(token=token),
82518244
)
82528245
hf_raise_for_status(r)
8253-
return SpaceRuntime(r.json())
82548246

82558247
#######################
82568248
# Inference Endpoints #

0 commit comments

Comments
 (0)