# `HuggingfaceClient.Hub.Snapshots`
[🔗](https://github.com/huggingface/huggingface_client/blob/v0.1.0/lib/huggingface_client/hub/snapshots.ex#L1)

Cache path utilities for HuggingFace Hub snapshots.

Mirrors the Python `huggingface_hub.snapshot_download` cache layout so that
cached files produced by either library are interoperable.

## Cache layout

    $HF_HOME/hub/
      models--gpt2/
        refs/
          main
        blobs/
          <sha256>
        snapshots/
          <commit_sha>/
            config.json -> ../../blobs/<sha256>

# `repo_type`

```elixir
@type repo_type() :: :model | :dataset | :space
```

# `default_cache_dir`

```elixir
@spec default_cache_dir() :: String.t()
```

Returns the default root cache directory for Hub snapshots.

Equivalent to `$HF_HUB_CACHE`, defaulting to `~/.cache/huggingface/hub`.

# `repo_folder_name`

```elixir
@spec repo_folder_name(String.t(), repo_type()) :: String.t()
```

Returns the folder name for a given `repo_id` and `repo_type`.

Replaces `/` with `--` in the repo ID, matching the Python implementation.

## Examples

    iex> HuggingfaceClient.Hub.Snapshots.repo_folder_name("gpt2", :model)
    "models--gpt2"

    iex> HuggingfaceClient.Hub.Snapshots.repo_folder_name("meta-llama/Llama-3.1-8B-Instruct", :model)
    "models--meta-llama--Llama-3.1-8B-Instruct"

    iex> HuggingfaceClient.Hub.Snapshots.repo_folder_name("rajpurkar/squad", :dataset)
    "datasets--rajpurkar--squad"

# `repo_path`

```elixir
@spec repo_path(String.t(), repo_type(), String.t() | nil) :: String.t()
```

Returns the full on-disk path for a cached repo's snapshot root.

    ~/.cache/huggingface/hub/models--gpt2/snapshots

# `snapshot_path`

```elixir
@spec snapshot_path(String.t(), repo_type(), String.t(), String.t() | nil) ::
  String.t()
```

Returns the path for a specific snapshot revision of a repo.

    ~/.cache/huggingface/hub/models--gpt2/snapshots/<revision>

---

*Consult [api-reference.md](api-reference.md) for complete listing*
