hfutils.utils.path

hf_normpath

hfutils.utils.path.hf_normpath(path) str[source]

Normalize a given path.

Parameters:

path (Any) – The path to normalize.

Returns:

The normalized path.

Return type:

str

hf_fs_path

hfutils.utils.path.hf_fs_path(repo_id: str, filename: str, repo_type: Literal['dataset', 'model', 'space'] = 'dataset', revision: str | None = None)[source]

Get the huggingface filesystem path.

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

  • filename (str) – The filename.

  • repo_type (RepoTypeTyping) – The type of repository. (default: ‘dataset’)

  • revision (Optional[str]) – The revision of the repository. (default: None)

Returns:

The huggingface filesystem path.

Return type:

str

parse_hf_fs_path

hfutils.utils.path.parse_hf_fs_path(path: str) HfFileSystemPath[source]

Parse the huggingface filesystem path.

Parameters:

path (str) – The path to parse.

Returns:

The parsed huggingface filesystem path.

Return type:

HfFileSystemPath

Raises:

ValueError – If this path is invalid.

HfFileSystemPath

class hfutils.utils.path.HfFileSystemPath(repo_id: str, filename: str, repo_type: Literal['dataset', 'model', 'space'], revision: str | None)[source]

Huggingface FileSystem Path.

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

  • filename (str) – The filename.

  • repo_type (RepoTypeTyping) – The type of repository.

  • revision (Optional[str]) – The revision of the repository.