88from grutopia .core .util import is_in_container
99from grutopia .macros import gm
1010
11+ RED = '\033 [31m'
12+ END = '\033 [0m'
13+
1114# Default environment name
1215DEFAULT_ENV_NAME = ''
1316
@@ -37,7 +40,7 @@ def create_conda_env():
3740 print (f"Creating Conda environment '{ DEFAULT_ENV_NAME } ' for downloading dataset..." )
3841 subprocess .check_call (['conda' , 'create' , '--name' , DEFAULT_ENV_NAME , '--yes' , 'python=3.10' ])
3942 except subprocess .CalledProcessError as e :
40- print (f"Error creating Conda environment '{ DEFAULT_ENV_NAME } ': { e } " )
43+ print (f"{ RED } ERROR { END } : Error creating Conda environment '{ DEFAULT_ENV_NAME } ': { e } " )
4144 raise
4245
4346
@@ -186,7 +189,7 @@ def delete_conda_env():
186189 print (f"Deleting Conda environment '{ DEFAULT_ENV_NAME } '..." )
187190 subprocess .check_call (['conda' , 'env' , 'remove' , '--name' , DEFAULT_ENV_NAME , '--yes' ])
188191 except subprocess .CalledProcessError as e :
189- print (f"Error deleting Conda environment '{ DEFAULT_ENV_NAME } ': { e } " )
192+ print (f"{ RED } ERROR { END } : Error deleting Conda environment '{ DEFAULT_ENV_NAME } ': { e } " )
190193
191194
192195def unzip_all (dir_path ):
@@ -237,6 +240,7 @@ def main():
237240 if dataset_src not in ['huggingface' , 'modelscope' , 'openxlab' ]:
238241 print ("Invalid dataset source. Please choose 'huggingface' or 'modelscope' or 'openxlab'." )
239242 return
243+ print (f'Dataset will be downloaded from { dataset_src } .' )
240244
241245 # Determine the target path
242246 target_path = gm .ASSET_PATH
@@ -269,13 +273,19 @@ def main():
269273 with open (config_file , 'w' ) as f :
270274 f .write (f'DEFAULT_ASSETS_PATH = "{ target_path } "' )
271275 print (f'Assets will be installed under this location: { target_path } ' )
272- path_confirm = input ('Do you want to continue? (Y/n): ' ).strip ().lower ()
273- if path_confirm not in ['y' , 'yes' ]:
274- return
275276
276- # Check if dataset already exists
277+ # Check if target path already exists
277278 if os .path .exists (target_path ):
278- print (f'Dataset already exists at { target_path } . No need to download again.' )
279+ if os .path .isdir (target_path ):
280+ resume = input (f'Directory { target_path } already exists. Resume last download? (Y/n): ' ).lower ()
281+ if resume not in ['y' , 'yes' , '' ]:
282+ return
283+ else :
284+ print (f'{ RED } ERROR{ END } : { target_path } is not a directory.' )
285+ return
286+
287+ path_confirm = input ('Do you want to continue? (Y/n): ' ).strip ().lower ()
288+ if path_confirm not in ['y' , 'yes' , '' ]:
279289 return
280290
281291 # Create a conda env for download
@@ -297,9 +307,7 @@ def main():
297307 unzip_all (target_path )
298308
299309 except Exception as e :
300- print (f'Error downloading assets: { e } ' )
301- print ('Removing downloaded assets files...' )
302- remove_dir (target_path )
310+ print (f'{ RED } ERROR{ END } : Error downloading assets: { e } ' )
303311 except KeyboardInterrupt :
304312 if DEFAULT_ENV_NAME != '' :
305313 cleanup_process (dataset_src )
0 commit comments