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

Les buckets offrent un stockage d’objets de type S3 sur Hugging Face, propulsé par le backend de stockage Xet. Contrairement aux dépôts (basés sur git et qui suivent l’historique des fichiers), les buckets sont des conteneurs de stockage d’objets distants conçus pour les fichiers de grande taille avec déduplication adressable par contenu. Ils sont conçus pour les cas d’usage nécessitant un stockage simple, rapide et mutable, tel que le stockage de points de contrôle d’entraînement, de journaux, d’artefacts intermédiaires ou de toute grande collection de fichiers qui n’a pas besoin de contrôle de version.

Vous pouvez interagir avec les buckets à l’aide de l’API Python (HfApi) ou de l’interface en ligne de commande (hf buckets). Dans ce guide, nous passons en revue toutes les opérations disponibles.

Toutes les commandes CLI sont disponibles sous hf buckets <command>. Exécutez hf buckets --help pour en savoir plus.

Créer et gérer des buckets

Créer un bucket

Créez un bucket avec create_bucket(). Vous devez fournir un nom de bucket. Si vous ne spécifiez pas d’espace de noms, le bucket est créé sous votre nom d’utilisateur.

>>> 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(...)

Ou via l'interface en ligne de commande :

>>> 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

Vous pouvez également spécifier le format complet namespace/bucket_name pour créer un bucket sous une organisation :

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

Ou via l'interface en ligne de commande :

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

Obtenir les informations du bucket

Utilisez bucket_info() pour obtenir les métadonnées d’un bucket, y compris sa visibilité, sa taille totale, le nombre de fichiers et sa date de création.

>>> 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
)

Ou via l'interface en ligne de commande :

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

Lister les buckets

Utilisez list_buckets() pour lister tous les buckets d’un espace de noms. Par défaut, il liste les buckets de l’espace de noms de l’utilisateur actuel.

>>> 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)

Ou via l’interface en ligne de commande (hf buckets ls est un raccourci pour 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"

Vous pouvez également filtrer les buckets par nom à l’aide de search :

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

Vous pouvez utiliser les options --quiet et --format json pour obtenir un format de sortie différent. C'est particulièrement intéressant si vous souhaitez rediriger la sortie vers un autre outil comme grep ou 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
  },
  ...
]

Changer la visibilité du bucket

Utilisez update_bucket_settings() pour passer un bucket existant en mode privé ou public.

>>> 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)

Ou via l'interface en ligne de commande :

# 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

Supprimer un bucket

Utilisez delete_bucket() pour supprimer un bucket. Cette opération est irréversible.

>>> 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)

Ou via l'interface en ligne de commande :

# 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

Supprimer des fichiers

Utilisez batch_bucket_files() avec le paramètre delete pour supprimer des fichiers d’un bucket :

>>> from huggingface_hub import batch_bucket_files

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

Ou via l’interface en ligne de commande avec hf buckets rm (ou 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

Déplacer un bucket

Utilisez move_bucket() pour déplacer ou renommer un bucket. Vous pouvez renommer dans le même espace de noms ou transférer vers un autre espace de noms (utilisateur ou organisation).

>>> 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")

Ou via l'interface en ligne de commande :

# 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

Pour plus d'informations sur le déplacement des dépôts et des buckets, consultez la documentation du Hub.

Parcourir le contenu du bucket

Lister les fichiers

Utilisez list_bucket_tree() pour lister les fichiers et les répertoires d’un 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)

Ou via l’interface en ligne de commande (CLI), avec prise en charge des formats tableau, lisible par un humain et arbre ASCII. Par défaut, la CLI est non récursive.

# 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

La commande hf buckets list accepte à la fois le format court (username/my-bucket/sub) et le handle complet (hf://buckets/username/my-bucket/sub) en tant qu'arguments.

L’affichage d’un bucket avec HfFileSystem met son contenu en cache. Passez HfFileSystem(live_follow=True) pour que les listes soient actualisées à mesure que des fichiers sont ajoutés, mis à jour ou supprimés dans le bucket par d’autres pairs, voir le guide du système de fichiers.

Téléverser des fichiers

Téléchargement avec Python

Utilisez batch_bucket_files() pour téléverser des fichiers dans un bucket. Vous pouvez téléverser depuis des chemins de fichiers locaux ou depuis des octets bruts :

>>> 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"),
...     ],
... )

Vous pouvez également copier des fichiers xet depuis un autre bucket ou dépôt à l’aide du paramètre copy. Il s’agit d’une opération côté serveur — aucune donnée n’est téléchargée ni réenvoyée :

# 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"),
...     ],
... )

Les hachages Xet peuvent être récupérés à l'aide de list_repo_tree.

Vous pouvez également supprimer des fichiers pendant que d'autres sont en cours de téléversement.

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

Les appels à batch_bucket_files() ne sont pas transactionnels. En cas d’erreur pendant le processus, certains fichiers peuvent avoir été téléversés, copiés ou supprimés, tandis que d’autres non. Lorsque le serveur signale que certaines opérations ont échoué, une BucketBatchError est levée avec les chemins en échec dans son attribut failures.

Téléverser un fichier unique avec l'interface en ligne de commande

Utilisez hf buckets cp pour téléverser un fichier unique :

