File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 25
25
if os .environ .get ("HF_HUB_ENABLE_HF_TRANSFER" , None ) is None :
26
26
os .environ ["HF_HUB_ENABLE_HF_TRANSFER" ] = "1"
27
27
28
+ # For each model with huggingface distribution path, clean up the old location.
29
+ def _delete_old_hf_models (models_dir : Path ):
30
+ for model_config in load_model_configs ().values ():
31
+ if model_config .distribution_channel == ModelDistributionChannel .HuggingFaceSnapshot :
32
+ if os .path .exists (models_dir / model_config .name ):
33
+ print (f"Cleaning up old model artifacts in { models_dir / model_config .name } . New artifacts will be downloaded to { HUGGINGFACE_HOME_PATH } " )
34
+ shutil .rmtree (models_dir / model_config .name )
35
+
28
36
def _download_hf_snapshot (
29
37
model_config : ModelConfig , hf_token : Optional [str ]
30
38
):
@@ -273,4 +281,5 @@ def where_main(args) -> None:
273
281
274
282
# Subcommand to download model artifacts.
275
283
def download_main (args ) -> None :
284
+ _delete_old_hf_models (args .model_directory )
276
285
download_and_convert (args .model , args .model_directory , args .hf_token )
You can’t perform that action at this time.
0 commit comments