Created
May 4, 2023 18:03
-
-
Save AntreasAntoniou/d75cb822dd1f3f46ad8f923135913e6f to your computer and use it in GitHub Desktop.
Automatically set all huggingface user repos to private
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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