File size: 711 Bytes
cf5659c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python

# creates a local auth token file which can then be safely used by other programs without leaking
# the password in public git

import getpass
import json
from pathlib import Path
from huggingface_hub import HfApi

HUB_DATA_PATH_SHARED = "/gpfsdswork/projects/rech/six/commun/auth/.hub_info.json"
#HUB_DATA_PATH = Path(__file__).resolve().parent / ".hub_info.json"

username = input("Hub username: ")
password = getpass.getpass("Hub password: ")
email = input("Hub email: ")
auth_token = HfApi().login(username=username, password=password)

data = dict(username=username, email=email, auth_token=auth_token)
#print(data)

with open(HUB_DATA_PATH_SHARED, 'w') as f:
    json.dump(data, f)