This commit is contained in:
Awni Hannun 2024-12-31 19:31:46 -08:00
parent b84b483e9f
commit 32d8793583

View File

@ -9,13 +9,10 @@ def ask_for_confirmation(message: str) -> bool:
"""Ask user for confirmation with Y/N prompt. """Ask user for confirmation with Y/N prompt.
Returns True for Y/yes, False for N/no/empty.""" Returns True for Y/yes, False for N/no/empty."""
y = ("y", "yes", "1") y = ("y", "yes", "1")
n = ("n", "no", "0") n = ("n", "no", "0", "")
all_values = y + n + ("",) full_message = f"{message} (y/n) "
full_message = f"{message} (y/N) "
while True: while True:
answer = input(full_message).lower() answer = input(full_message).lower()
if answer == "":
return False
if answer in y: if answer in y:
return True return True
if answer in n: if answer in n:
@ -45,9 +42,7 @@ def main():
args = parser.parse_args() args = parser.parse_args()
if args.scan: if args.scan:
print( print(f'Scanning Hugging Face cache for models with pattern "{args.pattern}".')
f'Scanning Hugging Face cache for models with pattern "{args.pattern}".'
)
hf_cache_info = scan_cache_dir() hf_cache_info = scan_cache_dir()
print( print(
tabulate( tabulate(
@ -107,7 +102,9 @@ def main():
) )
) )
confirmed = ask_for_confirmation("\nAre you sure you want to delete these models?") confirmed = ask_for_confirmation(
"\nAre you sure you want to delete these models?"
)
if confirmed: if confirmed:
for model_info in repos: for model_info in repos:
print(f"\nDeleting {model_info.repo_id}...") print(f"\nDeleting {model_info.repo_id}...")