Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI fix clean_skops.py #235

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions scripts/clean_skops.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@

# This is the token for the skops user. TODO remove eventually, see issue #47
token = "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"
client = HfApi()
user = client.whoami(token=token)["name"]
client = HfApi(token=token)
user = client.whoami()["name"]
answer = input(
f"Are you sure you want to delete all repos under {user} older than 7 days? (y/[n])"
)
if answer != "y":
exit(1)
models = client.list_models(author=user)
models = [x for x in client.list_models(author=user)]

print(f"Found {len(models)} models, checking their age...")

for model_info in models:
info = client.model_info(model_info.modelId, token=token)
info = client.model_info(model_info.modelId)
age = (
datetime.datetime.now()
- datetime.datetime.fromisoformat(info.lastModified.rsplit(".", 1)[0])
Expand All @@ -31,4 +31,4 @@
print(f"Skipping model: {model_info.modelId}, age: {age}")
continue
print(f"deleting {model_info.modelId}, age: {age} days")
client.delete_repo(model_info.modelId, token=token)
client.delete_repo(model_info.modelId)