Anthonyg5005 commited on
Commit
d5e1170
·
verified ·
1 Parent(s): 265a38e

add login token detection and helpful notes

Browse files
Files changed (1) hide show
  1. create new branch.py +10 -1
create new branch.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import os
2
  import huggingface_hub
3
  from huggingface_hub import create_branch
@@ -7,8 +8,16 @@ repo = input("Repository name: ")
7
  r_type = input("Repo type (model) (dataset) (space): ")
8
  branch = input("New branch name: ")
9
 
 
 
 
 
 
 
 
 
10
  #login
11
- huggingface_hub.login(os.environ['HF_TOKEN'])
12
 
13
  #create the branch
14
  create_branch(repo, repo_type=r_type, branch=branch)
 
1
+ #import required modules
2
  import os
3
  import huggingface_hub
4
  from huggingface_hub import create_branch
 
8
  r_type = input("Repo type (model) (dataset) (space): ")
9
  branch = input("New branch name: ")
10
 
11
+ #get token
12
+ if 'HF_TOKEN' in os.environ:
13
+ #if the variable is found then write it to hf_token:
14
+ hf_token = os.environ['HF_TOKEN']
15
+ else:
16
+ #if the variable is not found then prompt user to provide it:
17
+ hf_token = input("HF_TOKEN Variable not detected. Enter your HuggingFace token: ")
18
+
19
  #login
20
+ huggingface_hub.login(hf_token)
21
 
22
  #create the branch
23
  create_branch(repo, repo_type=r_type, branch=branch)