AQIT 0.1.0
Loading...
Searching...
No Matches
aquin.compute.hf_auth Namespace Reference

Functions

dict[str, str] _read_json (Path path)
str _local_hf_token ()
str _cached_hf_token ()
str _aquin_api_key ()
str _aquin_base_url ()
bool _aquin_logged_in ()
None _apply_hf_token (str token)
str _fetch_proxy_token ()
str resolve_hf_token ()
dict[str, Any] hf_hub_kwargs ()
bool ensure_hf_login (*, bool quiet=False)
str _proxy_unavailable_hint ()
None require_hf_hub_auth (*, str hf_repo)
str gated_repo_hint (str hf_repo)

Variables

str _CONFIG_PATH = Path.home() / ".aquin" / "config.json"
str _ENGINE_STATE = Path.home() / ".aquin" / "engine.json"
str _HF_CACHE_TOKEN = Path.home() / ".cache" / "huggingface" / "token"
str _proxy_token = None
str _last_proxy_error = None

Function Documentation

◆ _apply_hf_token()

None _apply_hf_token ( str token)
protected
Expose token to huggingface_hub / transformers via env only (no interactive login).

Definition at line 64 of file hf_auth.py.

References _local_hf_token().

Referenced by ensure_hf_login(), hf_hub_kwargs(), and require_hf_hub_auth().

◆ _aquin_api_key()

str _aquin_api_key ( )
protected

Definition at line 47 of file hf_auth.py.

Referenced by _aquin_logged_in(), and _fetch_proxy_token().

◆ _aquin_base_url()

str _aquin_base_url ( )
protected

Definition at line 52 of file hf_auth.py.

References _read_json().

◆ _aquin_logged_in()

bool _aquin_logged_in ( )
protected

Definition at line 60 of file hf_auth.py.

References _aquin_api_key().

Referenced by gated_repo_hint(), require_hf_hub_auth(), and resolve_hf_token().

◆ _cached_hf_token()

str _cached_hf_token ( )
protected

Definition at line 41 of file hf_auth.py.

Referenced by ensure_hf_login(), and resolve_hf_token().

◆ _fetch_proxy_token()

str _fetch_proxy_token ( )
protected
Fetch HF hub token from Aquin API (Bearer aquin API key).

Definition at line 74 of file hf_auth.py.

References _aquin_api_key().

Referenced by resolve_hf_token().

◆ _local_hf_token()

str _local_hf_token ( )
protected

Definition at line 34 of file hf_auth.py.

Referenced by _apply_hf_token(), ensure_hf_login(), and resolve_hf_token().

◆ _proxy_unavailable_hint()

str _proxy_unavailable_hint ( )
protected

Definition at line 160 of file hf_auth.py.

Referenced by gated_repo_hint(), and require_hf_hub_auth().

◆ _read_json()

dict[str, str] _read_json ( Path path)
protected

Definition at line 24 of file hf_auth.py.

Referenced by _aquin_base_url().

◆ ensure_hf_login()

bool ensure_hf_login ( * ,
bool quiet = False )
Authenticate huggingface_hub for gated downloads.
Prefers HF_TOKEN locally; otherwise optional AQUIN_API_KEY proxy if configured.

Definition at line 145 of file hf_auth.py.

References _apply_hf_token(), _cached_hf_token(), _local_hf_token(), and resolve_hf_token().

◆ gated_repo_hint()

str gated_repo_hint ( str hf_repo)

Definition at line 184 of file hf_auth.py.

References _aquin_logged_in(), _proxy_unavailable_hint(), and resolve_hf_token().

◆ hf_hub_kwargs()

dict[str, Any] hf_hub_kwargs ( )
Ensure HF auth is configured. Returns {} :  env-based auth avoids duplicate token= in TL.

Definition at line 137 of file hf_auth.py.

References _apply_hf_token(), and resolve_hf_token().

◆ require_hf_hub_auth()

None require_hf_hub_auth ( * ,
str hf_repo )
Resolve HF auth before model download. Raises if Aquin login is set but
the server proxy cannot supply a token.

Definition at line 170 of file hf_auth.py.

References _apply_hf_token(), _aquin_logged_in(), _proxy_unavailable_hint(), and resolve_hf_token().

◆ resolve_hf_token()

str resolve_hf_token ( )
Return an HF hub token from env, local cache, or Aquin web proxy.

Definition at line 127 of file hf_auth.py.

References _aquin_logged_in(), _cached_hf_token(), _fetch_proxy_token(), and _local_hf_token().

Referenced by ensure_hf_login(), gated_repo_hint(), hf_hub_kwargs(), and require_hf_hub_auth().

Variable Documentation

◆ _CONFIG_PATH

str aquin.compute.hf_auth._CONFIG_PATH = Path.home() / ".aquin" / "config.json"
protected

Definition at line 16 of file hf_auth.py.

◆ _ENGINE_STATE

str aquin.compute.hf_auth._ENGINE_STATE = Path.home() / ".aquin" / "engine.json"
protected

Definition at line 17 of file hf_auth.py.

◆ _HF_CACHE_TOKEN

str aquin.compute.hf_auth._HF_CACHE_TOKEN = Path.home() / ".cache" / "huggingface" / "token"
protected

Definition at line 18 of file hf_auth.py.

◆ _last_proxy_error

str aquin.compute.hf_auth._last_proxy_error = None
protected

Definition at line 21 of file hf_auth.py.

◆ _proxy_token

str aquin.compute.hf_auth._proxy_token = None
protected

Definition at line 20 of file hf_auth.py.