raft-submission / hooks /pre_gen_project.py
lewtun's picture
lewtun HF staff
Refactor submission instructions
2dcd69b
raw
history blame
525 Bytes
from huggingface_hub import HfApi, HfFolder, Repository
hf_user = "{{cookiecutter.hf_hub_username}}"
hf_password = "{{cookiecutter.hf_hub_password}}"
huggingface_token = HfApi().login(username=hf_user, password=hf_password)
HfFolder.save_token(huggingface_token)
repo_url = HfApi().create_repo(
token=huggingface_token,
name="{{cookiecutter.repo_name}}",
organization=hf_user,
exist_ok=True,
private=True,
)
model_repo = Repository(local_dir=".", clone_from=repo_url, use_auth_token=huggingface_token)