Skip to content

Instantly share code, notes, and snippets.

@AntreasAntoniou
Created May 4, 2023 18:03
Show Gist options
  • Save AntreasAntoniou/d75cb822dd1f3f46ad8f923135913e6f to your computer and use it in GitHub Desktop.
Save AntreasAntoniou/d75cb822dd1f3f46ad8f923135913e6f to your computer and use it in GitHub Desktop.
Automatically set all huggingface user repos to private
import requests
from huggingface_hub import Repository, HfApi
if __name__ == "__main__":
import os
from rich import print
huggingface_username = os.environ.get("HF_USERNAME")
huggingface_api_token = os.environ.get("HF_API_TOKEN")
client = HfApi(token=huggingface_api_token)
for model_repo in client.list_models(author=huggingface_username):
print(f"Setting {model_repo} to private")
client.update_repo_visibility(
repo_id=model_repo.__dict__["modelId"], private=True
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment