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 ye,h,f as a,c as o,j as fe,u as M,x as l,k as ge,y as we,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(E){let s,f='<a href="/docs/huggingface_hub/pr_2402/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_2402/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=f},l(c){s=h(c,"P",{"data-svelte-h":!0}),l(s)!=="svelte-1npxq5o"&&(s.innerHTML=f)},m(c,A){i(c,s,A)},p:me,d(c){c&&a(s)}}}function Te(E){let s,f,c,A,g,I,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_2402/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_2402/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> client. Let’s examine the pros and cons
of each approach.`,W,m,z,_,ie=`At first, <code>huggingface_hub</code> was mostly built around the <a href="/docs/huggingface_hub/pr_2402/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,y,oe=`The main advantage of using a <a href="/docs/huggingface_hub/pr_2402/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,w,D,v,se=`The <a href="/docs/huggingface_hub/pr_2402/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_2402/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_2402/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_2402/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_2402/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_2402/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,x,le='This preference of the http-based <a href="/docs/huggingface_hub/pr_2402/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> over the git-based <a href="/docs/huggingface_hub/pr_2402/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,P,Y,j,Z;return g=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:E}}}),w=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"}}),P=new $e({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/concepts/git_vs_http.md"}}),{c(){s=r("meta"),f=n(),c=r("p"),A=n(),L(g.$$.fragment),I=n(),u=r("p"),u.innerHTML=te,G=n(),d=r("p"),d.innerHTML=ae,W=n(),L(m.$$.fragment),z=n(),_=r("p"),_.innerHTML=ie,F=n(),b=r("p"),b.textContent=ne,O=n(),y=r("p"),y.innerHTML=oe,U=n(),L(p.$$.fragment),B=n(),L(w.$$.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(),x=r("p"),x.innerHTML=le,X=n(),L(P.$$.fragment),Y=n(),j=r("p"),this.h()},l(e){const t=ye("svelte-u9bgzb",document.head);s=h(t,"META",{name:!0,content:!0}),t.forEach(a),f=o(e),c=h(e,"P",{}),fe(c).forEach(a),A=o(e),M(g.$$.fragment,e),I=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-8kfrjr"&&(d.innerHTML=ae),W=o(e),M(m.$$.fragment,e),z=o(e),_=h(e,"P",{"data-svelte-h":!0}),l(_)!=="svelte-1oufefq"&&(_.innerHTML=ie),F=o(e),b=h(e,"P",{"data-svelte-h":!0}),l(b)!=="svelte-mpix11"&&(b.textContent=ne),O=o(e),y=h(e,"P",{"data-svelte-h":!0}),l(y)!=="svelte-19w0ejv"&&(y.innerHTML=oe),U=o(e),M(p.$$.fragment,e),B=o(e),M(w.$$.fragment,e),D=o(e),v=h(e,"P",{"data-svelte-h":!0}),l(v)!=="svelte-1j3tpt6"&&(v.innerHTML=se),J=o(e),$=h(e,"P",{"data-svelte-h":!0}),l($)!=="svelte-1suiyn4"&&($.innerHTML=re),K=o(e),M(H.$$.fragment,e),N=o(e),T=h(e,"P",{"data-svelte-h":!0}),l(T)!=="svelte-16fru6r"&&(T.innerHTML=he),Q=o(e),k=h(e,"P",{"data-svelte-h":!0}),l(k)!=="svelte-jyumrb"&&(k.innerHTML=ce),V=o(e),x=h(e,"P",{"data-svelte-h":!0}),l(x)!=="svelte-x2rypt"&&(x.innerHTML=le),X=o(e),M(P.$$.fragment,e),Y=o(e),j=h(e,"P",{}),fe(j).forEach(a),this.h()},h(){ge(s,"name","hf:doc:metadata"),ge(s,"content",ke)},m(e,t){we(document.head,s),i(e,f,t),i(e,c,t),i(e,A,t),R(g,e,t),i(e,I,t),i(e,u,t),i(e,G,t),i(e,d,t),i(e,W,t),R(m,e,t),i(e,z,t),i(e,_,t),i(e,F,t),i(e,b,t),i(e,O,t),i(e,y,t),i(e,U,t),R(p,e,t),i(e,B,t),R(w,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,x,t),i(e,X,t),R(P,e,t),i(e,Y,t),i(e,j,t),Z=!0},p(e,[t]){const pe={};t&2&&(pe.$$scope={dirty:t,ctx:e}),p.$set(pe)},i(e){Z||(q(g.$$.fragment,e),q(m.$$.fragment,e),q(p.$$.fragment,e),q(w.$$.fragment,e),q(H.$$.fragment,e),q(P.$$.fragment,e),Z=!0)},o(e){C(g.$$.fragment,e),C(m.$$.fragment,e),C(p.$$.fragment,e),C(w.$$.fragment,e),C(H.$$.fragment,e),C(P.$$.fragment,e),Z=!1},d(e){e&&(a(f),a(c),a(A),a(I),a(u),a(G),a(d),a(W),a(z),a(_),a(F),a(b),a(O),a(y),a(U),a(B),a(D),a(v),a(J),a($),a(K),a(N),a(T),a(Q),a(k),a(V),a(x),a(X),a(Y),a(j)),a(s),S(g,e),S(m,e),S(p,e),S(w,e),S(H,e),S(P,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 xe(E){return de(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends _e{constructor(s){super(),be(this,s,xe,Te,ue,{})}}export{Re as component};
