Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logout raises warning in Colab #1929

Open
osanseviero opened this issue Dec 20, 2023 · 3 comments
Open

Logout raises warning in Colab #1929

osanseviero opened this issue Dec 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@osanseviero
Copy link
Contributor

osanseviero commented Dec 20, 2023

Describe the bug

In Google Colab, if I have no HF_TOKEN secret, I get a long error

Reproduction

from huggingface_hub import logout

logout()

Logs

/usr/local/lib/python3.10/dist-packages/huggingface_hub/_login.py:337: UserWarning: 
The secret `HF_TOKEN` does not exist in your Colab secrets.
To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.
You will be able to reuse this secret in all of your notebooks.
Please note that authentication is recommended but still optional to access public models or datasets.
  warnings.warn(
Successfully logged out.
/usr/local/lib/python3.10/dist-packages/huggingface_hub/_login.py:337: UserWarning: 
The secret `HF_TOKEN` does not exist in your Colab secrets.
To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.
You will be able to reuse this secret in all of your notebooks.
Please note that authentication is recommended but still optional to access public models or datasets.
  warnings.warn(


### System info

```shell
Copy-and-paste the text below in your GitHub issue.

- huggingface_hub version: 0.20.0
- Platform: Linux-6.1.58+-x86_64-with-glibc2.35
- Python version: 3.10.12
- Running in iPython ?: Yes
- iPython shell: Shell
- Running in notebook ?: Yes
- Running in Google Colab ?: Yes
- Token path ?: /root/.cache/huggingface/token
- Has saved token ?: False
- Configured git credential helpers: store
- FastAI: 2.7.13
- Tensorflow: 2.15.0
- Torch: 2.1.0+cu121
- Jinja2: 3.1.2
- Graphviz: 0.20.1
- Pydot: 1.4.2
- Pillow: 9.4.0
- hf_transfer: N/A
- gradio: N/A
- tensorboard: N/A
- numpy: 1.23.5
- pydantic: 1.10.13
- aiohttp: 3.9.1
- ENDPOINT: https://huggingface.co
- HF_HUB_CACHE: /root/.cache/huggingface/hub
- HF_ASSETS_CACHE: /root/.cache/huggingface/assets
- HF_TOKEN_PATH: /root/.cache/huggingface/token
- HF_HUB_OFFLINE: False
- HF_HUB_DISABLE_TELEMETRY: False
- HF_HUB_DISABLE_PROGRESS_BARS: None
- HF_HUB_DISABLE_SYMLINKS_WARNING: False
- HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False
- HF_HUB_DISABLE_IMPLICIT_TOKEN: False
- HF_HUB_ENABLE_HF_TRANSFER: False
- HF_HUB_ETAG_TIMEOUT: 10
- HF_HUB_DOWNLOAD_TIMEOUT: 10

{'huggingface_hub version': '0.20.0',
 'Platform': 'Linux-6.1.58+-x86_64-with-glibc2.35',
 'Python version': '3.10.12',
 'Running in iPython ?': 'Yes',
 'iPython shell': 'Shell',
 'Running in notebook ?': 'Yes',
 'Running in Google Colab ?': 'Yes',
 'Token path ?': '/root/.cache/huggingface/token',
 'Has saved token ?': False,
 'Configured git credential helpers': 'store',
 'FastAI': '2.7.13',
 'Tensorflow': '2.15.0',
 'Torch': '2.1.0+cu121',
 'Jinja2': '3.1.2',
 'Graphviz': '0.20.1',
 'Pydot': '1.4.2',
 'Pillow': '9.4.0',
 'hf_transfer': 'N/A',
 'gradio': 'N/A',
 'tensorboard': 'N/A',
 'numpy': '1.23.5',
 'pydantic': '1.10.13',
 'aiohttp': '3.9.1',
 'ENDPOINT': 'https://huggingface.co',
 'HF_HUB_CACHE': '/root/.cache/huggingface/hub',
 'HF_ASSETS_CACHE': '/root/.cache/huggingface/assets',
 'HF_TOKEN_PATH': '/root/.cache/huggingface/token',
 'HF_HUB_OFFLINE': False,
 'HF_HUB_DISABLE_TELEMETRY': False,
 'HF_HUB_DISABLE_PROGRESS_BARS': None,
 'HF_HUB_DISABLE_SYMLINKS_WARNING': False,
 'HF_HUB_DISABLE_EXPERIMENTAL_WARNING': False,
 'HF_HUB_DISABLE_IMPLICIT_TOKEN': False,
 'HF_HUB_ENABLE_HF_TRANSFER': False,
 'HF_HUB_ETAG_TIMEOUT': 10,
 'HF_HUB_DOWNLOAD_TIMEOUT': 10}
@osanseviero osanseviero added the bug Something isn't working label Dec 20, 2023
@Wauplin
Copy link
Contributor

Wauplin commented Dec 20, 2023

This is kinda expected, no? It's not really an error, it's a warning. The idea is to get quicker adoption by having a warning explaining authentication on Colab when a user tries to authenticate.

For the specific huggingface_hub.logout it feels kinda weird but looks like a corner case no? The logout mechanism should be to disable the HF_TOKEN secret in the Colab settings directly.

@osanseviero
Copy link
Contributor Author

Yes, I think it's a bug in the case of logout, but I agree it's clearly a corner case.

To clarify, doing logout will not remove the secret, is that correct?

@Wauplin
Copy link
Contributor

Wauplin commented Dec 20, 2023

To clarify, doing logout will not remove the secret, is that correct?

That is correct.

However if the secret exists + is shared with the notebook and you call logout, an error will be raised to tell you that you are not logged out. <= this is the real use case that we should take care of IMO.

image

Yes, I think it's a bug in the case of logout, but I agree it's clearly a corner case.

To clarify, this corner case happens only if HF_TOKEN does not exist in your secrets. If it exists but is not shared with the notebook, the warning would be different. We can modify the workflow for logout specifically but low priority imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants