Skip to content

Commit db63340

Browse files
committed
changes
1 parent 757e351 commit db63340

3 files changed

Lines changed: 6 additions & 50 deletions

File tree

trackio/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ def init(
254254
dataset_id,
255255
bucket_id,
256256
private,
257-
create_bucket_if_missing=True,
258257
)
259258
user_name, space_name = space_id.split("/")
260259
space_url = deploy.SPACE_HOST_URL.format(

trackio/deploy.py

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
from trackio.bucket_storage import create_bucket_if_not_exists, upload_project_to_bucket
2727
from trackio.space_volumes import (
2828
attach_bucket_volume,
29-
resolve_bucket_id_for_deploy,
3029
)
3130
from trackio.sqlite_storage import SQLiteStorage
3231
from trackio.utils import (
@@ -118,23 +117,13 @@ def deploy_as_space(
118117
dataset_id: str | None = None,
119118
bucket_id: str | None = None,
120119
private: bool | None = None,
121-
*,
122-
create_bucket_if_missing: bool = False,
123-
bucket_short_name: str | None = None,
124-
bucket_read_only: bool = False,
125120
):
126121
if (
127122
os.getenv("SYSTEM") == "spaces"
128123
): # in case a repo with this function is uploaded to spaces
129124
return
130125

131-
resolved_bucket = resolve_bucket_id_for_deploy(
132-
space_id,
133-
bucket_id=bucket_id,
134-
create_bucket_if_missing=create_bucket_if_missing,
135-
bucket_short_name=bucket_short_name,
136-
)
137-
if dataset_id is not None and resolved_bucket is not None:
126+
if dataset_id is not None and bucket_id is not None:
138127
raise ValueError(
139128
"Cannot use bucket volume options together with dataset_id; use one persistence mode."
140129
)
@@ -171,8 +160,8 @@ def deploy_as_space(
171160
# Make sure necessary dependencies are installed by creating a requirements.txt.
172161
is_source_install = _is_trackio_installed_from_source()
173162

174-
if resolved_bucket is not None:
175-
create_bucket_if_not_exists(resolved_bucket, private=private)
163+
if bucket_id is not None:
164+
create_bucket_if_not_exists(bucket_id, private=private)
176165

177166
with open(Path(trackio_path, "README.md"), "r") as f:
178167
readme_content = f.read()
@@ -243,16 +232,15 @@ def deploy_as_space(
243232

244233
if hf_token := huggingface_hub.utils.get_token():
245234
huggingface_hub.add_space_secret(space_id, "HF_TOKEN", hf_token)
246-
if resolved_bucket is not None:
235+
if bucket_id is not None:
247236
changed = attach_bucket_volume(
248237
space_id,
249-
resolved_bucket,
238+
bucket_id,
250239
mount_path="/data",
251-
read_only=bucket_read_only,
252240
)
253241
huggingface_hub.add_space_variable(space_id, "TRACKIO_DIR", "/data/trackio")
254242
if changed:
255-
print(f"* Attached bucket {resolved_bucket} at '/data'")
243+
print(f"* Attached bucket {bucket_id} at '/data'")
256244
elif dataset_id is not None:
257245
huggingface_hub.add_space_variable(space_id, "TRACKIO_DATASET_ID", dataset_id)
258246
if logo_light_url := os.environ.get("TRACKIO_LOGO_LIGHT_URL"):
@@ -276,10 +264,6 @@ def create_space_if_not_exists(
276264
dataset_id: str | None = None,
277265
bucket_id: str | None = None,
278266
private: bool | None = None,
279-
*,
280-
create_bucket_if_missing: bool = False,
281-
bucket_short_name: str | None = None,
282-
bucket_read_only: bool = False,
283267
) -> None:
284268
"""
285269
Creates a new Hugging Face Space if it does not exist.
@@ -298,12 +282,6 @@ def create_space_if_not_exists(
298282
Whether to make the Space private. If `None` (default), the repo will be
299283
public unless the organization's default is private. This value is ignored
300284
if the repo already exists.
301-
create_bucket_if_missing (`bool`, *optional*):
302-
If `True`, create a bucket named `{space_repo}-storage` under the Space owner before attach.
303-
bucket_short_name (`str`, *optional*):
304-
Short bucket name when using `create_bucket_if_missing` (no namespace prefix).
305-
bucket_read_only (`bool`, *optional*):
306-
Mount the bucket read-only.
307285
"""
308286
if "/" not in space_id:
309287
raise ValueError(
@@ -341,9 +319,6 @@ def create_space_if_not_exists(
341319
dataset_id,
342320
bucket_id,
343321
private,
344-
create_bucket_if_missing=create_bucket_if_missing,
345-
bucket_short_name=bucket_short_name,
346-
bucket_read_only=bucket_read_only,
347322
)
348323
print("* Waiting for Space to be ready...")
349324
_wait_until_space_running(space_id)

trackio/space_volumes.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,3 @@ def attach_bucket_volume(
100100
new_vol["readOnly"] = True
101101
set_space_volumes(space_id, existing + [new_vol], token=token)
102102
return True
103-
104-
105-
def resolve_bucket_id_for_deploy(
106-
space_id: str,
107-
*,
108-
bucket_id: str | None,
109-
create_bucket_if_missing: bool,
110-
bucket_short_name: str | None,
111-
) -> str | None:
112-
if bucket_id is not None:
113-
return bucket_id
114-
if not create_bucket_if_missing:
115-
return None
116-
namespace, repo = space_id.split("/", 1)
117-
short = bucket_short_name if bucket_short_name else f"{repo}-storage"
118-
if "/" in short:
119-
short = short.split("/")[-1]
120-
return f"{namespace}/{short}"

0 commit comments

Comments
 (0)