Skip to content

Commit

Permalink
CI fix clean_skops.py (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinjalali authored Dec 2, 2022
1 parent ec8df2f commit 53119d7
Showing 1 changed file with 5 additions and 5 deletions.
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)

0 comments on commit 53119d7

Please sign in to comment.