hf buckets cp est un alias de la commande unifiée hf cp (également exposée sous le nom hf repos cp). Les trois sont identiques, ainsi tout exemple de hf buckets cp ci-dessous fonctionne également avec 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

Vous pouvez également rediriger le résultat d'une commande directement vers un nouveau fichier à l'aide de - :

# 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

Téléverser un répertoire avec l'interface en ligne de commande

Utilisez hf buckets sync pour téléverser un répertoire local entier vers un 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

Consultez la section Synchroniser les répertoires ci-dessous pour l’ensemble des options de synchronisation.

Télécharger les fichiers

Télécharger avec Python

Utilisez download_bucket_files() pour télécharger des fichiers depuis un 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"),
...     ],
... )

Pour de meilleures performances, vous pouvez passer des objets BucketFile obtenus à partir de list_bucket_tree() au lieu de chemins en chaîne. Cela évite l'étape de récupération des métadonnées :

>>> 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],
... )

Télécharger un fichier unique avec l'interface en ligne de commande

Utilisez hf buckets cp pour télécharger un fichier unique :

# 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

Vous pouvez également acheminer le contenu d'un fichier directement vers stdout en utilisant - :

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

Télécharger un répertoire avec l'interface en ligne de commande

Utilisez hf buckets sync pour télécharger tous les fichiers d’un bucket vers un répertoire local :

# 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

Consultez la section Synchroniser les répertoires ci-dessous pour l’ensemble des options de synchronisation.

Copier des fichiers vers le Bucket

Utilisez copy_files() pour copier des fichiers déjà hébergés sur le Hub vers un 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/",
... )

Le même est disponible depuis l’interface en ligne de commande via la commande unifiée hf cp (également exposée sous la forme hf buckets cp et hf repos cp — les trois sont identiques) :

# 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

Lors de la copie de dossiers, un / final sur la source utilise des sémantiques de type rsync — seuls les contenus du dossier sont copiés, sans imbriquer le dossier lui-même :

# 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/

Remarques :

  • La copie d'un bucket vers un dépôt n'est pas encore prise en charge.
  • Les copies côté serveur ne fonctionnent que dans la même zone de stockage.
  • Les fichiers suivis par Xet (dans des buckets ou des dépôts) sont copiés côté serveur par hachage — aucune donnée n'est téléchargée ni réenvoyée.
  • Les petits fichiers texte non suivis par Xet dans les sources du dépôt sont téléchargés puis réenvoyés vers le bucket de destination.
  • copy_files() peut également être utilisé pour des copies de dépôt à dépôt. Consultez le guide des dépôts pour plus de détails.

Synchroniser les répertoires

La commande hf buckets sync (et son équivalent API sync_bucket()) est la méthode la plus puissante pour transférer des fichiers entre un répertoire local et un bucket. Elle compare la source et la destination, et ne transfère que les fichiers qui ont changé.

Synchronisation de base

# 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 est un alias pratique pour hf buckets sync. Les deux commandes sont identiques.

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

Ou via 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")

Supprimer les fichiers inutiles

Par défaut, sync n’ajoute ou ne met à jour que des fichiers. Utilisez --delete (ou delete=True en Python) pour supprimer également les fichiers de la destination qui n’existent pas dans la source :

# 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

Ou via Python :

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

Filtrage

Vous pouvez contrôler les fichiers synchronisés à l'aide de motifs d'inclusion/exclusion :

# 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"

Ou via 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"])

Pour un filtrage plus complexe, utilisez un fichier de filtre avec --filter-from (ou filter_from en Python) :

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

Le fichier de filtre utilise les préfixes + (inclure) et - (exclure). Les lignes commençant par # sont des commentaires. Les règles sont évaluées dans l'ordre (la première règle correspondante l'emporte) :

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

Modes de comparaison

Par défaut, sync compare les fichiers en utilisant à la fois la taille et l'heure de modification. Vous pouvez personnaliser ce comportement :

# 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

Ou via 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)

Planifier et appliquer

Pour les opérations critiques, vous pouvez examiner le plan de synchronisation avant de l’exécuter :

# 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

Ou via 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")

Le fichier de plan est un fichier JSONL avec une ligne d’en-tête suivie d’une ligne par opération. Chaque opération inclut l’action (upload, download, delete ou skip), le chemin du fichier et la raison de l’action. Vous pouvez modifier ce fichier manuellement avant de l’appliquer, mais faites attention à la syntaxe.

Essai à blanc

Utilisez --dry-run (ou dry_run=True en Python) pour obtenir le plan de synchronisation sans rien exécuter :

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

Ou via 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 affiche le même format JSONL que --plan, mais l’imprime sur la sortie standard au lieu de l’enregistrer dans un fichier. Seuls les contenus JSONL sont imprimés, ce qui permet de les rediriger en toute sécurité.

Modes détaillé et silencieux

# 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

Ou via Python :

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

Avancé

Pour les cas d'utilisation de bas niveau, les méthodes suivantes sont également disponibles :

  • get_bucket_paths_info() : Récupère des informations sur des chemins spécifiques dans un bucket via une seule requête par lot. Utile lorsque vous savez exactement pour quels fichiers vous avez besoin de métadonnées.
>>> 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