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,6 +292,7 @@ class ModelManager(object):
else: else:
os.makedirs(output_path, exist_ok=True) os.makedirs(output_path, exist_ok=True)
print(f" > Downloading model to {output_path}") print(f" > Downloading model to {output_path}")
try:
# download from fairseq # download from fairseq
if "fairseq" in model_name: if "fairseq" in model_name:
self.download_fairseq_model(model_name, output_path) self.download_fairseq_model(model_name, output_path)
@ -301,6 +302,10 @@ class ModelManager(object):
self._download_model_files(model_item["github_rls_url"], output_path, self.progress_bar) self._download_model_files(model_item["github_rls_url"], output_path, self.progress_bar)
else: else:
self._download_zip_file(model_item["github_rls_url"], output_path, self.progress_bar) 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) self.print_model_license(model_item=model_item)
# find downloaded files # find downloaded files
output_model_path = output_path output_model_path = output_path