import{s as ue,o as de,n as me}from"../chunks/scheduler.6062bdaf.js";import{S as _e,i as be,g as r,s as n,r as L,A as we,h,f as a,c as o,j as ge,u as M,x as l,k as fe,y as ye,a as i,v as R,d as q,t as C,w as S}from"../chunks/index.4bca734e.js";import{T as ve}from"../chunks/Tip.b9ac1f03.js";import{H as ee,E as $e}from"../chunks/EditOnGithub.74ab2baa.js";function He(I){let s,g='<a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> is now deprecated in favor of the http-based alternatives. Given its large adoption in legacy code, the complete removal of <a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> will only happen in release <code>v1.0</code>.';return{c(){s=r("p"),s.innerHTML=g},l(c){s=h(c,"P",{"data-svelte-h":!0}),l(s)!=="svelte-1hjg2ae"&&(s.innerHTML=g)},m(c,A){i(c,s,A)},p:me,d(c){c&&a(s)}}}function Te(I){let s,g,c,A,f,j,u,te=`The <code>huggingface_hub</code> library is a library for interacting with the Hugging Face Hub, which is a
collections of git-based repositories (models, datasets or Spaces). There are two main
ways to access the Hub using <code>huggingface_hub</code>.`,G,d,ae=`The first approach, the so-called “git-based” approach, is led by the <a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> class.
This method uses a wrapper around the <code>git</code> command with additional functions specifically
designed to interact with the Hub. The second option, called the “HTTP-based” approach,
involves making HTTP requests using the <a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> client. Let’s examine the pros and cons
of each approach.`,z,m,W,_,ie=`At first, <code>huggingface_hub</code> was mostly built around the <a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> class. It provides
Python wrappers for common <code>git</code> commands such as <code>&quot;git add&quot;</code>, <code>&quot;git commit&quot;</code>, <code>&quot;git push&quot;</code>,
<code>&quot;git tag&quot;</code>, <code>&quot;git checkout&quot;</code>, etc.`,F,b,ne=`The library also helps with setting credentials and tracking large files, which are often
used in machine learning repositories. Additionally, the library allows you to execute its
methods in the background, making it useful for uploading data during training.`,O,w,oe=`The main advantage of using a <a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> is that it allows you to maintain a local
copy of the entire repository on your machine. This can also be a disadvantage as
it requires you to constantly update and maintain this local copy. This is similar to
traditional software development where each developer maintains their own local copy and
pushes changes when working on a feature. However, in the context of machine learning,
this may not always be necessary as users may only need to download weights for inference
or convert weights from one format to another without the need to clone the entire
repository.`,U,p,B,y,D,v,se=`The <a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> class was developed to provide an alternative to local git repositories, which
can be cumbersome to maintain, especially when dealing with large models or datasets. The
<a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> class offers the same functionality as git-based approaches, such as downloading
and pushing files and creating branches and tags, but without the need for a local folder
that needs to be kept in sync.`,J,$,re=`In addition to the functionalities already provided by <code>git</code>, the <a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> class offers
additional features, such as the ability to manage repos, download files using caching for
efficient reuse, search the Hub for repos and metadata, access community features such as
discussions, PRs, and comments, and configure Spaces hardware and secrets.`,K,H,N,T,he=`Overall, the <strong>HTTP-based approach is the recommended way to use</strong> <code>huggingface_hub</code>
in all cases. <a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> allows to pull and push changes, work with PRs, tags and branches, interact with discussions and much more. Since the <code>0.16</code> release, the http-based methods can also run in the background, which was the last major advantage of the <a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> class.`,Q,k,ce='However, not all git commands are available through <a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a>. Some may never be implemented, but we are always trying to improve and close the gap. If you don’t see your use case covered, please open <a href="https://github.com/huggingface/huggingface_hub" rel="nofollow">an issue on Github</a>! We welcome feedback to help build the 🤗 ecosystem with and for our users.',V,P,le='This preference of the http-based <a href="/docs/huggingface_hub/pr_2368/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> over the git-based <a href="/docs/huggingface_hub/pr_2368/en/package_reference/repository#huggingface_hub.Repository">Repository</a> does not mean that git versioning will disappear from the Hugging Face Hub anytime soon. It will always be possible to use <code>git</code> commands locally in workflows where it makes sense.',X,x,Y,E,Z;return f=new ee({props:{title:"Git vs HTTP paradigm",local:"git-vs-http-paradigm",headingTag:"h1"}}),m=new ee({props:{title:"Repository: the historical git-based approach",local:"repository-the-historical-git-based-approach",headingTag:"h2"}}),p=new ve({props:{warning:!0,$$slots:{default:[He]},$$scope:{ctx:I}}}),y=new ee({props:{title:"HfApi: a flexible and convenient HTTP client",local:"hfapi-a-flexible-and-convenient-http-client",headingTag:"h2"}}),H=new ee({props:{title:"What should I use ? And when ?",local:"what-should-i-use--and-when-",headingTag:"h2"}}),x=new $e({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/concepts/git_vs_http.md"}}),{c(){s=r("meta"),g=n(),c=r("p"),A=n(),L(f.$$.fragment),j=n(),u=r("p"),u.innerHTML=te,G=n(),d=r("p"),d.innerHTML=ae,z=n(),L(m.$$.fragment),W=n(),_=r("p"),_.innerHTML=ie,F=n(),b=r("p"),b.textContent=ne,O=n(),w=r("p"),w.innerHTML=oe,U=n(),L(p.$$.fragment),B=n(),L(y.$$.fragment),D=n(),v=r("p"),v.innerHTML=se,J=n(),$=r("p"),$.innerHTML=re,K=n(),L(H.$$.fragment),N=n(),T=r("p"),T.innerHTML=he,Q=n(),k=r("p"),k.innerHTML=ce,V=n(),P=r("p"),P.innerHTML=le,X=n(),L(x.$$.fragment),Y=n(),E=r("p"),this.h()},l(e){const t=we("svelte-u9bgzb",document.head);s=h(t,"META",{name:!0,content:!0}),t.forEach(a),g=o(e),c=h(e,"P",{}),ge(c).forEach(a),A=o(e),M(f.$$.fragment,e),j=o(e),u=h(e,"P",{"data-svelte-h":!0}),l(u)!=="svelte-109fppz"&&(u.innerHTML=te),G=o(e),d=h(e,"P",{"data-svelte-h":!0}),l(d)!=="svelte-16bc4yv"&&(d.innerHTML=ae),z=o(e),M(m.$$.fragment,e),W=o(e),_=h(e,"P",{"data-svelte-h":!0}),l(_)!=="svelte-1q1g0cv"&&(_.innerHTML=ie),F=o(e),b=h(e,"P",{"data-svelte-h":!0}),l(b)!=="svelte-mpix11"&&(b.textContent=ne),O=o(e),w=h(e,"P",{"data-svelte-h":!0}),l(w)!=="svelte-evz7qg"&&(w.innerHTML=oe),U=o(e),M(p.$$.fragment,e),B=o(e),M(y.$$.fragment,e),D=o(e),v=h(e,"P",{"data-svelte-h":!0}),l(v)!=="svelte-1m2zufu"&&(v.innerHTML=se),J=o(e),$=h(e,"P",{"data-svelte-h":!0}),l($)!=="svelte-ewjrnl"&&($.innerHTML=re),K=o(e),M(H.$$.fragment,e),N=o(e),T=h(e,"P",{"data-svelte-h":!0}),l(T)!=="svelte-1flhpi5"&&(T.innerHTML=he),Q=o(e),k=h(e,"P",{"data-svelte-h":!0}),l(k)!=="svelte-15k2iao"&&(k.innerHTML=ce),V=o(e),P=h(e,"P",{"data-svelte-h":!0}),l(P)!=="svelte-1qjwif5"&&(P.innerHTML=le),X=o(e),M(x.$$.fragment,e),Y=o(e),E=h(e,"P",{}),ge(E).forEach(a),this.h()},h(){fe(s,"name","hf:doc:metadata"),fe(s,"content",ke)},m(e,t){ye(document.head,s),i(e,g,t),i(e,c,t),i(e,A,t),R(f,e,t),i(e,j,t),i(e,u,t),i(e,G,t),i(e,d,t),i(e,z,t),R(m,e,t),i(e,W,t),i(e,_,t),i(e,F,t),i(e,b,t),i(e,O,t),i(e,w,t),i(e,U,t),R(p,e,t),i(e,B,t),R(y,e,t),i(e,D,t),i(e,v,t),i(e,J,t),i(e,$,t),i(e,K,t),R(H,e,t),i(e,N,t),i(e,T,t),i(e,Q,t),i(e,k,t),i(e,V,t),i(e,P,t),i(e,X,t),R(x,e,t),i(e,Y,t),i(e,E,t),Z=!0},p(e,[t]){const pe={};t&2&&(pe.$$scope={dirty:t,ctx:e}),p.$set(pe)},i(e){Z||(q(f.$$.fragment,e),q(m.$$.fragment,e),q(p.$$.fragment,e),q(y.$$.fragment,e),q(H.$$.fragment,e),q(x.$$.fragment,e),Z=!0)},o(e){C(f.$$.fragment,e),C(m.$$.fragment,e),C(p.$$.fragment,e),C(y.$$.fragment,e),C(H.$$.fragment,e),C(x.$$.fragment,e),Z=!1},d(e){e&&(a(g),a(c),a(A),a(j),a(u),a(G),a(d),a(z),a(W),a(_),a(F),a(b),a(O),a(w),a(U),a(B),a(D),a(v),a(J),a($),a(K),a(N),a(T),a(Q),a(k),a(V),a(P),a(X),a(Y),a(E)),a(s),S(f,e),S(m,e),S(p,e),S(y,e),S(H,e),S(x,e)}}}const ke='{"title":"Git vs HTTP paradigm","local":"git-vs-http-paradigm","sections":[{"title":"Repository: the historical git-based approach","local":"repository-the-historical-git-based-approach","sections":[],"depth":2},{"title":"HfApi: a flexible and convenient HTTP client","local":"hfapi-a-flexible-and-convenient-http-client","sections":[],"depth":2},{"title":"What should I use ? And when ?","local":"what-should-i-use--and-when-","sections":[],"depth":2}],"depth":1}';function Pe(I){return de(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends _e{constructor(s){super(),be(this,s,Pe,Te,ue,{})}}export{Re as component};
