source
stringclasses
40 values
url
stringlengths
53
184
file_type
stringclasses
1 value
chunk
stringlengths
3
512
chunk_id
stringlengths
5
8
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#add-items
.md
... ) >>> add_collection_item(collection.slug, item_id="lmsys/lmsys-chat-1m", item_type="dataset") >>> add_collection_item(collection.slug, item_id="warp-ai/wuerstchen", item_type="space") # same item_id, different item_type ``` If an item already exists in a collection (same `item_id`/`item_type` pair), an HTTP 409 error will be raised. You can choose to ignore this error by setting `exists_ok=True`.
27_6_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#add-a-note-to-an-existing-item
.md
You can modify an existing item to add or modify the note attached to it using [`update_collection_item`]. Let's reuse the example above: ```py >>> from huggingface_hub import get_collection, update_collection_item # Fetch collection with newly added items >>> collection_slug = "osanseviero/os-week-highlights-sept-18-24-650bfed7f795a59f491afb80" >>> collection = get_collection(collection_slug)
27_7_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#add-a-note-to-an-existing-item
.md
# Add note the `lmsys-chat-1m` dataset >>> update_collection_item( ... collection_slug=collection_slug, ... item_object_id=collection.items[2].item_object_id, ... note="This dataset contains one million real-world conversations with 25 state-of-the-art LLMs.", ... ) ```
27_7_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#reorder-items
.md
Items in a collection are ordered. The order is determined by the `position` attribute of each item. By default, items are ordered by appending new items at the end of the collection. You can update the order using [`update_collection_item`] the same way you would add a note. Let's reuse our example above: ```py >>> from huggingface_hub import get_collection, update_collection_item
27_8_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#reorder-items
.md
# Fetch collection >>> collection_slug = "osanseviero/os-week-highlights-sept-18-24-650bfed7f795a59f491afb80" >>> collection = get_collection(collection_slug) # Reorder to place the two `Wuerstchen` items together >>> update_collection_item( ... collection_slug=collection_slug, ... item_object_id=collection.items[3].item_object_id, ... position=2, ... ) ```
27_8_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#remove-items
.md
Finally, you can also remove an item using [`delete_collection_item`]. ```py >>> from huggingface_hub import get_collection, update_collection_item # Fetch collection >>> collection_slug = "osanseviero/os-week-highlights-sept-18-24-650bfed7f795a59f491afb80" >>> collection = get_collection(collection_slug) # Remove `coqui/xtts` Space from the list >>> delete_collection_item(collection_slug=collection_slug, item_object_id=collection.items[0].item_object_id) ```
27_9_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/collections.md
https://huggingface.co/docs/huggingface_hub/en/guides/collections/#delete-collection
.md
A collection can be deleted using [`delete_collection`]. <Tip warning={true}> This is a non-revertible action. A deleted collection cannot be restored. </Tip> ```py >>> from huggingface_hub import delete_collection >>> collection = delete_collection("username/useless-collection-64f9a55bb3115b4f513ec026", missing_ok=True) ```
27_10_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/
.md
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
28_0_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#command-line-interface-cli
.md
The `huggingface_hub` Python package comes with a built-in CLI called `huggingface-cli`. This tool allows you to interact with the Hugging Face Hub directly from a terminal. For example, you can login to your account, create a repository, upload and download files, etc. It also comes with handy features to configure your machine or manage your cache. In this guide, we will have a look at the main features of the CLI and how to use them.
28_1_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#getting-started
.md
First of all, let's install the CLI: ``` >>> pip install -U "huggingface_hub[cli]" ``` <Tip> In the snippet above, we also installed the `[cli]` extra dependencies to make the user experience better, especially when using the `delete-cache` command. </Tip> Once installed, you can check that the CLI is correctly setup: ``` >>> huggingface-cli --help usage: huggingface-cli <command> [<args>]
28_2_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#getting-started
.md
positional arguments: {env,login,whoami,logout,repo,upload,download,lfs-enable-largefiles,lfs-multipart-upload,scan-cache,delete-cache,tag} huggingface-cli command helpers env Print information about the environment. login Log in using a token from huggingface.co/settings/tokens whoami Find out which huggingface.co account you are logged in as. logout Log out repo {create} Commands to interact with your huggingface.co repos.
28_2_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#getting-started
.md
logout Log out repo {create} Commands to interact with your huggingface.co repos. upload Upload a file or a folder to a repo on the Hub download Download files from the Hub lfs-enable-largefiles Configure your repository to enable upload of files > 5GB. scan-cache Scan cache directory. delete-cache Delete revisions from the cache directory. tag (create, list, delete) tags for a repo in the hub
28_2_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#getting-started
.md
options: -h, --help show this help message and exit ``` If the CLI is correctly installed, you should see a list of all the options available in the CLI. If you get an error message such as `command not found: huggingface-cli`, please refer to the [Installation](../installation) guide. <Tip>
28_2_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#getting-started
.md
<Tip> The `--help` option is very convenient for getting more details about a command. You can use it anytime to list all available options and their details. For example, `huggingface-cli upload --help` provides more information on how to upload files using the CLI. </Tip>
28_2_4
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#using-pkgx
.md
[Pkgx](https://pkgx.sh) is a blazingly fast cross platform package manager that runs anything. You can install huggingface-cli using pkgx as follows: ```bash >>> pkgx install huggingface-cli ``` Or you can run huggingface-cli directly: ```bash >>> pkgx huggingface-cli --help ``` Check out the pkgx huggingface page [here](https://pkgx.dev/pkgs/huggingface.co/) for more details.
28_3_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#using-homebrew
.md
You can also install the CLI using [Homebrew](https://brew.sh/): ```bash >>> brew install huggingface-cli ``` Check out the Homebrew huggingface page [here](https://formulae.brew.sh/formula/huggingface-cli) for more details.
28_4_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
In many cases, you must be logged in to a Hugging Face account to interact with the Hub (download private repos, upload files, create PRs, etc.). To do so, you need a [User Access Token](https://huggingface.co/docs/hub/security-tokens) from your [Settings page](https://huggingface.co/settings/tokens). The User Access Token is used to authenticate your identity to the Hub. Make sure to set a token with write access if you want to upload or modify content.
28_5_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
Once you have your token, run the following command in your terminal: ```bash >>> huggingface-cli login ``` This command will prompt you for a token. Copy-paste yours and press *Enter*. Then, you'll be asked if the token should also be saved as a git credential. Press *Enter* again (default to yes) if you plan to use `git` locally. Finally, it will call the Hub to check that your token is valid and save it locally. ```
28_5_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
``` _| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_| _| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|
28_5_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _| _| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|
28_5_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
To log in, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens . Enter your token (input will not be visible): Add token as git credential? (Y/n) Token is valid (permission: write). Your token has been saved in your configured git credential helpers (store). Your token has been saved to /home/wauplin/.cache/huggingface/token Login successful ```
28_5_4
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
Your token has been saved to /home/wauplin/.cache/huggingface/token Login successful ``` Alternatively, if you want to log-in without being prompted, you can pass the token directly from the command line. To be more secure, we recommend passing your token as an environment variable to avoid pasting it in your command history. ```bash # Or using an environment variable >>> huggingface-cli login --token $HF_TOKEN --add-to-git-credential Token is valid (permission: write).
28_5_5
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-login
.md
>>> huggingface-cli login --token $HF_TOKEN --add-to-git-credential Token is valid (permission: write). The token `token_name` has been saved to /home/wauplin/.cache/huggingface/stored_tokens Your token has been saved in your configured git credential helpers (store). Your token has been saved to /home/wauplin/.cache/huggingface/token Login successful The current active token is: `token_name` ``` For more details about authentication, check out [this section](../quick-start#authentication).
28_5_6
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-whoami
.md
If you want to know if you are logged in, you can use `huggingface-cli whoami`. This command doesn't have any options and simply prints your username and the organizations you are a part of on the Hub: ```bash huggingface-cli whoami Wauplin orgs: huggingface,eu-test,OAuthTesters,hf-accelerate,HFSmolCluster ``` If you are not logged in, an error message will be printed.
28_6_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-logout
.md
This command logs you out. In practice, it will delete all tokens stored on your machine. If you want to remove a specific token, you can specify the token name as an argument. This command will not log you out if you are logged in using the `HF_TOKEN` environment variable (see [reference](../package_reference/environment_variables#hftoken)). If that is the case, you must unset the environment variable in your machine configuration.
28_7_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-download
.md
Use the `huggingface-cli download` command to download files from the Hub directly. Internally, it uses the same [`hf_hub_download`] and [`snapshot_download`] helpers described in the [Download](./download) guide and prints the returned path to the terminal. In the examples below, we will walk through the most common use cases. For a full list of available options, you can run: ```bash huggingface-cli download --help ```
28_8_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-a-single-file
.md
To download a single file from a repo, simply provide the repo_id and filename as follow: ```bash >>> huggingface-cli download gpt2 config.json downloading https://huggingface.co/gpt2/resolve/main/config.json to /home/wauplin/.cache/huggingface/hub/tmpwrq8dm5o (…)ingface.co/gpt2/resolve/main/config.json: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 665/665 [00:00<00:00, 2.49MB/s] /home/wauplin/.cache/huggingface/hub/models--gpt2/snapshots/11c5a3d5811f50298f278a704980280950aedb10/config.json ```
28_9_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-a-single-file
.md
/home/wauplin/.cache/huggingface/hub/models--gpt2/snapshots/11c5a3d5811f50298f278a704980280950aedb10/config.json ``` The command will always print on the last line the path to the file on your local machine.
28_9_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-an-entire-repository
.md
In some cases, you just want to download all the files from a repository. This can be done by just specifying the repo id: ```bash >>> huggingface-cli download HuggingFaceH4/zephyr-7b-beta Fetching 23 files: 0%| | 0/23 [00:00<?, ?it/s] ... ... /home/wauplin/.cache/huggingface/hub/models--HuggingFaceH4--zephyr-7b-beta/snapshots/3bac358730f8806e5c3dc7c7e19eb36e045bf720 ```
28_10_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-multiple-files
.md
You can also download a subset of the files from a repository with a single command. This can be done in two ways. If you already have a precise list of the files you want to download, you can simply provide them sequentially: ```bash >>> huggingface-cli download gpt2 config.json model.safetensors Fetching 2 files: 0%| | 0/2 [00:00<?, ?it/s]
28_11_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-multiple-files
.md
Fetching 2 files: 0%| | 0/2 [00:00<?, ?it/s] downloading https://huggingface.co/gpt2/resolve/11c5a3d5811f50298f278a704980280950aedb10/model.safetensors to /home/wauplin/.cache/huggingface/hub/tmpdachpl3o (…)8f278a7049802950aedb10/model.safetensors: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8.09k/8.09k [00:00<00:00, 40.5MB/s]
28_11_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-multiple-files
.md
(…)8f278a7049802950aedb10/model.safetensors: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8.09k/8.09k [00:00<00:00, 40.5MB/s] Fetching 2 files: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2/2 [00:00<00:00, 3.76it/s] /home/wauplin/.cache/huggingface/hub/models--gpt2/snapshots/11c5a3d5811f50298f278a704980280950aedb10 ```
28_11_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-multiple-files
.md
/home/wauplin/.cache/huggingface/hub/models--gpt2/snapshots/11c5a3d5811f50298f278a704980280950aedb10 ``` The other approach is to provide patterns to filter which files you want to download using `--include` and `--exclude`. For example, if you want to download all safetensors files from [stabilityai/stable-diffusion-xl-base-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0), except the files in FP16 precision: ```bash
28_11_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-multiple-files
.md
```bash >>> huggingface-cli download stabilityai/stable-diffusion-xl-base-1.0 --include "*.safetensors" --exclude "*.fp16.*"* Fetching 8 files: 0%| | 0/8 [00:00<?, ?it/s] ... ... Fetching 8 files: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8/8 (...) /home/wauplin/.cache/huggingface/hub/models--stabilityai--stable-diffusion-xl-base-1.0/snapshots/462165984030d82259a11f4367a4eed129e94a7b ```
28_11_4
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-a-dataset-or-a-space
.md
The examples above show how to download from a model repository. To download a dataset or a Space, use the `--repo-type` option: ```bash # https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k >>> huggingface-cli download HuggingFaceH4/ultrachat_200k --repo-type dataset # https://huggingface.co/spaces/HuggingFaceH4/zephyr-chat >>> huggingface-cli download HuggingFaceH4/zephyr-chat --repo-type space ... ```
28_12_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-a-specific-revision
.md
The examples above show how to download from the latest commit on the main branch. To download from a specific revision (commit hash, branch name or tag), use the `--revision` option: ```bash >>> huggingface-cli download bigcode/the-stack --repo-type dataset --revision v1.1 ... ```
28_13_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-to-a-local-folder
.md
The recommended (and default) way to download files from the Hub is to use the cache-system. However, in some cases you want to download files and move them to a specific folder. This is useful to get a workflow closer to what git commands offer. You can do that using the `--local-dir` option.
28_14_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-to-a-local-folder
.md
A `.cache/huggingface/` folder is created at the root of your local directory containing metadata about the downloaded files. This prevents re-downloading files if they're already up-to-date. If the metadata has changed, then the new file version is downloaded. This makes the `local-dir` optimized for pulling only the latest changes. <Tip> For more details on how downloading to a local file works, check out the [download](./download.md#download-files-to-a-local-folder) guide. </Tip> ```bash
28_14_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-to-a-local-folder
.md
</Tip> ```bash >>> huggingface-cli download adept/fuyu-8b model-00001-of-00002.safetensors --local-dir fuyu ... fuyu/model-00001-of-00002.safetensors ```
28_14_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#specify-cache-directory
.md
If not using `--local-dir`, all files will be downloaded by default to the cache directory defined by the `HF_HOME` [environment variable](../package_reference/environment_variables#hfhome). You can specify a custom cache using `--cache-dir`: ```bash >>> huggingface-cli download adept/fuyu-8b --cache-dir ./path/to/cache ... ./path/to/cache/models--adept--fuyu-8b/snapshots/ddcacbcf5fdf9cc59ff01f6be6d6662624d9c745 ```
28_15_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#specify-a-token
.md
To access private or gated repositories, you must use a token. By default, the token saved locally (using `huggingface-cli login`) will be used. If you want to authenticate explicitly, use the `--token` option: ```bash >>> huggingface-cli download gpt2 config.json --token=hf_**** /home/wauplin/.cache/huggingface/hub/models--gpt2/snapshots/11c5a3d5811f50298f278a704980280950aedb10/config.json ```
28_16_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#quiet-mode
.md
By default, the `huggingface-cli download` command will be verbose. It will print details such as warning messages, information about the downloaded files, and progress bars. If you want to silence all of this, use the `--quiet` option. Only the last line (i.e. the path to the downloaded files) is printed. This can prove useful if you want to pass the output to another command in a script. ```bash >>> huggingface-cli download gpt2 --quiet
28_17_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#quiet-mode
.md
```bash >>> huggingface-cli download gpt2 --quiet /home/wauplin/.cache/huggingface/hub/models--gpt2/snapshots/11c5a3d5811f50298f278a704980280950aedb10 ```
28_17_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-timeout
.md
On machines with slow connections, you might encounter timeout issues like this one: ```bash `requests.exceptions.ReadTimeout: (ReadTimeoutError("HTTPSConnectionPool(host='cdn-lfs-us-1.huggingface.co', port=443): Read timed out. (read timeout=10)"), '(Request ID: a33d910c-84c6-4514-8362-c705e2039d38)')` ``` To mitigate this issue, you can set the `HF_HUB_DOWNLOAD_TIMEOUT` environment variable to a higher value (default is 10): ```bash export HF_HUB_DOWNLOAD_TIMEOUT=30 ```
28_18_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#download-timeout
.md
```bash export HF_HUB_DOWNLOAD_TIMEOUT=30 ``` For more details, check out the [environment variables reference](../package_reference/environment_variables#hfhubdownloadtimeout).And rerun your download command.
28_18_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-upload
.md
Use the `huggingface-cli upload` command to upload files to the Hub directly. Internally, it uses the same [`upload_file`] and [`upload_folder`] helpers described in the [Upload](./upload) guide. In the examples below, we will walk through the most common use cases. For a full list of available options, you can run: ```bash >>> huggingface-cli upload --help ```
28_19_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-an-entire-folder
.md
The default usage for this command is: ```bash # Usage: huggingface-cli upload [repo_id] [local_path] [path_in_repo] ``` To upload the current directory at the root of the repo, use: ```bash >>> huggingface-cli upload my-cool-model . . https://huggingface.co/Wauplin/my-cool-model/tree/main/ ``` <Tip> If the repo doesn't exist yet, it will be created automatically. </Tip> You can also upload a specific folder: ```bash >>> huggingface-cli upload my-cool-model ./models .
28_20_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-an-entire-folder
.md
</Tip> You can also upload a specific folder: ```bash >>> huggingface-cli upload my-cool-model ./models . https://huggingface.co/Wauplin/my-cool-model/tree/main/ ``` Finally, you can upload a folder to a specific destination on the repo: ```bash >>> huggingface-cli upload my-cool-model ./path/to/curated/data /data/train https://huggingface.co/Wauplin/my-cool-model/tree/main/data/train ```
28_20_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-a-single-file
.md
You can also upload a single file by setting `local_path` to point to a file on your machine. If that's the case, `path_in_repo` is optional and will default to the name of your local file: ```bash >>> huggingface-cli upload Wauplin/my-cool-model ./models/model.safetensors https://huggingface.co/Wauplin/my-cool-model/blob/main/model.safetensors ``` If you want to upload a single file to a specific directory, set `path_in_repo` accordingly: ```bash
28_21_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-a-single-file
.md
``` If you want to upload a single file to a specific directory, set `path_in_repo` accordingly: ```bash >>> huggingface-cli upload Wauplin/my-cool-model ./models/model.safetensors /vae/model.safetensors https://huggingface.co/Wauplin/my-cool-model/blob/main/vae/model.safetensors ```
28_21_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-multiple-files
.md
To upload multiple files from a folder at once without uploading the entire folder, use the `--include` and `--exclude` patterns. It can also be combined with the `--delete` option to delete files on the repo while uploading new ones. In the example below, we sync the local Space by deleting remote files and uploading all files except the ones in `/logs`: ```bash # Sync local Space with Hub (upload new files except from logs/, delete removed files)
28_22_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-multiple-files
.md
```bash # Sync local Space with Hub (upload new files except from logs/, delete removed files) >>> huggingface-cli upload Wauplin/space-example --repo-type=space --exclude="/logs/*" --delete="*" --commit-message="Sync local Space with Hub" ... ```
28_22_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-to-a-dataset-or-space
.md
To upload to a dataset or a Space, use the `--repo-type` option: ```bash >>> huggingface-cli upload Wauplin/my-cool-dataset ./data /train --repo-type=dataset ... ```
28_23_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-to-an-organization
.md
To upload content to a repo owned by an organization instead of a personal repo, you must explicitly specify it in the `repo_id`: ```bash >>> huggingface-cli upload MyCoolOrganization/my-cool-model . . https://huggingface.co/MyCoolOrganization/my-cool-model/tree/main/ ```
28_24_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-to-a-specific-revision
.md
By default, files are uploaded to the `main` branch. If you want to upload files to another branch or reference, use the `--revision` option: ```bash # Upload files to a PR >>> huggingface-cli upload bigcode/the-stack . . --repo-type dataset --revision refs/pr/104 ... ``` **Note:** if `revision` does not exist and `--create-pr` is not set, a branch will be created automatically from the `main` branch.
28_25_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-and-create-a-pr
.md
If you don't have the permission to push to a repo, you must open a PR and let the authors know about the changes you want to make. This can be done by setting the `--create-pr` option: ```bash # Create a PR and upload the files to it >>> huggingface-cli upload bigcode/the-stack . . --repo-type dataset --revision refs/pr/104 https://huggingface.co/datasets/bigcode/the-stack/blob/refs%2Fpr%2F104/ ```
28_26_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#upload-at-regular-intervals
.md
In some cases, you might want to push regular updates to a repo. For example, this is useful if you're training a model and you want to upload the logs folder every 10 minutes. You can do this using the `--every` option: ```bash # Upload new logs every 10 minutes huggingface-cli upload training-model logs/ --every=10 ```
28_27_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#specify-a-commit-message
.md
Use the `--commit-message` and `--commit-description` to set a custom message and description for your commit instead of the default one ```bash >>> huggingface-cli upload Wauplin/my-cool-model ./models . --commit-message="Epoch 34/50" --commit-description="Val accuracy: 68%. Check tensorboard for more details." ... https://huggingface.co/Wauplin/my-cool-model/tree/main ```
28_28_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#specify-a-token
.md
To upload files, you must use a token. By default, the token saved locally (using `huggingface-cli login`) will be used. If you want to authenticate explicitly, use the `--token` option: ```bash >>> huggingface-cli upload Wauplin/my-cool-model ./models . --token=hf_**** ... https://huggingface.co/Wauplin/my-cool-model/tree/main ```
28_29_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#quiet-mode
.md
By default, the `huggingface-cli upload` command will be verbose. It will print details such as warning messages, information about the uploaded files, and progress bars. If you want to silence all of this, use the `--quiet` option. Only the last line (i.e. the URL to the uploaded files) is printed. This can prove useful if you want to pass the output to another command in a script. ```bash >>> huggingface-cli upload Wauplin/my-cool-model ./models . --quiet
28_30_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#quiet-mode
.md
```bash >>> huggingface-cli upload Wauplin/my-cool-model ./models . --quiet https://huggingface.co/Wauplin/my-cool-model/tree/main ```
28_30_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-repo-files
.md
If you want to delete files from a Hugging Face repository, use the `huggingface-cli repo-files` command.
28_31_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#delete-files
.md
The `huggingface-cli repo-files <repo_id> delete` sub-command allows you to delete files from a repository. Here are some usage examples. Delete a folder : ```bash >>> huggingface-cli repo-files Wauplin/my-cool-model delete folder/ Files correctly deleted from repo. Commit: https://huggingface.co/Wauplin/my-cool-mo... ``` Delete multiple files: ```bash >>> huggingface-cli repo-files Wauplin/my-cool-model delete file.txt folder/pytorch_model.bin
28_32_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#delete-files
.md
Delete multiple files: ```bash >>> huggingface-cli repo-files Wauplin/my-cool-model delete file.txt folder/pytorch_model.bin Files correctly deleted from repo. Commit: https://huggingface.co/Wauplin/my-cool-mo... ``` Use Unix-style wildcards to delete sets of files: ```bash >>> huggingface-cli repo-files Wauplin/my-cool-model delete "*.txt" "folder/*.bin" Files correctly deleted from repo. Commit: https://huggingface.co/Wauplin/my-cool-mo... ```
28_32_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#specify-a-token
.md
To delete files from a repo you must be authenticated and authorized. By default, the token saved locally (using `huggingface-cli login`) will be used. If you want to authenticate explicitly, use the `--token` option: ```bash >>> huggingface-cli repo-files --token=hf_**** Wauplin/my-cool-model delete file.txt ```
28_33_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-scan-cache
.md
Scanning your cache directory is useful if you want to know which repos you have downloaded and how much space it takes on your disk. You can do that by running `huggingface-cli scan-cache`: ```bash >>> huggingface-cli scan-cache REPO ID REPO TYPE SIZE ON DISK NB FILES LAST_ACCESSED LAST_MODIFIED REFS LOCAL PATH
28_34_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-scan-cache
.md
REPO ID REPO TYPE SIZE ON DISK NB FILES LAST_ACCESSED LAST_MODIFIED REFS LOCAL PATH --------------------------- --------- ------------ -------- ------------- ------------- ------------------- ------------------------------------------------------------------------- glue dataset 116.3K 15 4 days ago 4 days ago 2.4.0, main, 1.17.0 /home/wauplin/.cache/huggingface/hub/datasets--glue
28_34_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-scan-cache
.md
google/fleurs dataset 64.9M 6 1 week ago 1 week ago refs/pr/1, main /home/wauplin/.cache/huggingface/hub/datasets--google--fleurs Jean-Baptiste/camembert-ner model 441.0M 7 2 weeks ago 16 hours ago main /home/wauplin/.cache/huggingface/hub/models--Jean-Baptiste--camembert-ner
28_34_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-scan-cache
.md
bert-base-cased model 1.9G 13 1 week ago 2 years ago /home/wauplin/.cache/huggingface/hub/models--bert-base-cased t5-base model 10.1K 3 3 months ago 3 months ago main /home/wauplin/.cache/huggingface/hub/models--t5-base t5-small model 970.7M 11 3 days ago 3 days ago refs/pr/1, main /home/wauplin/.cache/huggingface/hub/models--t5-small
28_34_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-scan-cache
.md
Done in 0.0s. Scanned 6 repo(s) for a total of 3.4G. Got 1 warning(s) while scanning. Use -vvv to print details. ``` For more details about how to scan your cache directory, please refer to the [Manage your cache](./manage-cache#scan-cache-from-the-terminal) guide.
28_34_4
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-delete-cache
.md
`huggingface-cli delete-cache` is a tool that helps you delete parts of your cache that you don't use anymore. This is useful for saving and freeing disk space. To learn more about using this command, please refer to the [Manage your cache](./manage-cache#clean-cache-from-the-terminal) guide.
28_35_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-tag
.md
The `huggingface-cli tag` command allows you to tag, untag, and list tags for repositories.
28_36_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#tag-a-model
.md
To tag a repo, you need to provide the `repo_id` and the `tag` name: ```bash >>> huggingface-cli tag Wauplin/my-cool-model v1.0 You are about to create tag v1.0 on model Wauplin/my-cool-model Tag v1.0 created on Wauplin/my-cool-model ```
28_37_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#tag-a-model-at-a-specific-revision
.md
If you want to tag a specific revision, you can use the `--revision` option. By default, the tag will be created on the `main` branch: ```bash >>> huggingface-cli tag Wauplin/my-cool-model v1.0 --revision refs/pr/104 You are about to create tag v1.0 on model Wauplin/my-cool-model Tag v1.0 created on Wauplin/my-cool-model ```
28_38_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#tag-a-dataset-or-a-space
.md
If you want to tag a dataset or Space, you must specify the `--repo-type` option: ```bash >>> huggingface-cli tag bigcode/the-stack v1.0 --repo-type dataset You are about to create tag v1.0 on dataset bigcode/the-stack Tag v1.0 created on bigcode/the-stack ```
28_39_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#list-tags
.md
To list all tags for a repository, use the `-l` or `--list` option: ```bash >>> huggingface-cli tag Wauplin/gradio-space-ci -l --repo-type space Tags for space Wauplin/gradio-space-ci: 0.2.2 0.2.1 0.2.0 0.1.2 0.0.2 0.0.1 ```
28_40_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#delete-a-tag
.md
To delete a tag, use the `-d` or `--delete` option: ```bash >>> huggingface-cli tag -d 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 ``` You can also pass `-y` to skip the confirmation step.
28_41_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-env
.md
The `huggingface-cli env` command prints details about your machine setup. This is useful when you open an issue on [GitHub](https://github.com/huggingface/huggingface_hub) to help the maintainers investigate your problem. ```bash >>> huggingface-cli env Copy-and-paste the text below in your GitHub issue.
28_42_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-env
.md
- huggingface_hub version: 0.19.0.dev0 - Platform: Linux-6.2.0-36-generic-x86_64-with-glibc2.35 - Python version: 3.10.12 - Running in iPython ?: No - Running in notebook ?: No - Running in Google Colab ?: No - Token path ?: /home/wauplin/.cache/huggingface/token - Has saved token ?: True - Who am I ?: Wauplin - Configured git credential helpers: store - FastAI: N/A - Tensorflow: 2.11.0 - Torch: 1.12.1 - Jinja2: 3.1.2 - Graphviz: 0.20.1 - Pydot: 1.4.2 - Pillow: 9.2.0 - hf_transfer: 0.1.3 - gradio: 4.0.2
28_42_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-env
.md
- Torch: 1.12.1 - Jinja2: 3.1.2 - Graphviz: 0.20.1 - Pydot: 1.4.2 - Pillow: 9.2.0 - hf_transfer: 0.1.3 - gradio: 4.0.2 - tensorboard: 2.6 - numpy: 1.23.2 - pydantic: 2.4.2 - aiohttp: 3.8.4 - ENDPOINT: https://huggingface.co - HF_HUB_CACHE: /home/wauplin/.cache/huggingface/hub - HF_ASSETS_CACHE: /home/wauplin/.cache/huggingface/assets - HF_TOKEN_PATH: /home/wauplin/.cache/huggingface/token - HF_HUB_OFFLINE: False - HF_HUB_DISABLE_TELEMETRY: False - HF_HUB_DISABLE_PROGRESS_BARS: None
28_42_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/cli.md
https://huggingface.co/docs/huggingface_hub/en/guides/cli/#huggingface-cli-env
.md
- HF_HUB_OFFLINE: False - HF_HUB_DISABLE_TELEMETRY: False - HF_HUB_DISABLE_PROGRESS_BARS: None - HF_HUB_DISABLE_SYMLINKS_WARNING: False - HF_HUB_DISABLE_EXPERIMENTAL_WARNING: False - HF_HUB_DISABLE_IMPLICIT_TOKEN: False - HF_HUB_ENABLE_HF_TRANSFER: False - HF_HUB_ETAG_TIMEOUT: 10 - HF_HUB_DOWNLOAD_TIMEOUT: 10 ```
28_42_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/
.md
<!--⚠️ Note that this file is in Markdown but contains specific syntax for our doc-builder (similar to MDX) that may not be rendered properly in your Markdown viewer. -->
29_0_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#interact-with-discussions-and-pull-requests
.md
The `huggingface_hub` library provides a Python interface to interact with Pull Requests and Discussions on the Hub. Visit [the dedicated documentation page](https://huggingface.co/docs/hub/repositories-pull-requests-discussions) for a deeper view of what Discussions and Pull Requests on the Hub are, and how they work under the hood.
29_1_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
The `HfApi` class allows you to retrieve Discussions and Pull Requests on a given repo: ```python >>> from huggingface_hub import get_repo_discussions >>> for discussion in get_repo_discussions(repo_id="bigscience/bloom"): ... print(f"{discussion.num} - {discussion.title}, pr: {discussion.is_pull_request}")
29_2_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
# 11 - Add Flax weights, pr: True # 10 - Update README.md, pr: True # 9 - Training languages in the model card, pr: True # 8 - Update tokenizer_config.json, pr: True # 7 - Slurm training script, pr: False [...] ``` `HfApi.get_repo_discussions` supports filtering by author, type (Pull Request or Discussion) and status (`open` or `closed`): ```python >>> from huggingface_hub import get_repo_discussions >>> for discussion in get_repo_discussions( ... repo_id="bigscience/bloom",
29_2_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
>>> for discussion in get_repo_discussions( ... repo_id="bigscience/bloom", ... author="ArthurZ", ... discussion_type="pull_request", ... discussion_status="open", ... ): ... print(f"{discussion.num} - {discussion.title} by {discussion.author}, pr: {discussion.is_pull_request}")
29_2_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
# 19 - Add Flax weights by ArthurZ, pr: True ``` `HfApi.get_repo_discussions` returns a [generator](https://docs.python.org/3.7/howto/functional.html#generators) that yields [`Discussion`] objects. To get all the Discussions in a single list, run: ```python >>> from huggingface_hub import get_repo_discussions >>> discussions_list = list(get_repo_discussions(repo_id="bert-base-uncased")) ``` The [`Discussion`] object returned by [`HfApi.get_repo_discussions`] contains high-level overview of the
29_2_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
``` The [`Discussion`] object returned by [`HfApi.get_repo_discussions`] contains high-level overview of the Discussion or Pull Request. You can also get more detailed information using [`HfApi.get_discussion_details`]: ```python >>> from huggingface_hub import get_discussion_details
29_2_4
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
>>> get_discussion_details( ... repo_id="bigscience/bloom-1b3", ... discussion_num=2 ... ) DiscussionWithDetails( num=2, author='cakiki', title='Update VRAM memory for the V100s', status='open', is_pull_request=True, events=[ DiscussionComment(type='comment', author='cakiki', ...), DiscussionCommit(type='commit', author='cakiki', summary='Update VRAM memory for the V100s', oid='1256f9d9a33fa8887e1c1bf0e09b4713da96773a', ...), ], conflicting_files=[], target_branch='refs/heads/main',
29_2_5
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
], conflicting_files=[], target_branch='refs/heads/main', merge_commit_oid=None, diff='diff --git a/README.md b/README.md\nindex a6ae3b9294edf8d0eda0d67c7780a10241242a7e..3a1814f212bc3f0d3cc8f74bdbd316de4ae7b9e3 100644\n--- a/README.md\n+++ b/README.md\n@@ -132,7 +132,7 [...]', ) ``` [`HfApi.get_discussion_details`] returns a [`DiscussionWithDetails`] object, which is a subclass of [`Discussion`]
29_2_6
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#retrieve-discussions-and-pull-requests-from-the-hub
.md
) ``` [`HfApi.get_discussion_details`] returns a [`DiscussionWithDetails`] object, which is a subclass of [`Discussion`] with more detailed information about the Discussion or Pull Request. Information includes all the comments, status changes, and renames of the Discussion via [`DiscussionWithDetails.events`]. In case of a Pull Request, you can retrieve the raw git diff with [`DiscussionWithDetails.diff`]. All the commits of the Pull Requests are listed in [`DiscussionWithDetails.events`].
29_2_7
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
The [`HfApi`] class also offers ways to create and edit Discussions and Pull Requests. You will need an [access token](https://huggingface.co/docs/hub/security-tokens) to create and edit Discussions or Pull Requests. The simplest way to propose changes on a repo on the Hub is via the [`create_commit`] API: just set the `create_pr` parameter to `True`. This parameter is also available on other methods that wrap [`create_commit`]: * [`upload_file`] * [`upload_folder`] * [`delete_file`] * [`delete_folder`]
29_3_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
* [`upload_file`] * [`upload_folder`] * [`delete_file`] * [`delete_folder`] * [`metadata_update`] ```python >>> from huggingface_hub import metadata_update
29_3_1
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
>>> metadata_update( ... repo_id="username/repo_name", ... metadata={"tags": ["computer-vision", "awesome-model"]}, ... create_pr=True, ... ) ``` You can also use [`HfApi.create_discussion`] (respectively [`HfApi.create_pull_request`]) to create a Discussion (respectively a Pull Request) on a repo. Opening a Pull Request this way can be useful if you need to work on changes locally. Pull Requests opened this way will be in `"draft"` mode. ```python
29_3_2
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
```python >>> from huggingface_hub import create_discussion, create_pull_request
29_3_3
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
>>> create_discussion( ... repo_id="username/repo-name", ... title="Hi from the huggingface_hub library!", ... token="<insert your access token here>", ... ) DiscussionWithDetails(...)
29_3_4
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
>>> create_pull_request( ... repo_id="username/repo-name", ... title="Hi from the huggingface_hub library!", ... token="<insert your access token here>", ... ) DiscussionWithDetails(..., is_pull_request=True) ``` Managing Pull Requests and Discussions can be done entirely with the [`HfApi`] class. For example: * [`comment_discussion`] to add comments * [`edit_discussion_comment`] to edit comments * [`rename_discussion`] to rename a Discussion or Pull Request
29_3_5
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#create-and-edit-a-discussion-or-pull-request-programmatically
.md
* [`edit_discussion_comment`] to edit comments * [`rename_discussion`] to rename a Discussion or Pull Request * [`change_discussion_status`] to open or close a Discussion / Pull Request * [`merge_pull_request`] to merge a Pull Request Visit the [`HfApi`] documentation page for an exhaustive reference of all available methods.
29_3_6
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#push-changes-to-a-pull-request
.md
*Coming soon !*
29_4_0
/Users/nielsrogge/Documents/python_projecten/huggingface_hub/docs/source/en/guides/community.md
https://huggingface.co/docs/huggingface_hub/en/guides/community/#see-also
.md
For a more detailed reference, visit the [Discussions and Pull Requests](../package_reference/community) and the [hf_api](../package_reference/hf_api) documentation page.
29_5_0