2121from pycsghub .cmd .repo_types import RepoType
2222from pycsghub .constants import DEFAULT_CSGHUB_DOMAIN , DEFAULT_REVISION , REPO_SOURCE_CSG
2323from pycsghub .api_client import get_csghub_api
24- from .utils import print_download_result
24+ from .utils import print_download_result , disable_xnet
2525from .lfs import LfsEnableCommand , LfsUploadCommand
2626from .upload_large_folder .main import upload_large_folder_internal
2727
@@ -89,7 +89,7 @@ def version_callback(value: bool):
8989 "path" : typer .Argument (help = "Local path to repository you want to configure." ),
9090}
9191
92- @app .command (name = "download" , help = "Download model/dataset/space from OpenCSG Hub" , no_args_is_help = True )
92+ @app .command (name = "download" , help = "Download model/dataset/space/code/mcp from OpenCSG Hub" , no_args_is_help = True )
9393def download (
9494 repo_id : Annotated [str , OPTIONS ["repoID" ]],
9595 filenames : Annotated [
@@ -112,7 +112,7 @@ def download(
112112 force_download : Annotated [Optional [bool ], OPTIONS ["force_download" ]] = False ,
113113 max_workers : Annotated [Optional [int ], OPTIONS ["max_workers" ]] = 8 ,
114114):
115- api = get_csghub_api (token = token , endpoint = endpoint )
115+ api = get_csghub_api (repo_type = repo_type , token = token , endpoint = endpoint )
116116
117117 # Handle single/multiple file args similar to HF
118118 filenames_list = filenames if filenames is not None else []
@@ -186,7 +186,8 @@ def download(
186186 except Exception as e :
187187 if quiet :
188188 raise e
189- print (f"Download failed: { e } " )
189+
190+ logger .error (f"Download with xnet-disabled { disable_xnet ()} failed: { e } " )
190191 raise typer .Exit (code = 1 )
191192
192193 if quiet :
@@ -196,7 +197,7 @@ def download(
196197 else :
197198 print_download_result (result )
198199
199- @app .command (name = "upload" , help = "Upload repository files to OpenCSG Hub" , no_args_is_help = True )
200+ @app .command (name = "upload" , help = "Upload model/dataset/space/code/mcp files to OpenCSG Hub" , no_args_is_help = True )
200201def upload (
201202 repo_id : Annotated [str , OPTIONS ["repoID" ]],
202203 local_path : Annotated [str , OPTIONS ["localPath" ]],
@@ -216,8 +217,9 @@ def upload(
216217 every : Annotated [Optional [float ], OPTIONS ["every" ]] = None ,
217218 quiet : Annotated [bool , OPTIONS ["quiet" ]] = False ,
218219):
220+
219221 repo_type_str = repo_type .value
220- api = get_csghub_api (token = token , endpoint = endpoint , user_name = user_name )
222+ api = get_csghub_api (repo_type = repo_type , token = token , endpoint = endpoint , user_name = user_name )
221223
222224 resolved_local_path = local_path
223225 resolved_path_in_repo = path_in_repo
@@ -236,7 +238,7 @@ def run_upload() -> dict:
236238 # Placeholder for Scheduler
237239 # Scheduler not implemented yet in csghub-sdk
238240 # Similar to HF CommitScheduler logic
239- print (f"Scheduling commits every { every } minutes... (Not fully implemented)" )
241+ logger . info (f"Scheduling commits every { every } minutes... (Not fully implemented)" )
240242 try :
241243 while True :
242244 time .sleep (100 )
@@ -246,6 +248,7 @@ def run_upload() -> dict:
246248 if not os .path .isfile (resolved_local_path ) and not os .path .isdir (resolved_local_path ):
247249 raise FileNotFoundError (f"No such file or directory: '{ resolved_local_path } '." )
248250
251+ logger .debug (f"Uploading { repo_type_str } { repo_id } from { resolved_local_path } to { resolved_path_in_repo } " )
249252 # Create repo if needed
250253 api .create_repo (
251254 repo_id = repo_id ,
@@ -259,7 +262,7 @@ def run_upload() -> dict:
259262 try :
260263 api .repo_info (repo_id = repo_id , repo_type = repo_type_str , revision = revision )
261264 except Exception : # RevisionNotFoundError
262- logger .info (f"Branch '{ revision } ' not found. Creating it..." )
265+ logger .warning (f"Branch '{ revision } ' not found. Creating it..." )
263266 api .create_branch (repo_id = repo_id , repo_type = repo_type_str , branch = revision , exist_ok = True )
264267
265268 if os .path .isfile (resolved_local_path ):
@@ -292,10 +295,12 @@ def run_upload() -> dict:
292295 disable_progress_bars ()
293296 with warnings .catch_warnings ():
294297 warnings .simplefilter ("ignore" )
295- print (run_upload ())
298+ result = run_upload ()
299+ logger .debug (f"Upload result { result } " )
296300 enable_progress_bars ()
297301 else :
298- print (run_upload ())
302+ result = run_upload ()
303+ logger .debug (f"Upload result { result } " )
299304
300305@app .command (name = "upload-large-folder" , help = "Upload large folder to OpenCSG Hub using multiple workers" ,
301306 no_args_is_help = True )
0 commit comments