Skip to content

Commit fcb476c

Browse files
Tweaks (#475)
Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
1 parent 0967cb1 commit fcb476c

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

.changeset/all-drinks-admire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"trackio": minor
3+
---
4+
5+
feat:Tweaks

trackio/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ def init(
135135
case the Space will be created in the currently-logged-in Hugging Face
136136
user's namespace. If the Space does not exist, it will be created. If the
137137
Space already exists, the project will be logged to it. Can also be set
138-
via the `TRACKIO_SPACE_ID` environment variable.
138+
via the `TRACKIO_SPACE_ID` environment variable. You cannot log to a
139+
Space that has been **frozen** (converted to the static SDK); use
140+
``trackio.sync(..., sdk="static")`` only after you are done logging.
139141
space_storage ([`~huggingface_hub.SpaceStorage`], *optional*):
140142
Choice of persistent storage tier.
141143
dataset_id (`str`, *optional*):
@@ -211,6 +213,9 @@ def init(
211213
f"You must be logged in to Hugging Face locally when `space_id` is provided to deploy to a Space. {e}"
212214
) from e
213215

216+
if space_id is not None:
217+
deploy.raise_if_space_is_frozen_for_logging(space_id)
218+
214219
url = context_vars.current_server.get()
215220

216221
if space_id is not None:

trackio/deploy.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@
4343
_RESET = "\033[0m"
4444

4545

46+
def raise_if_space_is_frozen_for_logging(space_id: str) -> None:
47+
try:
48+
info = huggingface_hub.HfApi().space_info(space_id)
49+
except RepositoryNotFoundError:
50+
return
51+
if getattr(info, "sdk", None) == "static":
52+
raise RuntimeError(
53+
f"Cannot log to Hugging Face Space '{space_id}' because it has been frozen "
54+
f"(it uses the static SDK: a read-only dashboard with no live Trackio server).\n\n"
55+
f"Use a different space_id for training, or create a new Gradio Trackio Space. "
56+
f"Freezing converts a live Gradio Space to static after a run; a frozen Space "
57+
f'cannot accept new logs. See trackio.sync(..., sdk="static") in the Trackio docs.'
58+
)
59+
60+
4661
def _readme_linked_hub_yaml(dataset_id: str | None) -> str:
4762
if dataset_id is not None:
4863
return f"datasets:\n - {dataset_id}\n"
@@ -709,6 +724,11 @@ def sync(
709724
Syncs a local Trackio project's database to a Hugging Face Space.
710725
If the Space does not exist, it will be created.
711726
727+
**Freezing:** Passing ``sdk="static"`` *freezes* the Space: it converts a live Gradio
728+
Space into a static Space backed by an HF Bucket (read-only dashboard, no Gradio
729+
server). You cannot log new metrics to a frozen Space; use a different ``space_id``
730+
or a new Gradio Space for further training runs.
731+
712732
Args:
713733
project (`str`): The name of the project to upload.
714734
space_id (`str`, *optional*): The ID of the Space to upload to (e.g., `"username/space_id"`).
@@ -725,7 +745,7 @@ def sync(
725745
If `False`, all the steps will be run synchronously.
726746
sdk (`str`, *optional*, defaults to `"gradio"`):
727747
The type of Space to deploy. `"gradio"` deploys a Gradio Space with a live
728-
server. `"static"` deploys a static Space that reads from an HF Bucket
748+
server. `"static"` freezes the Space: deploys a static Space that reads from an HF Bucket
729749
(no server needed).
730750
dataset_id (`str`, *optional*):
731751
Deprecated. Use `bucket_id` instead.

0 commit comments

Comments
 (0)