Skip to content

Commit

Permalink
Fix Space runtime on static Space (#1754)
Browse files Browse the repository at this point in the history
* Fix Space runtime on static Space

* comment
  • Loading branch information
Wauplin authored Oct 17, 2023
1 parent 85b7753 commit 5c19b56
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/huggingface_hub/_space_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ class SpaceRuntime:

def __init__(self, data: Dict) -> None:
self.stage = data["stage"]
self.hardware = data["hardware"]["current"]
self.requested_hardware = data["hardware"]["requested"]
self.sleep_time = data["gcTimeout"]
self.storage = data["storage"]
self.hardware = data.get("hardware", {}).get("current")
self.requested_hardware = data.get("hardware", {}).get("requested")
self.sleep_time = data.get("gcTimeout")
self.storage = data.get("storage")
self.raw = data


Expand Down
8 changes: 8 additions & 0 deletions tests/test_hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2540,6 +2540,14 @@ def test_space_runtime(self) -> None:
# Raw response from Hub
self.assertIsInstance(runtime.raw, dict)

def test_static_space_runtime(self) -> None:
"""
Regression test for static Spaces.
See https://github.com/huggingface/huggingface_hub/pull/1754.
"""
runtime = self.api.get_space_runtime("victor/static-space")
self.assertIsInstance(runtime.raw, dict)

def test_pause_and_restart_space(self) -> None:
# Upload a fake app.py file
self.api.upload_file(path_or_fileobj=b"", path_in_repo="app.py", repo_id=self.repo_id, repo_type="space")
Expand Down

0 comments on commit 5c19b56

Please sign in to comment.