From f0cabe003de496358cf9bbc2806857f1bcd748e6 Mon Sep 17 00:00:00 2001 From: nemo Date: Mon, 20 Jan 2025 15:21:07 +0100 Subject: [PATCH] Make style --- scripts/ci_clean_cache.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/ci_clean_cache.py b/scripts/ci_clean_cache.py index e927c0bac3..8e4bfbaa0a 100644 --- a/scripts/ci_clean_cache.py +++ b/scripts/ci_clean_cache.py @@ -8,11 +8,12 @@ Deletion can be enabled by passing `-d` parameter, otherwise it will only list the candidates. """ + import sys -import argparse -from huggingface_hub import scan_cache_dir from datetime import datetime as dt +from huggingface_hub import scan_cache_dir + def find_old_revisions(scan_results, max_age_days=30): """Find commit hashes of objects in the cache. These objects need a last access time that @@ -30,8 +31,8 @@ def find_old_revisions(scan_results, max_age_days=30): def delete_old_revisions(scan_results, delete_candidates, do_delete=False): delete_operation = scan_results.delete_revisions(*delete_candidates) - print(f'Would free {delete_operation.expected_freed_size_str}') - print(f'Candidates: {delete_candidates}') + print(f"Would free {delete_operation.expected_freed_size_str}") + print(f"Candidates: {delete_candidates}") if do_delete: print("Deleting now.") @@ -44,18 +45,23 @@ def delete_old_revisions(scan_results, delete_candidates, do_delete=False): from argparse import ArgumentParser parser = ArgumentParser() - parser.add_argument('-a', '--max-age', type=int, default=30, help="Max. age in days items in the cache may have.") - parser.add_argument('-d', '--delete', action='store_true', help=( - "Delete mode; Really delete items if there are candidates. Exit code = 0 when we found something to delete, 1 " - "otherwise." - )) + parser.add_argument("-a", "--max-age", type=int, default=30, help="Max. age in days items in the cache may have.") + parser.add_argument( + "-d", + "--delete", + action="store_true", + help=( + "Delete mode; Really delete items if there are candidates. Exit code = 0 when we found something to delete, 1 " + "otherwise." + ), + ) args = parser.parse_args() scan_results = scan_cache_dir() delete_candidates = find_old_revisions(scan_results, args.max_age) if not delete_candidates: - print('No delete candidates found, not deleting anything.') + print("No delete candidates found, not deleting anything.") sys.exit(1) delete_old_revisions(scan_results, delete_candidates, do_delete=args.delete)