Skip to content

Commit 4a54d92

Browse files
committed
changes
1 parent f357deb commit 4a54d92

3 files changed

Lines changed: 21 additions & 112 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ readme = "README.md"
1414
requires-python = ">=3.10"
1515
dependencies = [
1616
"pandas<3.0.0",
17-
"huggingface-hub<2.0.0",
17+
"huggingface-hub>=1.9.0rc0,<2.0.0",
1818
"gradio[oauth]>=6.10.0,<7.0.0",
1919
"numpy<3.0.0",
2020
"pillow<12.0.0",

trackio/deploy.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525
import trackio
2626
from trackio.bucket_storage import create_bucket_if_not_exists, upload_project_to_bucket
27-
from trackio.space_volumes import (
28-
attach_bucket_volume,
29-
)
3027
from trackio.sqlite_storage import SQLiteStorage
3128
from trackio.utils import (
3229
MEDIA_DIR,
@@ -233,14 +230,28 @@ def deploy_as_space(
233230
if hf_token := huggingface_hub.utils.get_token():
234231
huggingface_hub.add_space_secret(space_id, "HF_TOKEN", hf_token)
235232
if bucket_id is not None:
236-
changed = attach_bucket_volume(
237-
space_id,
238-
bucket_id,
239-
mount_path="/data",
233+
from huggingface_hub import Volume
234+
235+
hf_api = huggingface_hub.HfApi()
236+
runtime = hf_api.get_space_runtime(space_id)
237+
existing = list(runtime.volumes) if runtime.volumes else []
238+
already_mounted = any(
239+
v.type == "bucket" and v.source == bucket_id and v.mount_path == "/data"
240+
for v in existing
240241
)
241-
huggingface_hub.add_space_variable(space_id, "TRACKIO_DIR", "/data/trackio")
242-
if changed:
242+
if not already_mounted:
243+
non_bucket = [
244+
v
245+
for v in existing
246+
if not (v.type == "bucket" and v.source == bucket_id)
247+
]
248+
hf_api.set_space_volumes(
249+
space_id,
250+
non_bucket
251+
+ [Volume(type="bucket", source=bucket_id, mount_path="/data")],
252+
)
243253
print(f"* Attached bucket {bucket_id} at '/data'")
254+
huggingface_hub.add_space_variable(space_id, "TRACKIO_DIR", "/data/trackio")
244255
elif dataset_id is not None:
245256
huggingface_hub.add_space_variable(space_id, "TRACKIO_DATASET_ID", dataset_id)
246257
if logo_light_url := os.environ.get("TRACKIO_LOGO_LIGHT_URL"):

trackio/space_volumes.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)