Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 83 additions & 4 deletions docs/source/en/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,69 @@ To view the diff of a pull request directly in your terminal, use `hf discussion
>>> hf discussions diff username/my-model 5
```

## hf collections

Use `hf collections` to browse, create, update, and delete collections on the Hugging Face Hub. Collections let you group related models, datasets, Spaces, and papers together.

### List collections

```bash
# List your collections
>>> hf collections ls

# List collections for a specific owner
>>> hf collections ls --owner nvidia

# Filter by item
>>> hf collections ls --item models/teknium/OpenHermes-2.5-Mistral-7B --limit 10
```

### Get collection info

```bash
>>> hf collections info username/my-collection-slug
```

### Create a collection

```bash
>>> hf collections create "My Models"
>>> hf collections create "My Models" --description "A collection of my favorite models" --private
>>> hf collections create "Org Collection" --namespace my-org
```

### Update a collection

```bash
>>> hf collections update username/my-collection --title "New Title"
>>> hf collections update username/my-collection --description "Updated description"
>>> hf collections update username/my-collection --private --theme green
```

### Add, update, and delete items

```bash
# Add an item (type is one of: model, dataset, space, paper)
>>> hf collections add-item username/my-collection moonshotai/kimi-k2 model
>>> hf collections add-item username/my-collection Qwen/DeepPlanning dataset --note "Useful dataset"

# Update an item's note or position
>>> hf collections update-item username/my-collection ITEM_OBJECT_ID --note "Updated note"
>>> hf collections update-item username/my-collection ITEM_OBJECT_ID --position 0

# Delete an item
>>> hf collections delete-item username/my-collection ITEM_OBJECT_ID
```

### Delete a collection

```bash
>>> hf collections delete username/my-collection
>>> hf collections delete username/my-collection --missing-ok
```

Use `--format json` for machine-readable output. For more details, see the [Collections guide](./collections).

## hf repos

`hf repos` lets you create, delete, move repositories, update their settings, and delete files on the Hugging Face Hub. It also includes subcommands to manage branches and tags.
Expand All @@ -1053,6 +1116,22 @@ Create a private dataset or a Space:

Use `--exist-ok` if the repo may already exist, and `--resource-group-id` to target an Enterprise resource group.

### Duplicate a repo

```bash
>>> hf repos duplicate openai/gdpval --type dataset
Successfully duplicated openai/gdpval to Wauplin/gdpval on the Hub.
```

Duplicate a Space with hardware, secrets, and volumes:

```bash
>>> hf repos duplicate multimodalart/dreambooth-training my-dreambooth --type space --flavor l4x4 --secrets HF_TOKEN --private
>>> hf repos duplicate org/my-space my-space --type space -v hf://gpt2:/models -v hf://buckets/org/b:/data
```

Use `--exist-ok` to skip if the destination repo already exists.

### Delete a repo

```bash
Expand Down Expand Up @@ -1330,10 +1409,10 @@ Tag v1.0 created on bigcode/the-stack

### List tags

To list all tags for a repository, use the `-l` or `--list` option:
To list all tags for a repository, use the `list` (or `ls`) subcommand:

```bash
>>> hf repos tag create Wauplin/gradio-space-ci -l --repo-type space
>>> hf repos tag list Wauplin/gradio-space-ci --repo-type space
Tags for space Wauplin/gradio-space-ci:
0.2.2
0.2.1
Expand All @@ -1345,10 +1424,10 @@ Tags for space Wauplin/gradio-space-ci:

### Delete a tag

To delete a tag, use the `-d` or `--delete` option:
To delete a tag, use the `delete` subcommand:

```bash
>>> hf repos tag create -d Wauplin/my-cool-model v1.0
>>> hf repos tag delete Wauplin/my-cool-model v1.0
You are about to delete tag v1.0 on model Wauplin/my-cool-model
Proceed? [Y/n] y
Tag v1.0 deleted on Wauplin/my-cool-model
Expand Down
60 changes: 60 additions & 0 deletions docs/source/en/guides/collections.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,27 @@ It will return a [`Collection`] object with the high-level metadata (title, desc
'https://huggingface.co/collections/owner/iccv-2023-15e23b46cb98efca45'
```

## Update a collection

Once a collection is created, you can update its metadata using [`update_collection_metadata`]. You can change the title, description, visibility, position, and theme:

```py
>>> from huggingface_hub import update_collection_metadata
>>> collection = update_collection_metadata(
... collection_slug="username/iccv-2023-64f9a55bb3115b4f513ec026",
... title="ICCV Oct. 2023",
... description="Portfolio of models, datasets, papers and demos I presented at ICCV Oct. 2023",
... private=False,
... theme="pink",
... )
>>> collection.slug
"username/iccv-oct-2023-64f9a55bb3115b4f513ec026"
# ^collection slug got updated but not the trailing ID
```

> [!TIP]
> Changing the title will update the slug of the collection, but the trailing ID will remain the same. Your existing links will keep working since the Hub resolves collections by the trailing ID.

## Manage items in a collection

Now that we have a [`Collection`], we want to add items to it and organize them.
Expand Down Expand Up @@ -219,3 +240,42 @@ A collection can be deleted using [`delete_collection`].
>>> from huggingface_hub import delete_collection
>>> collection = delete_collection("username/useless-collection-64f9a55bb3115b4f513ec026", missing_ok=True)
```

## Manage collections from the CLI

All of the above operations are also available from the `hf` command-line interface:

```bash
# List collections
>>> hf collections ls
>>> hf collections ls --owner nvidia
>>> hf collections ls --item models/teknium/OpenHermes-2.5-Mistral-7B --limit 10

# Get info about a collection
>>> hf collections info username/my-collection-slug

# Create a collection
>>> hf collections create "My Models"
>>> hf collections create "My Models" --description "A collection of my favorite models" --private

# Update a collection's metadata
>>> hf collections update username/my-collection --title "New Title"
>>> hf collections update username/my-collection --private --theme green

# Add an item to a collection
>>> hf collections add-item username/my-collection moonshotai/kimi-k2 model
>>> hf collections add-item username/my-collection Qwen/DeepPlanning dataset --note "Useful dataset"

# Update an item's note or position
>>> hf collections update-item username/my-collection ITEM_OBJECT_ID --note "Updated note"
>>> hf collections update-item username/my-collection ITEM_OBJECT_ID --position 0

# Delete an item from a collection
>>> hf collections delete-item username/my-collection ITEM_OBJECT_ID

# Delete a collection
>>> hf collections delete username/my-collection
>>> hf collections delete username/my-collection --missing-ok
```

Use `--format json` for machine-readable output. For the full list of options, run `hf collections <command> --help`. For more details, see the [CLI guide](./cli#hf-collections).
Loading
Loading