#!/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 = "/pfs/lustrep4/scratch/project_462000119/muennighoff/nov-2022-bettercom/.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)