File size: 655 Bytes
d5e1170
117c7e8
 
 
 
 
 
265a38e
117c7e8
 
d5e1170
 
 
 
 
 
 
 
117c7e8
d5e1170
117c7e8
 
265a38e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#import required modules
import os
import huggingface_hub
from huggingface_hub import create_branch

#get user variables
repo = input("Repository name: ")
r_type = input("Repo type (model) (dataset) (space): ")
branch = input("New branch name: ")

#get token
if 'HF_TOKEN' in os.environ:
    #if the variable is found then write it to hf_token:
    hf_token = os.environ['HF_TOKEN']
else:
    #if the variable is not found then prompt user to provide it:
    hf_token = input("HF_TOKEN Variable not detected. Enter your HuggingFace token: ")

#login
huggingface_hub.login(hf_token)

#create the branch
create_branch(repo, repo_type=r_type, branch=branch)