question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Store user token in huggingface home folder

See original GitHub issue

At the moment when the user uses login() to set its User Access Token, the token is stored in the file ~/.huggingface/token.

This path is currently not configurable. The right behavior would be to reuse “HF home folder”. By order of priority, this means the token would be stored under:

# if HF_HOME is set
$HF_HOME/token

# otherwise if XDG_CACHE_HOME is set (unix)
$XDG_CACHE_HOME/huggingface/token

# otherwise in default folder
~/.cache/huggingface/token

In the process of making this change we should take care of not breaking anything that currently exists. As I see it, we could:

  1. On HfFolder.save_token(...): store the token in HF_HOME/token.
  2. On HfFolder.delete_token(): delete from ~/.huggingface/token and HF_HOME/token
  3. On HfFolder.get_token(): read from HF_HOME/token if it exists. Otherwise read from ~/.huggingface/token, save under HF_HOME/token and return the token.

In all 3 cases, raise a warning “hey, you should delete ~/.huggingface/token as this location is deprecated”. This would ensure that with time all users will move to the new token path. I prefer the warning message instead of just deleting the old token path in case the user has multiple virtualenvs with multiple versions of huggingface_hub. We don’t want the user to be forced to login again each time one uses an old version of hfh.

Let’s take care of the consequences on downstream libraries as well (cc @sgugger @LysandreJik @osanseviero)

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Wauplincommented, Dec 6, 2022

Still fixed it in the end

0reactions
julien-ccommented, Dec 2, 2022

is it worth the hassle if no-one has complained about it? (no strong opinion, just asking)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Model sharing and uploading - Hugging Face
It will store your access token in the Hugging Face cache folder (by default ~/.cache/ ). If you don't have an easy access...
Read more >
User access tokens - Hugging Face
To create an access token, go to your settings, then click on the Access Tokens tab. Click on the New token button to...
Read more >
How to login to Huggingface Hub with Access Token - Beginners
I simply want to login to Huggingface HUB using an access token. ... in main service.run() File "C:\Users\mrlor\anaconda3\envs\ldm\lib\site- ...
Read more >
Tokenizer - Hugging Face
Tokenizer. A tokenizer is in charge of preparing the inputs for a model. The library contains tokenizers for all the models. Most of...
Read more >
Environment variables - Hugging Face
HF_HOME. To configure where huggingface_hub will locally store data. In particular, your token and the cache will be stored in this folder.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found