Hub Python Library documentation

Buckets

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

Buckets

Buckets menyediakan penyimpanan objek serupa S3 di Hugging Face, didukung oleh backend penyimpanan Xet. Berbeda dengan repositori (yang berbasis git dan melacak riwayat file), buckets adalah kontainer penyimpanan objek jarak jauh yang dirancang untuk file berskala besar dengan deduplikasi yang dapat diidentifikasi berdasarkan konten. Mereka dirancang untuk kasus penggunaan di mana Anda membutuhkan penyimpanan yang sederhana, cepat, dan dapat diubah, seperti menyimpan checkpoint pelatihan, log, artefak antara, atau kumpulan file besar lainnya yang tidak memerlukan kontrol versi.

Anda dapat berinteraksi dengan bucket menggunakan API Python (HfApi) atau CLI (hf buckets). Dalam panduan ini, kami akan membahas semua operasi yang tersedia.

Semua perintah CLI tersedia di bawah hf buckets <command>. Jalankan hf buckets --help untuk mempelajari lebih lanjut.

Buat dan kelola bucket

Buat bucket

Buat bucket dengan create_bucket(). Anda perlu menyediakan nama bucket. Jika Anda tidak menentukan namespace, bucket akan dibuat di bawah nama pengguna Anda.

>>> from huggingface_hub import create_bucket

# Create a bucket under your namespace
>>> url = create_bucket("my-bucket")
>>> url.bucket_id
'username/my-bucket'
>>> url.uri.to_uri()
'hf://buckets/username/my-bucket'

# Create a private bucket
>>> create_bucket("my-private-bucket", private=True)
BucketUrl(...)

# Don't error if bucket already exists
>>> create_bucket("my-bucket", exist_ok=True)
BucketUrl(...)

# Create a bucket in a specific region
>>> create_bucket("my-bucket", region="us")
BucketUrl(...)

Atau melalui CLI:

>>> hf buckets create my-bucket
✓ Bucket created
  uri: hf://buckets/Wauplin/my-bucket
  url: https://huggingface.co/buckets/Wauplin/my-bucket

# Create a private bucket
>>> hf buckets create my-bucket --private

# Don't error if bucket already exists
>>> hf buckets create my-bucket --exist-ok

# Create a bucket in a specific region
>>> hf buckets create my-bucket --region us

Anda juga dapat menentukan format lengkap namespace/bucket_name untuk membuat bucket di bawah organisasi:

>>> from huggingface_hub import create_bucket
>>> create_bucket("my-org/shared-bucket")

Atau melalui CLI:

>>> hf buckets create my-org/shared-bucket

Dapatkan info bucket

Gunakan bucket_info() untuk mendapatkan metadata tentang bucket, termasuk visibilitas, ukuran total, jumlah file, dan tanggal pembuatannya.

>>> from huggingface_hub import bucket_info
>>> bucket_info("username/my-bucket")
BucketInfo(
  id='username/my-bucket',
  private=False,
  created_at=datetime.datetime(2026, 2, 12, 17, 42, 12,
  tzinfo=datetime.timezone.utc),
  size=8411791508,
  total_files=128
)

Atau melalui CLI:

# JSON output
>>> hf buckets info username/my-bucket
{
  "id": "username/my-bucket",
  "private": false,
  ...
}

Daftarkan bucket

Gunakan list_buckets() untuk mendaftar semua bucket dalam namespace. Secara default, fungsi ini mendaftar bucket dalam namespace pengguna saat ini.

>>> from huggingface_hub import list_buckets

# List your own buckets
>>> for bucket in list_buckets():
...     print(bucket.id, bucket.size, bucket.total_files)

# List buckets in an organization
>>> for bucket in list_buckets(namespace="huggingface"):
...     print(bucket.id)

Atau melalui CLI (hf buckets ls adalah singkatan dari hf buckets list):

# Table format (default)
>>> hf buckets list
ID                   PRIVATE      SIZE TOTAL_FILES CREATED_AT
-------------------- ------- --------- ----------- ----------
username/my-bucket                  32           5 2026-02-16
username/checkpoints         117609095         700 2026-02-13
username/logs                321757477        2000 2026-02-13

# Human-readable sizes
>>> hf buckets list -h
ID                   PRIVATE     SIZE TOTAL_FILES CREATED_AT
-------------------- ------- -------- ----------- ----------
username/my-bucket               32 B           5 2026-02-16
username/checkpoints         117.6 MB         700 2026-02-13
username/logs                321.8 MB        2000 2026-02-13

# List buckets in a specific namespace
>>> hf buckets ls huggingface

# Filter buckets by name
>>> hf buckets list --search "checkpoint"

Anda juga dapat menyaring bucket berdasarkan nama menggunakan search:

>>> for bucket in list_buckets(search="checkpoint"):
...     print(bucket.id)

Anda dapat menggunakan opsi --quiet dan --format json untuk mendapatkan format output yang berbeda. Hal ini sangat menarik jika Anda ingin mengalirkan output ke alat lain seperti grep atau jq.

# Quiet mode: prints one bucket ID per line
>>> hf buckets list --quiet
username/my-bucket
username/checkpoints
username/logs

# JSON format
>>> hf buckets list --format json
[
  {
    "id": "username/my-bucket",
    "private": false,
    "created_at": "2026-02-16T15:28:32+00:00",
    "size": 32,
    "total_files": 5
  },
  ...
]

Ubah visibilitas bucket

Gunakan update_bucket_settings() untuk mengubah bucket yang sudah ada antara privat dan publik.

>>> from huggingface_hub import update_bucket_settings

# Make a bucket private
>>> update_bucket_settings("username/my-bucket", private=True)

# Make it public again
>>> update_bucket_settings("username/my-bucket", private=False)

Atau melalui CLI:

# Make a bucket private
>>> hf buckets settings username/my-bucket --private
✓ Bucket settings updated
  bucket_id: username/my-bucket
  private: True

# Make it public again
>>> hf buckets settings username/my-bucket --public

Hapus bucket

Gunakan delete_bucket() untuk menghapus bucket. Operasi ini tidak dapat dibatalkan.

>>> from huggingface_hub import delete_bucket
>>> delete_bucket("username/my-bucket")

# Don't error if bucket doesn't exist
>>> delete_bucket("username/my-bucket", missing_ok=True)

Atau melalui CLI:

# Prompts for confirmation
>>> hf buckets delete username/my-bucket

# Skip confirmation
>>> hf buckets delete username/my-bucket --yes

# Don't error if bucket doesn't exist
>>> hf buckets delete username/my-bucket --yes --missing-ok

Hapus file

Gunakan batch_bucket_files() dengan parameter delete untuk menghapus file dari bucket:

>>> from huggingface_hub import batch_bucket_files

# Delete specific files
>>> batch_bucket_files("username/my-bucket", delete=["old-model.bin", "logs/debug.log"])

Atau melalui CLI dengan hf buckets rm (atau hf buckets remove):

# Remove a single file
>>> hf buckets rm username/my-bucket/old-model.bin

# Remove all files under a prefix (requires --recursive)
>>> hf buckets rm username/my-bucket/logs/ --recursive

# Remove only files matching a pattern across the entire bucket
>>> hf buckets rm username/my-bucket --recursive --include "*.tmp"

# Exclude specific files from removal
>>> hf buckets rm username/my-bucket/data/ --recursive --exclude "*.safetensors"

# Preview what would be deleted
>>> hf buckets rm username/my-bucket/checkpoints/ --recursive --dry-run

Pindahkan bucket

Gunakan move_bucket() untuk memindahkan atau mengganti nama bucket. Anda dapat mengganti nama dalam namespace yang sama atau mentransfer ke namespace lain (pengguna atau organisasi).

>>> from huggingface_hub import move_bucket

# Rename a bucket
>>> move_bucket(from_id="username/old-name", to_id="username/new-name")

# Transfer to an organization
>>> move_bucket(from_id="username/my-bucket", to_id="my-org/my-bucket")

Atau melalui CLI:

# Rename a bucket
>>> hf buckets move username/old-bucket username/new-bucket

# Transfer to an organization
>>> hf buckets move username/my-bucket my-org/my-bucket

# Using the hf://buckets/ format
>>> hf buckets move hf://buckets/username/old-bucket hf://buckets/username/new-bucket

Untuk informasi lebih lanjut tentang memindahkan repositori dan bucket, lihat dokumentasi Hub.

Jelajahi isi bucket

Daftar file

Gunakan list_bucket_tree() untuk mendaftar file dan direktori dalam bucket.

>>> from huggingface_hub import list_bucket_tree

# List all files
>>> for item in list_bucket_tree("username/my-bucket"):
...     print(item.path, item.size)
file.txt 5
big.bin 2048
sub/nested.txt 14
sub/deep/file.txt 4

# List top-level entries only
>>> for item in list_bucket_tree("username/my-bucket", recursive=False):
...     print(item.type, item.path)
file file.txt
file big.bin
directory sub

# Filter by prefix
>>> for item in list_bucket_tree("username/my-bucket", prefix="sub"):
...     print(item.path)

Atau melalui CLI, dengan dukungan untuk format tabel, yang dapat dibaca manusia, dan pohon ASCII. Secara default, CLI bersifat non-rekursif.

# Default table format (non-recursive, directories shown as entries)
>>> hf buckets list username/my-bucket
        2048  2026-01-15 10:30:00  big.bin
           5  2026-01-15 10:30:00  file.txt
              2026-01-15 10:30:00  sub/

# Recursive listing (all files, including nested)
>>> hf buckets list username/my-bucket -R
        2048  2026-01-15 10:30:00  big.bin
           5  2026-01-15 10:30:00  file.txt
          14  2026-01-15 10:30:00  sub/nested.txt
           4  2026-01-15 10:30:00  sub/deep/file.txt

# Human-readable sizes and short dates
>>> hf buckets list username/my-bucket -R -h
      2.0 KB         Jan 15 10:30  big.bin
         5 B         Jan 15 10:30  file.txt
        14 B         Jan 15 10:30  sub/nested.txt
         4 B         Jan 15 10:30  sub/deep/file.txt

# ASCII tree format
>>> hf buckets list username/my-bucket --tree -h -R
2.0 KB  Jan 15 10:30  ├── big.bin
   5 B  Jan 15 10:30  ├── file.txt
                      └── sub/
                          ├── deep/
   4 B  Jan 15 10:30  │       └── file.txt
  14 B  Jan 15 10:30  └── nested.txt

# Tree structure only (no sizes/dates)
>>> hf buckets list username/my-bucket --tree --quiet -R
├── big.bin
├── file.txt
└── sub/
    ├── deep/
    │   └── file.txt
    └── nested.txt

# Quiet mode: one path per line
>>> hf buckets list username/my-bucket -q
big.bin
file.txt
sub/

# Filter by prefix
>>> hf buckets list username/my-bucket/sub -R

Perintah hf buckets list menerima format pendek (username/my-bucket/sub) dan handle lengkap (hf://buckets/username/my-bucket/sub) sebagai argumen.

Listing sebuah bucket dengan HfFileSystem akan meng-cache isinya. Gunakan HfFileSystem(live_follow=True) agar daftar diperbarui saat file ditambahkan, diperbarui, dan dihapus di bucket oleh peer lain, lihat panduan filesystem.

Unggah file

Upload dengan Python

Gunakan batch_bucket_files() untuk mengunggah file ke bucket. Anda dapat mengunggah dari jalur file lokal atau dari byte mentah:

>>> from huggingface_hub import batch_bucket_files

# Upload from local file paths
>>> batch_bucket_files(
...     "username/my-bucket",
...     add=[
...         ("./model.safetensors", "models/model.safetensors"),
...         ("./config.json", "models/config.json"),
...     ],
... )

# Upload from raw bytes
>>> batch_bucket_files(
...     "username/my-bucket",
...     add=[
...         (b'{"key": "value"}', "config.json"),
...     ],
... )

Anda juga dapat menyalin file xet dari bucket atau repositori lain menggunakan parameter copy. Ini adalah operasi sisi server — tidak ada data yang diunduh atau diunggah ulang:

# Copy files by xet hash (source_repo_type, source_repo_id, xet_hash, destination)
>>> batch_bucket_files(
...     "username/my-bucket",
...     copy=[
...         ("bucket", "username/source-bucket", "<xethash_1>", "models/model.safetensors"),
...         ("model", "username/my-model", "<xethash_2>", "models/config.safetensors"),
...     ],
... )

Hash Xet dapat diambil menggunakan list_repo_tree.

Anda juga dapat menghapus file sambil mengunggah file lainnya.

# Upload and delete in one batch
>>> batch_bucket_files(
...     "username/my-bucket",
...     add=[("./new-model.safetensors", "model.safetensors")],
...     delete=["old-model.bin"],
... )

Panggilan ke batch_bucket_files() bersifat non-transaksional. Jika terjadi kesalahan selama proses, beberapa file mungkin sudah diunggah, disalin, atau dihapus sementara yang lain belum. Ketika server melaporkan bahwa beberapa operasi gagal, BucketBatchError akan dilempar dengan path yang gagal pada atribut failures-nya.

Unggah satu file dengan CLI

Gunakan hf buckets cp untuk mengunggah satu file:

hf buckets cp adalah alias untuk perintah terpadu hf cp (juga tersedia sebagai hf repos cp). Ketiga perintah ini identik, sehingga contoh hf buckets cp di bawah ini juga berfungsi dengan hf cp.

# Upload to bucket root (uses local filename as remote name)
>>> hf buckets cp ./config.json hf://buckets/username/my-bucket

# Upload to a subdirectory
>>> hf buckets cp ./data.csv hf://buckets/username/my-bucket/logs/

# Upload with a different remote filename
>>> hf buckets cp ./model.safetensors hf://buckets/username/my-bucket/v2/model.safetensors

Anda juga dapat mengalirkan hasil perintah langsung ke file baru menggunakan -:

# Upload from stdin
>>> echo "hello" | hf buckets cp - hf://buckets/username/my-bucket/hello.txt
>>> cat model.safetensors | hf buckets cp - hf://buckets/username/my-bucket/model.safetensors

Unggah direktori dengan CLI

Gunakan hf buckets sync untuk mengunggah seluruh direktori lokal ke bucket:

# Upload a local directory to a bucket
>>> hf buckets sync ./data hf://buckets/username/my-bucket

# Upload to a specific prefix in the bucket
>>> hf buckets sync ./data hf://buckets/username/my-bucket/train

Lihat bagian Sync directories di bawah ini untuk kumpulan lengkap opsi sinkronisasi.

Unduh file

Unduh dengan Python

Gunakan download_bucket_files() untuk mengunduh file dari bucket:

>>> from huggingface_hub import download_bucket_files

# Download specific files by path
>>> download_bucket_files(
...     "username/my-bucket",
...     files=[
...         ("models/model.safetensors", "./local/model.safetensors"),
...         ("config.json", "./local/config.json"),
...     ],
... )

Untuk performa yang lebih baik, Anda dapat meneruskan objek BucketFile yang diperoleh dari list_bucket_tree() alih-alih jalur string. Ini melewati langkah pengambilan metadata:

>>> from huggingface_hub import list_bucket_tree, download_bucket_files

# List and filter files, then download
>>> parquet_files = [
...     item for item in list_bucket_tree("username/my-bucket", recursive=True)
...     if item.type == "file" and item.path.endswith(".parquet")
... ]
>>> download_bucket_files(
...     "username/my-bucket",
...     files=[(f, f"./local/{f.path}") for f in parquet_files],
... )

Unduh satu file dengan CLI

Gunakan hf buckets cp untuk mengunduh satu file:

# Download to a specific file
>>> hf buckets cp hf://buckets/username/my-bucket/config.json ./config.json

# Download to a directory (uses original filename)
>>> hf buckets cp hf://buckets/username/my-bucket/config.json ./data/

# Download to current directory (omit destination)
>>> hf buckets cp hf://buckets/username/my-bucket/config.json

Anda juga dapat mengalirkan isi file langsung ke stdout menggunakan -:

# Download to stdout and pretty-print with jq
>>> hf buckets cp hf://buckets/username/my-bucket/config.json - | jq .

Unduh direktori dengan CLI

Gunakan hf buckets sync untuk mengunduh semua file dari bucket ke direktori lokal:

# Download bucket contents to a local directory
>>> hf buckets sync hf://buckets/username/my-bucket ./data

# Download only a specific prefix
>>> hf buckets sync hf://buckets/username/my-bucket/models ./local-models

Lihat bagian Sync directories di bawah ini untuk kumpulan lengkap opsi sinkronisasi.

Salin file ke Bucket

Gunakan copy_files() untuk menyalin file yang sudah di-hosting di Hub ke Bucket:

>>> from huggingface_hub import copy_files

# Bucket to bucket (same or different bucket)
>>> copy_files(
...     "hf://buckets/username/source-bucket/checkpoints/model.safetensors",
...     "hf://buckets/username/destination-bucket/archive/model.safetensors",
... )

# Repo to bucket
>>> copy_files(
...     "hf://datasets/username/my-dataset/processed/",
...     "hf://buckets/username/my-bucket/datasets/processed/",
... )

Hal yang sama tersedia dari CLI melalui perintah terpadu hf cp (juga dipaparkan sebagai hf buckets cp dan hf repos cp — ketiganya identik):

# Bucket to bucket
>>> hf cp hf://buckets/username/source-bucket/logs/ hf://buckets/username/destination-bucket/logs/

# Repo to bucket
>>> hf cp hf://username/my-model/config.json hf://buckets/username/my-bucket/models/config.json

Saat menyalin folder, / di akhir sumber menggunakan semantik gaya rsync — hanya isi folder yang disalin, tanpa menelusuri folder itu sendiri:

# Without trailing slash: "logs" dir is nested => destination/logs/...
>>> hf cp hf://buckets/username/source-bucket/logs hf://buckets/username/destination-bucket/

# With trailing slash: only contents of "logs" are copied => destination/...
>>> hf cp hf://buckets/username/source-bucket/logs/ hf://buckets/username/destination-bucket/

Catatan:

  • Salinan dari bucket ke repo belum didukung.
  • Salinan sisi server hanya berfungsi di dalam region penyimpanan yang sama.
  • File yang dilacak dengan Xet (di bucket atau repositori) disalin di sisi server berdasarkan hash — tidak ada data yang diunduh atau diunggah ulang.
  • Berkas teks kecil yang tidak dilacak dengan Xet pada sumber repo diunduh dan diunggah ulang ke bucket tujuan.
  • copy_files() juga dapat digunakan untuk salinan antar-repo. Lihat panduan repositori untuk detail lebih lanjut.

Sinkronkan direktori

Perintah hf buckets sync (dan padanan API-nya sync_bucket()) adalah cara paling ampuh untuk mentransfer file antara direktori lokal dan bucket. Perintah ini membandingkan sumber dan tujuan, lalu hanya mentransfer file yang telah berubah.

Sinkronisasi dasar

# Upload: local directory -> bucket
>>> hf buckets sync ./data hf://buckets/username/my-bucket

# Download: bucket -> local directory
>>> hf buckets sync hf://buckets/username/my-bucket ./data

hf sync adalah alias yang praktis untuk hf buckets sync. Kedua perintah ini identik.

>>> hf sync ./data hf://buckets/username/my-bucket

Atau melalui Python:

>>> from huggingface_hub import sync_bucket

# Upload: local directory -> bucket
>>> sync_bucket("./data", "hf://buckets/username/my-bucket")

# Download: bucket -> local directory
>>> sync_bucket("hf://buckets/username/my-bucket", "./data")

Hapus file yang tidak diperlukan

Secara default, sync hanya menambahkan atau memperbarui file. Gunakan --delete (atau delete=True di Python) untuk juga menghapus file di tujuan yang tidak ada di sumber:

# Upload and remove remote files not present locally
>>> hf buckets sync ./data hf://buckets/username/my-bucket --delete

# Download and remove local files not present in bucket
>>> hf buckets sync hf://buckets/username/my-bucket ./data --delete

Atau melalui Python:

>>> sync_bucket("./data", "hf://buckets/username/my-bucket", delete=True)
>>> sync_bucket("hf://buckets/username/my-bucket", "./data", delete=True)

Penyaringan

Anda dapat mengontrol file mana yang disinkronkan menggunakan pola include/exclude:

# Only sync .txt files
>>> hf buckets sync ./data hf://buckets/username/my-bucket --include "*.txt"

# Exclude log files
>>> hf buckets sync ./data hf://buckets/username/my-bucket --exclude "*.log"

# Combine include and exclude
>>> hf buckets sync ./data hf://buckets/username/my-bucket --include "*.safetensors" --exclude "*.tmp"

Atau melalui Python:

# Only sync .txt files
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", include=["*.txt"])

# Exclude log files
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", exclude=["*.log"])

# Combine include and exclude
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", include=["*.safetensors"], exclude=["*.tmp"])

Untuk penyaringan yang lebih kompleks, gunakan file filter dengan --filter-from (atau filter_from di Python):

>>> hf buckets sync ./data hf://buckets/username/my-bucket --filter-from filters.txt

File filter menggunakan prefiks + (termasuk) dan - (dikecualikan). Baris yang diawali dengan # adalah komentar. Aturan dievaluasi secara berurutan (aturan yang cocok pertama kali menang):

# filters.txt
- *.log
- *.tmp
+ *.safetensors
+ *.json

Mode perbandingan

Secara default, sync membandingkan file menggunakan ukuran dan waktu modifikasi. Anda dapat menyesuaikan perilaku ini:

# Only compare sizes (ignore modification times)
>>> hf buckets sync ./data hf://buckets/username/my-bucket --ignore-times

# Only compare modification times (ignore sizes)
>>> hf buckets sync ./data hf://buckets/username/my-bucket --ignore-sizes

# Only update files that already exist on the receiver (skip new files)
>>> hf buckets sync ./data hf://buckets/username/my-bucket --existing

# Only create new files (skip files that already exist on the receiver)
>>> hf buckets sync ./data hf://buckets/username/my-bucket --ignore-existing

Atau melalui Python:

>>> sync_bucket("./data", "hf://buckets/username/my-bucket", ignore_times=True)
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", ignore_sizes=True)
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", existing=True)
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", ignore_existing=True)

Rencanakan dan terapkan

Untuk operasi kritis, Anda dapat meninjau rencana sinkronisasi sebelum mengeksekusinya:

# Step 1: Generate a plan file (nothing is transferred)
>>> hf buckets sync ./data hf://buckets/username/my-bucket --plan sync-plan.jsonl
Sync plan: ./data -> hf://buckets/username/my-bucket
  Uploads: 3
  Downloads: 0
  Deletes: 0
  Skips: 1
Plan saved to: sync-plan.jsonl

# Step 2: Review the plan file (JSONL format)
>>> cat sync-plan.jsonl

# Step 3: Apply the plan
>>> hf buckets sync --apply sync-plan.jsonl

Atau melalui Python:

# Step 1: Generate a plan file (nothing is transferred)
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", plan="sync-plan.jsonl")

# Step 2: Review the plan file (JSONL format), then apply
>>> sync_bucket(apply="sync-plan.jsonl")

File rencana adalah file JSONL dengan baris header diikuti oleh satu baris per operasi. Setiap operasi mencakup aksi (upload, download, delete, atau skip), jalur file, dan alasan untuk aksi tersebut. Anda dapat mengedit file ini secara manual sebelum menerapkannya, tetapi harap berhati-hati dengan sintaksnya.

Uji coba

Gunakan --dry-run (atau dry_run=True di Python) untuk mendapatkan rencana sinkronisasi tanpa mengeksekusi apa pun:

# Preview what would be synced
>>> hf buckets sync ./data hf://buckets/username/my-bucket --dry-run | jq '.action'

Atau melalui Python:

>>> plan = sync_bucket("./data", "hf://buckets/username/my-bucket", dry_run=True)
>>> plan.summary()
{'uploads': 3, 'downloads': 0, 'deletes': 0, 'skips': 1, 'total_size': 4096}

--dry-run menghasilkan format JSONL yang sama dengan --plan tetapi mencetaknya ke stdout alih-alih menyimpan ke file. Hanya konten JSONL yang dicetak, sehingga aman untuk di-pipe.

Mode verbose dan quiet

# Show per-file operations
>>> hf buckets sync ./data hf://buckets/username/my-bucket --verbose

# Suppress all output
>>> hf buckets sync ./data hf://buckets/username/my-bucket --quiet

Atau melalui Python:

>>> sync_bucket("./data", "hf://buckets/username/my-bucket", verbose=True)
>>> sync_bucket("./data", "hf://buckets/username/my-bucket", quiet=True)

Lanjutan

Untuk kasus penggunaan tingkat yang lebih rendah, metode-metode berikut juga tersedia:

  • get_bucket_paths_info(): Mengambil informasi tentang path tertentu dalam bucket dalam satu permintaan batch. Berguna ketika Anda tahu persis file mana yang membutuhkan metadata.
>>> from huggingface_hub import get_bucket_paths_info
>>> for info in get_bucket_paths_info("username/my-bucket", ["file.txt", "models/model.safetensors"]):
...     print(info.path, info.size, info.xet_hash)
>>> from huggingface_hub import get_bucket_file_metadata
>>> metadata = get_bucket_file_metadata("username/my-bucket", "models/model.safetensors")
>>> metadata.size
42000
Update on GitHub