From 74462ac713201fd6e8036fcc947c57b9c9924ebf Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 31 Mar 2023 22:52:52 -0300 Subject: [PATCH] Don't override the metadata when checking the sha256sum --- download-model.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/download-model.py b/download-model.py index 75b031bd..43473215 100644 --- a/download-model.py +++ b/download-model.py @@ -197,20 +197,7 @@ if __name__ == '__main__': output_folder = f"{'_'.join(model.split('/')[-2:])}" if branch != 'main': output_folder += f'_{branch}' - - # Creating the folder and writing the metadata output_folder = Path(base_folder) / output_folder - if not output_folder.exists(): - output_folder.mkdir() - with open(output_folder / 'huggingface-metadata.txt', 'w') as f: - f.write(f'url: https://huggingface.co/{model}\n') - f.write(f'branch: {branch}\n') - f.write(f'download date: {str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))}\n') - sha256_str = '' - for i in range(len(sha256)): - sha256_str += f' {sha256[i][1]} {sha256[i][0]}\n' - if sha256_str != '': - f.write(f'sha256sum:\n{sha256_str}') if args.check: # Validate the checksums @@ -238,6 +225,20 @@ if __name__ == '__main__': print('[-] Invalid checksums. Rerun download-model.py with the --clean flag.') else: + + # Creating the folder and writing the metadata + if not output_folder.exists(): + output_folder.mkdir() + with open(output_folder / 'huggingface-metadata.txt', 'w') as f: + f.write(f'url: https://huggingface.co/{model}\n') + f.write(f'branch: {branch}\n') + f.write(f'download date: {str(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))}\n') + sha256_str = '' + for i in range(len(sha256)): + sha256_str += f' {sha256[i][1]} {sha256[i][0]}\n' + if sha256_str != '': + f.write(f'sha256sum:\n{sha256_str}') + # Downloading the files print(f"Downloading the model to {output_folder}") download_files(links, output_folder, args.threads) \ No newline at end of file