hfutils.repository.base

This module provides utility functions for working with Hugging Face Hub repositories and Git.

It includes functions to:

  1. Generate Hugging Face Hub repository URLs.

  2. Check Git and Git LFS installations.

The module uses the git_info function from the hbutils.system package and constants from huggingface_hub.

hf_hub_repo_url

hfutils.repository.base.hf_hub_repo_url(repo_id: str, repo_type: Literal['dataset', 'model', 'space'] = 'dataset', endpoint: str | None = None) str[source]

Generate a Hugging Face Hub repository URL.

Parameters:
  • repo_id (str) – The repository ID.

  • repo_type (RepoTypeTyping) – The type of repository. Can be ‘model’, ‘dataset’, or ‘space’. Defaults to ‘dataset’.

  • endpoint (Optional[str]) – The Hugging Face Hub endpoint. If None, uses the default ENDPOINT.

Returns:

The full URL for the specified Hugging Face Hub repository.

Return type:

str

Raises:

ValueError – If an unknown repository type is provided.

Usage:
>>> hf_hub_repo_url('username/repo', 'model')
'https://huggingface.co/username/repo'
>>> hf_hub_repo_url('username/dataset', 'dataset')
'https://huggingface.co/datasets/username/dataset'