|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from datetime import datetime, timezone |
|
|
|
from huggingface_hub import HfApi |
|
|
|
|
|
def garbage_collect_empty_models(token: str | None = None): |
|
api = HfApi(token=token) |
|
now = datetime.now(timezone.utc) |
|
print("Running garbage collection on mergekit-community.") |
|
for model in api.list_models(author="mergekit-community", full=True): |
|
if model.siblings and len(model.siblings) > 1: |
|
|
|
continue |
|
if (now - model.last_modified).total_seconds() < 3600: |
|
|
|
|
|
print("Skipping", model.modelId, "(recently updated)") |
|
continue |
|
try: |
|
print(f"Deleting {model.modelId}") |
|
api.delete_repo(model.modelId, missing_ok=True) |
|
except Exception as e: |
|
print(f"Error deleting {model.modelId}: {e}") |
|
|
|
|
|
if __name__ == "__main__": |
|
garbage_collect_empty_models() |
|
|