Buckets:
| <meta charset="utf-8" /><meta name="hf:doc:metadata" content="{"title":"Migrating to huggingface_hub v1.0","local":"migrating-to-huggingfacehub-v10","sections":[{"title":"Python 3.9+","local":"python-39","sections":[],"depth":2},{"title":"HTTPX migration","local":"httpx-migration","sections":[{"title":"Breaking changes","local":"breaking-changes","sections":[],"depth":3},{"title":"Why httpx ?","local":"why-httpx-","sections":[],"depth":3}],"depth":2},{"title":"hf_transfer","local":"hftransfer","sections":[],"depth":2},{"title":"Repository class","local":"repository-class","sections":[],"depth":2},{"title":"HfFolder class","local":"hffolder-class","sections":[],"depth":2},{"title":"InferenceApi class","local":"inferenceapi-class","sections":[],"depth":2},{"title":"Other deprecated features","local":"other-deprecated-features","sections":[],"depth":2},{"title":"CLI cache commands","local":"cli-cache-commands","sections":[],"depth":2},{"title":"TensorFlow and Keras 2.x support","local":"tensorflow-and-keras-2x-support","sections":[],"depth":2},{"title":"upload_file and upload_folder return values","local":"uploadfile-and-uploadfolder-return-values","sections":[],"depth":2}],"depth":1}"> | |
| <link href="/docs/huggingface_hub/pr_4113/en/_app/immutable/assets/0.e3b0c442.css" rel="modulepreload"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/entry/start.cad533c1.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/scheduler.0cf4ef2e.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/singletons.2cc47ca0.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/paths.69a55a12.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/entry/app.b1cfe321.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/preload-helper.d23a64db.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/index.abc433bf.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/nodes/0.3b235bd8.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/each.e59479a4.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/nodes/3.69de5ab5.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/CopyLLMTxtMenu.f735f320.js"> | |
| <link rel="modulepreload" href="/docs/huggingface_hub/pr_4113/en/_app/immutable/chunks/MermaidChart.svelte_svelte_type_style_lang.f083e07d.js"><!-- HEAD_svelte-u9bgzb_START --><meta name="hf:doc:metadata" content="{"title":"Migrating to huggingface_hub v1.0","local":"migrating-to-huggingfacehub-v10","sections":[{"title":"Python 3.9+","local":"python-39","sections":[],"depth":2},{"title":"HTTPX migration","local":"httpx-migration","sections":[{"title":"Breaking changes","local":"breaking-changes","sections":[],"depth":3},{"title":"Why httpx ?","local":"why-httpx-","sections":[],"depth":3}],"depth":2},{"title":"hf_transfer","local":"hftransfer","sections":[],"depth":2},{"title":"Repository class","local":"repository-class","sections":[],"depth":2},{"title":"HfFolder class","local":"hffolder-class","sections":[],"depth":2},{"title":"InferenceApi class","local":"inferenceapi-class","sections":[],"depth":2},{"title":"Other deprecated features","local":"other-deprecated-features","sections":[],"depth":2},{"title":"CLI cache commands","local":"cli-cache-commands","sections":[],"depth":2},{"title":"TensorFlow and Keras 2.x support","local":"tensorflow-and-keras-2x-support","sections":[],"depth":2},{"title":"upload_file and upload_folder return values","local":"uploadfile-and-uploadfolder-return-values","sections":[],"depth":2}],"depth":1}"><!-- HEAD_svelte-u9bgzb_END --> <p></p> <div class="items-center shrink-0 min-w-[100px] max-sm:min-w-[50px] justify-end ml-auto flex" style="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"><div class="inline-flex rounded-md max-sm:rounded-sm"><button class="inline-flex items-center gap-1 h-7 max-sm:h-7 px-2 max-sm:px-1.5 text-sm font-medium text-gray-800 border border-r-0 rounded-l-md max-sm:rounded-l-sm border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-live="polite"><span class="inline-flex items-center justify-center rounded-md p-0.5 max-sm:p-0 hover:text-gray-800 dark:hover:text-gray-200"><svg class="sm:size-3.5 size-3" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z" transform="translate(0)"></path><path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)"></path><rect fill="none" width="32" height="32"></rect></svg></span> <span>Copy page</span></button> <button class="inline-flex items-center justify-center w-6 max-sm:w-5 h-7 max-sm:h-7 disabled:pointer-events-none text-sm text-gray-500 hover:text-gray-700 dark:hover:text-white rounded-r-md max-sm:rounded-r-sm border border-l transition border-gray-200 bg-white hover:shadow-inner dark:border-gray-850 dark:bg-gray-950 dark:text-gray-200 dark:hover:bg-gray-800" aria-haspopup="menu" aria-expanded="false" aria-label="Open copy menu"><svg class="transition-transform text-gray-400 overflow-visible sm:size-3.5 size-3 rotate-0" width="1em" height="1em" viewBox="0 0 12 7" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L6 6L11 1" stroke="currentColor"></path></svg></button></div> </div> <h1 class="relative group"><a id="migrating-to-huggingfacehub-v10" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#migrating-to-huggingfacehub-v10"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Migrating to huggingface_hub v1.0</span></h1> <p data-svelte-h="svelte-t23pc3">The v1.0 release is a major milestone for the <code>huggingface_hub</code> library. It marks our commitment to API stability and the maturity of the library. We have made several improvements and breaking changes to make the library more robust and easier to use.</p> <p data-svelte-h="svelte-15m6031">This guide is intended to help you migrate your existing code to the new version. If you have any questions or feedback, please let us know by <a href="https://github.com/huggingface/huggingface_hub/issues" rel="nofollow">opening an issue on GitHub</a>.</p> <h2 class="relative group"><a id="python-39" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#python-39"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Python 3.9+</span></h2> <p data-svelte-h="svelte-1adikcs"><code>huggingface_hub</code> now requires Python 3.9 or higher. Python 3.8 is no longer supported.</p> <h2 class="relative group"><a id="httpx-migration" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#httpx-migration"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>HTTPX migration</span></h2> <p data-svelte-h="svelte-11fofu5">The <code>huggingface_hub</code> library now uses <a href="https://www.python-httpx.org/" rel="nofollow"><code>httpx</code></a> instead of <code>requests</code> for HTTP requests. This change was made to improve performance and to support both synchronous and asynchronous requests the same way. We therefore dropped both <code>requests</code> and <code>aiohttp</code> dependencies.</p> <h3 class="relative group"><a id="breaking-changes" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#breaking-changes"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Breaking changes</span></h3> <p data-svelte-h="svelte-145g3dr">This is a major change that affects the entire library. While we have tried to make this change as transparent as possible, you may need to update your code in some cases. Here is a list of breaking changes introduced in the process:</p> <ul data-svelte-h="svelte-1iablzh"><li><strong>Proxy configuration</strong>: “per method” proxies are no longer supported. Proxies must be configured globally using the <code>HTTP_PROXY</code> and <code>HTTPS_PROXY</code> environment variables.</li> <li><strong>Custom HTTP backend</strong>: The <code>configure_http_backend</code> function has been removed. You should now use <a href="/docs/huggingface_hub/pr_4113/en/package_reference/utilities#huggingface_hub.set_client_factory">set_client_factory()</a> and <a href="/docs/huggingface_hub/pr_4113/en/package_reference/utilities#huggingface_hub.set_async_client_factory">set_async_client_factory()</a> to configure the HTTP clients.</li> <li><strong>Error handling</strong>: HTTP errors are not inherited from <code>requests.HTTPError</code> anymore, but from <code>httpx.HTTPError</code>. We recommend catching <code>huggingface_hub.HfHubHttpError</code> which is a subclass of <code>requests.HTTPError</code> in v0.x and of <code>httpx.HTTPError</code> in v1.x. Catching from the <code>huggingface_hub</code> error ensures your code is compatible with both the old and new versions of the library.</li> <li><strong>SSLError</strong>: <code>httpx</code> does not have the concept of <code>SSLError</code>. It is now a generic <code>httpx.ConnectError</code>.</li> <li><strong><code>LocalEntryNotFoundError</code></strong>: This error no longer inherits from <code>HTTPError</code>. We now define a <code>EntryNotFoundError</code> (new) that is inherited by both <code>LocalEntryNotFoundError</code> (if file not found in local cache) and <code>RemoteEntryNotFoundError</code> (if file not found in repo on the Hub). Only the remote error inherits from <code>HTTPError</code>.</li> <li><strong><code>InferenceClient</code></strong>: The <code>InferenceClient</code> can now be used as a context manager. This is especially useful when streaming tokens from a language model to ensure that the connection is closed properly.</li> <li><strong><code>AsyncInferenceClient</code></strong>: The <code>trust_env</code> parameter has been removed from the <code>AsyncInferenceClient</code>’s constructor. Environment variables are trusted by default by <code>httpx</code>. If you explicitly don’t want to trust the environment, you must configure it with <a href="/docs/huggingface_hub/pr_4113/en/package_reference/utilities#huggingface_hub.set_client_factory">set_client_factory()</a>.</li></ul> <p data-svelte-h="svelte-v9ui40">For more details, you can check <a href="https://github.com/huggingface/huggingface_hub/pull/3328" rel="nofollow">PR #3328</a> that introduced <code>httpx</code>.</p> <h3 class="relative group"><a id="why-httpx-" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#why-httpx-"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Why httpx ?</span></h3> <p data-svelte-h="svelte-1i7b7h4">The migration from <code>requests</code> to <code>httpx</code> brings several key improvements that enhance the library’s performance, reliability, and maintainability:</p> <p data-svelte-h="svelte-1yvs1su"><strong>Thread Safety and Connection Reuse</strong>: <code>httpx</code> is thread-safe by design, allowing us to safely reuse the same client across multiple threads. This connection reuse reduces the overhead of establishing new connections for each HTTP request, improving performance especially when making frequent requests to the Hub.</p> <p data-svelte-h="svelte-bisj46"><strong>HTTP/2 Support</strong>: <code>httpx</code> provides native HTTP/2 support, which offers better efficiency when making multiple requests to the same server (exactly our use case). This translates to lower latency and reduced resource consumption compared to HTTP/1.1.</p> <p data-svelte-h="svelte-1y4y4mi"><strong>Unified Sync/Async API</strong>: Unlike our previous setup with separate <code>requests</code> (sync) and <code>aiohttp</code> (async) dependencies, <code>httpx</code> provides both synchronous and asynchronous clients with identical behavior. This ensures that <code>InferenceClient</code> and <code>AsyncInferenceClient</code> have consistent functionality and eliminates subtle behavioral differences that previously existed between the two implementations.</p> <p data-svelte-h="svelte-ckzch0"><strong>Improved SSL Error Handling</strong>: <code>httpx</code> handles SSL errors more gracefully, making debugging connection issues easier and more reliable.</p> <p data-svelte-h="svelte-2ote3q"><strong>Future-Proof Architecture</strong>: <code>httpx</code> is actively maintained and designed for modern Python applications. In contrast, <code>requests</code> is in maintenance mode and won’t receive major updates like thread-safety improvements or HTTP/2 support.</p> <p data-svelte-h="svelte-xedd0t"><strong>Better Environment Variable Handling</strong>: <code>httpx</code> provides more consistent handling of environment variables across both sync and async contexts, eliminating previous inconsistencies where <code>requests</code> would read local environment variables by default while <code>aiohttp</code> would not.</p> <p data-svelte-h="svelte-zjn7b4">The transition to <code>httpx</code> positions <code>huggingface_hub</code> with a modern, efficient, and maintainable HTTP backend. While most users should experience seamless operation, the underlying improvements provide better performance and reliability for all Hub interactions.</p> <h2 class="relative group"><a id="hftransfer" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#hftransfer"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>hf_transfer</span></h2> <p data-svelte-h="svelte-opc8qc">Now that all repositories on the Hub are Xet-enabled and that <code>hf_xet</code> is the default way to download/upload files, we’ve removed support for the <code>hf_transfer</code> optional package. The <code>HF_HUB_ENABLE_HF_TRANSFER</code> environment variable is therefore ignored. Use <a href="../package_reference/environment_variables"><code>HF_XET_HIGH_PERFORMANCE</code></a> instead.</p> <h2 class="relative group"><a id="repository-class" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#repository-class"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Repository class</span></h2> <p data-svelte-h="svelte-6m5hf4">The <code>Repository</code> class has been removed in v1.0. It was a thin wrapper around the <code>git</code> CLI for managing repositories. You can still use <code>git</code> directly in the terminal, but the recommended approach is to use the HTTP-based API in the <code>huggingface_hub</code> library for a smoother experience, especially when dealing with large files.</p> <p data-svelte-h="svelte-fmadcf">Here is a mapping from the legacy <code>Repository</code> class to the new <code>HfApi</code> one:</p> <table data-svelte-h="svelte-1uunjoo"><thead><tr><th><code>Repository</code> method</th> <th><code>HfApi</code> method</th></tr></thead> <tbody><tr><td><code>repo.clone_from</code></td> <td><code>snapshot_download</code></td></tr> <tr><td><code>repo.git_add</code> + <code>git_commit</code> + <code>git_push</code></td> <td><a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.upload_file">upload_file()</a>, <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.upload_folder">upload_folder()</a>, <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.create_commit">create_commit()</a></td></tr> <tr><td><code>repo.git_tag</code></td> <td><code>create_tag</code></td></tr> <tr><td><code>repo.git_branch</code></td> <td><code>create_branch</code></td></tr></tbody></table> <h2 class="relative group"><a id="hffolder-class" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#hffolder-class"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>HfFolder class</span></h2> <p data-svelte-h="svelte-1w1vnys"><code>HfFolder</code> was used to manage the user access token. Use <a href="/docs/huggingface_hub/pr_4113/en/package_reference/authentication#huggingface_hub.login">login()</a> to save a new token, <a href="/docs/huggingface_hub/pr_4113/en/package_reference/authentication#huggingface_hub.logout">logout()</a> to delete it and <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.whoami">whoami()</a> to check the user associated to the current token. Finally, use <code>get_token()</code> to retrieve user’s token in a script.</p> <h2 class="relative group"><a id="inferenceapi-class" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#inferenceapi-class"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>InferenceApi class</span></h2> <p data-svelte-h="svelte-7olnhb"><code>InferenceApi</code> was a class to interact with the Inference API. It is now recommended to use the <a href="/docs/huggingface_hub/pr_4113/en/package_reference/inference_client#huggingface_hub.InferenceClient">InferenceClient</a> class instead.</p> <h2 class="relative group"><a id="other-deprecated-features" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#other-deprecated-features"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>Other deprecated features</span></h2> <p data-svelte-h="svelte-161jw51">Some methods and parameters have been removed in v1.0. The ones listed below have already been deprecated with a warning message in v0.x.</p> <ul data-svelte-h="svelte-1padejn"><li><code>constants.hf_cache_home</code> has been removed. Please use <code>HF_HOME</code> instead.</li> <li><code>use_auth_token</code> parameters have been removed from all methods. Please use <code>token</code> instead.</li> <li><code>get_token_permission</code> method has been removed.</li> <li><code>update_repo_visibility</code> method has been removed. Please use <code>update_repo_settings</code> instead.</li> <li><code>is_write_action</code> parameter has been removed from <code>build_hf_headers</code> as well as <code>write_permission</code> from <code>login</code>. The concept of “write permission” has been removed and is no longer relevant now that fine-grained tokens are the recommended approach.</li> <li><code>new_session</code> parameter in <code>login</code> has been renamed to <code>skip_if_logged_in</code> for better clarity.</li> <li><code>resume_download</code>, <code>force_filename</code>, and <code>local_dir_use_symlinks</code> parameters have been removed from <code>hf_hub_download</code> and <code>snapshot_download</code>.</li> <li><code>library</code>, <code>language</code>, <code>tags</code>, and <code>task</code> parameters have been removed from <code>list_models</code>.</li></ul> <h2 class="relative group"><a id="cli-cache-commands" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#cli-cache-commands"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>CLI cache commands</span></h2> <p data-svelte-h="svelte-p6nfpi">Cache management from the CLI has been redesigned to follow a Docker-inspired workflow. The deprecated <code>huggingface-cli</code> has been removed, <code>hf</code> (introduced in v0.34) replaces it with a clearer ressource-action CLI. | |
| The legacy <code>hf cache scan</code> and <code>hf cache delete</code> commands are also removed in v1.0 and are replaced with the new trio below:</p> <ul data-svelte-h="svelte-1tgaack"><li><code>hf cache ls</code> lists cache entries with concise table, JSON, or CSV output. Use <code>--revisions</code> to inspect individual revisions, add <code>--filter</code> expressions such as <code>size>1GB</code> or <code>accessed>30d</code>, and combine them with <code>--quiet</code> when you only need the identifiers.</li> <li><code>hf cache rm</code> deletes selected cache entries. Pass one or more repo IDs (for example <code>model/bert-base-uncased</code>) or revision hashes, and optionally add <code>--dry-run</code> to preview or <code>--yes</code> to skip the confirmation prompt. This replaces both the interactive TUI and <code>--disable-tui</code> workflows from the previous command.</li> <li><code>hf cache prune</code> performs the common cleanup task of deleting unreferenced revisions in one shot. Add <code>--dry-run</code> or <code>--yes</code> in the same way as with <code>hf cache rm</code>.</li></ul> <p data-svelte-h="svelte-xqm9kb">Finally, the <code>[cli]</code> extra has been removed - The CLI now ships with the core <code>huggingface_hub</code> package.</p> <h2 class="relative group"><a id="tensorflow-and-keras-2x-support" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#tensorflow-and-keras-2x-support"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>TensorFlow and Keras 2.x support</span></h2> <p data-svelte-h="svelte-1xjprmy">All TensorFlow-related code and dependencies have been removed in v1.0. This includes the following breaking changes:</p> <ul data-svelte-h="svelte-1lmmq60"><li><code>huggingface_hub[tensorflow]</code> is no longer a supported extra dependency</li> <li>The <code>split_tf_state_dict_into_shards</code> and <code>get_tf_storage_size</code> utility functions have been removed.</li> <li>The <code>tensorflow</code>, <code>fastai</code>, and <code>fastcore</code> versions are no longer included in the built-in headers.</li></ul> <p data-svelte-h="svelte-pkbhai">The Keras 2.x integration has also been removed. This includes the <code>KerasModelHubMixin</code> class and the <code>save_pretrained_keras</code>, <code>from_pretrained_keras</code>, and <code>push_to_hub_keras</code> utilities. Keras 2.x is a legacy and unmaintained library. The recommended approach is to use Keras 3.x which is tightly integrated with the Hub (i.e. it contains built-in method to load/push to Hub). If you still want to work with Keras 2.x, you should downgrade <code>huggingface_hub</code> to v0.x version.</p> <h2 class="relative group"><a id="uploadfile-and-uploadfolder-return-values" class="header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full" href="#uploadfile-and-uploadfolder-return-values"><span><svg class="" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 256"><path d="M167.594 88.393a8.001 8.001 0 0 1 0 11.314l-67.882 67.882a8 8 0 1 1-11.314-11.315l67.882-67.881a8.003 8.003 0 0 1 11.314 0zm-28.287 84.86l-28.284 28.284a40 40 0 0 1-56.567-56.567l28.284-28.284a8 8 0 0 0-11.315-11.315l-28.284 28.284a56 56 0 0 0 79.196 79.197l28.285-28.285a8 8 0 1 0-11.315-11.314zM212.852 43.14a56.002 56.002 0 0 0-79.196 0l-28.284 28.284a8 8 0 1 0 11.314 11.314l28.284-28.284a40 40 0 0 1 56.568 56.567l-28.285 28.285a8 8 0 0 0 11.315 11.314l28.284-28.284a56.065 56.065 0 0 0 0-79.196z" fill="currentColor"></path></svg></span></a> <span>upload_file and upload_folder return values</span></h2> <p data-svelte-h="svelte-2n1x2v">The <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.upload_file">upload_file()</a> and <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.upload_folder">upload_folder()</a> functions now return the URL of the commit created on the Hub. Previously, they returned the URL of the file or folder. This is to align with the return value of <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.create_commit">create_commit()</a>, <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.delete_file">delete_file()</a> and <a href="/docs/huggingface_hub/pr_4113/en/package_reference/hf_api#huggingface_hub.HfApi.delete_folder">delete_folder()</a>.</p> <a class="!text-gray-400 !no-underline text-sm flex items-center not-prose mt-4" href="https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/concepts/migration.md" target="_blank"><svg class="mr-1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" fill="currentColor" focusable="false" role="img" width="1em" height="1em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 32 32"><path d="M31,16l-7,7l-1.41-1.41L28.17,16l-5.58-5.59L24,9l7,7z"></path><path d="M1,16l7-7l1.41,1.41L3.83,16l5.58,5.59L8,23l-7-7z"></path><path d="M12.419,25.484L17.639,6.552l1.932,0.518L14.351,26.002z"></path></svg> <span data-svelte-h="svelte-zjs2n5"><span class="underline">Update</span> on GitHub</span></a> <p></p> | |
| <script> | |
| { | |
| __sveltekit_1c3kngw = { | |
| assets: "/docs/huggingface_hub/pr_4113/en", | |
| base: "/docs/huggingface_hub/pr_4113/en", | |
| env: {} | |
| }; | |
| const element = document.currentScript.parentElement; | |
| const data = [null,null]; | |
| Promise.all([ | |
| import("/docs/huggingface_hub/pr_4113/en/_app/immutable/entry/start.cad533c1.js"), | |
| import("/docs/huggingface_hub/pr_4113/en/_app/immutable/entry/app.b1cfe321.js") | |
| ]).then(([kit, app]) => { | |
| kit.start(app, element, { | |
| node_ids: [0, 3], | |
| data, | |
| form: null, | |
| error: null | |
| }); | |
| }); | |
| } | |
| </script> | |
Xet Storage Details
- Size:
- 37 kB
- Xet hash:
- c0355925ddc31dc32f9f52529b848f011020ab9bff882b9074edf519e07b94b6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.