login

Contents

login#

rapidtools.auth.login(token: str | None = None, dataset_id: str = 'hf_token') → bool[source]#

Authenticate this machine with the Hugging Face Hub.

Resolution order: an explicit token, a token already cached by huggingface-cli login, then the token file published in the rapidtools dataset registry (downloaded, used, and deleted).

Parameters:
  • token – Hugging Face access token. When given it is cached for future sessions.

  • dataset_id – Registry entry holding the fallback token file.

Returns:

bool – True when a token is available afterwards, False when every source failed (the failure is logged, never raised).

Example

>>> from rapidtools.auth import login
>>> login(token='hf_example')
True