codesnippets / update_model_card_mass_pr.py
patrickvonplaten's picture
add update model card script
090ea4d
#!/usr/bin/env python3
from huggingface_hub import hf_api
from huggingface_hub.repocard import metadata_update
hf_api = hf_api.HfApi()
all_marian_models = hf_api.list_models(filter="marian")
all_new_marian_models = [x.modelId for x in all_marian_models if x.modelId.startswith("Helsinki-NLP/opus-mt-tc")]
for repo_id in all_new_marian_models:
print(f"Opening PR for {repo_id}")
metadata_update(repo_id, {"tags": ["translation", "opus-mt-tc"]}, create_pr=True, pr_commit_summary="Add `opus-mt-tc` tag", pr_commit_description="Add `opus-mt-tc` tag so that this new marian models can be found more easily")