Failed to download the file and need to delete the created file path

This commit is contained in:
JiangCheng 2023-06-05 16:04:54 +08:00
parent 2d967b786d
commit dd612fd72e
1 changed files with 13 additions and 8 deletions

View File

@ -292,15 +292,20 @@ class ModelManager(object):
else:
os.makedirs(output_path, exist_ok=True)
print(f" > Downloading model to {output_path}")
# download from fairseq
if "fairseq" in model_name:
self.download_fairseq_model(model_name, output_path)
else:
# download from github release
if isinstance(model_item["github_rls_url"], list):
self._download_model_files(model_item["github_rls_url"], output_path, self.progress_bar)
try:
# download from fairseq
if "fairseq" in model_name:
self.download_fairseq_model(model_name, output_path)
else:
self._download_zip_file(model_item["github_rls_url"], output_path, self.progress_bar)
# download from github release
if isinstance(model_item["github_rls_url"], list):
self._download_model_files(model_item["github_rls_url"], output_path, self.progress_bar)
else:
self._download_zip_file(model_item["github_rls_url"], output_path, self.progress_bar)
except requests.Exception.RequestException as e:
print(f" > Failed to download the model file to {output_path}")
rmtree(output_path)
raise e
self.print_model_license(model_item=model_item)
# find downloaded files
output_model_path = output_path