2626from trackio .bucket_storage import create_bucket_if_not_exists , upload_project_to_bucket
2727from trackio .space_volumes import (
2828 attach_bucket_volume ,
29- resolve_bucket_id_for_deploy ,
3029)
3130from trackio .sqlite_storage import SQLiteStorage
3231from 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 )
0 commit comments