hfutils.operate.download

download_file_to_file

hfutils.operate.download.download_file_to_file(local_file: str, repo_id: str, file_in_repo: str, repo_type: Literal['dataset', 'model', 'space'] = 'dataset', revision: str = 'main', silent: bool = False)[source]

Download a file from a Hugging Face repository and save it to a local file.

Parameters:
  • local_file (str) – The local file path to save the downloaded file.

  • repo_id (str) – The identifier of the repository.

  • file_in_repo (str) – The file path within the repository.

  • repo_type (RepoTypeTyping) – The type of the repository (‘dataset’, ‘model’, ‘space’).

  • revision (str) – The revision of the repository (e.g., branch, tag, commit hash).

  • silent (bool) – If True, suppress progress bar output.

download_archive_as_directory

hfutils.operate.download.download_archive_as_directory(local_directory: str, repo_id: str, file_in_repo: str, repo_type: Literal['dataset', 'model', 'space'] = 'dataset', revision: str = 'main', silent: bool = False)[source]

Download an archive file from a Hugging Face repository and extract it to a local directory.

Parameters:
  • local_directory (str) – The local directory path to extract the downloaded archive.

  • repo_id (str) – The identifier of the repository.

  • file_in_repo (str) – The file path within the repository.

  • repo_type (RepoTypeTyping) – The type of the repository (‘dataset’, ‘model’, ‘space’).

  • revision (str) – The revision of the repository (e.g., branch, tag, commit hash).

  • silent (bool) – If True, suppress progress bar output.

download_directory_as_directory

hfutils.operate.download.download_directory_as_directory(local_directory: str, repo_id: str, dir_in_repo: str = '.', repo_type: ~typing.Literal['dataset', 'model', 'space'] = 'dataset', revision: str = 'main', silent: bool = False, ignore_patterns: ~typing.List[str] = <object object>)[source]

Download all files in a directory from a Hugging Face repository to a local directory.

Parameters:
  • local_directory (str) – The local directory path to save the downloaded files.

  • repo_id (str) – The identifier of the repository.

  • dir_in_repo (str) – The directory path within the repository.

  • repo_type (RepoTypeTyping) – The type of the repository (‘dataset’, ‘model’, ‘space’).

  • revision (str) – The revision of the repository (e.g., branch, tag, commit hash).

  • silent (bool) – If True, suppress progress bar output.

  • ignore_patterns (List[str]) – List of file patterns to ignore.