import{s as ce,n as he,o as pe}from"../chunks/scheduler.6062bdaf.js";import{S as ue,i as fe,g as s,s as n,r as F,A as de,h as r,f as a,c as o,j as re,u as N,x as l,k as le,y as ge,a as i,v as O,d as B,t as J,w as K}from"../chunks/index.4bca734e.js";import{H as Q}from"../chunks/Heading.723dceba.js";function me(V){let c,x,$,P,h,L,p,X=`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>.`,M,u,Y=`The first approach, the so-called “git-based” approach, is led by the <a href="/docs/huggingface_hub/v0.18.0.rc0/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/v0.18.0.rc0/en/package_reference/hf_api#huggingface_hub.HfApi">HfApi</a> client. Let’s examine the pros and cons
of each approach.`,A,f,q,d,Z=`At first, <code>huggingface_hub</code> was mostly built around the <a href="/docs/huggingface_hub/v0.18.0.rc0/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.`,R,g,ee=`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.`,C,m,te=`The main advantage of using a <a href="/docs/huggingface_hub/v0.18.0.rc0/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.`,I,b,S,y,ae=`The <a href="/docs/huggingface_hub/v0.18.0.rc0/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/v0.18.0.rc0/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.`,E,_,ie=`In addition to the functionalities already provided by <code>git</code>, the <a href="/docs/huggingface_hub/v0.18.0.rc0/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.`,W,v,z,w,ne=`Overall, the <strong>HTTP-based approach is the recommended way to use</strong> <code>huggingface_hub</code>
in most cases. However, there are a few situations where maintaining a local git clone
(using <a href="/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/repository#huggingface_hub.Repository">Repository</a>) may be more beneficial:`,G,T,oe=`<li>If you are training a model on your machine, it may be more efficient to use a traditional
git-based workflow, pushing regular updates. <a href="/docs/huggingface_hub/v0.18.0.rc0/en/package_reference/repository#huggingface_hub.Repository">Repository</a> is optimized for this type of
situation with its ability to work in the background.</li> <li>If you need to manually edit large files, <code>git</code> is the best option as it only sends the
diff to the server. With the <code>HfAPI</code> client, the entire file is uploaded with each edit.
Do keep in mind that most large files are binary so do not benefit from git diffs anyway.</li>`,j,H,se=`Not all git commands are available through <a href="/docs/huggingface_hub/v0.18.0.rc0/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.`,U,k,D;return h=new Q({props:{title:"Git vs HTTP paradigm",local:"git-vs-http-paradigm",headingTag:"h1"}}),f=new Q({props:{title:"Repository: the historical git-based approach",local:"repository-the-historical-git-based-approach",headingTag:"h2"}}),b=new Q({props:{title:"HfApi: a flexible and convenient HTTP client",local:"hfapi-a-flexible-and-convenient-http-client",headingTag:"h2"}}),v=new Q({props:{title:"What should I use ? And when ?",local:"what-should-i-use--and-when-",headingTag:"h2"}}),{c(){c=s("meta"),x=n(),$=s("p"),P=n(),F(h.$$.fragment),L=n(),p=s("p"),p.innerHTML=X,M=n(),u=s("p"),u.innerHTML=Y,A=n(),F(f.$$.fragment),q=n(),d=s("p"),d.innerHTML=Z,R=n(),g=s("p"),g.textContent=ee,C=n(),m=s("p"),m.innerHTML=te,I=n(),F(b.$$.fragment),S=n(),y=s("p"),y.innerHTML=ae,E=n(),_=s("p"),_.innerHTML=ie,W=n(),F(v.$$.fragment),z=n(),w=s("p"),w.innerHTML=ne,G=n(),T=s("ul"),T.innerHTML=oe,j=n(),H=s("p"),H.innerHTML=se,U=n(),k=s("p"),this.h()},l(e){const t=de("svelte-u9bgzb",document.head);c=r(t,"META",{name:!0,content:!0}),t.forEach(a),x=o(e),$=r(e,"P",{}),re($).forEach(a),P=o(e),N(h.$$.fragment,e),L=o(e),p=r(e,"P",{"data-svelte-h":!0}),l(p)!=="svelte-109fppz"&&(p.innerHTML=X),M=o(e),u=r(e,"P",{"data-svelte-h":!0}),l(u)!=="svelte-g158cr"&&(u.innerHTML=Y),A=o(e),N(f.$$.fragment,e),q=o(e),d=r(e,"P",{"data-svelte-h":!0}),l(d)!=="svelte-vkncul"&&(d.innerHTML=Z),R=o(e),g=r(e,"P",{"data-svelte-h":!0}),l(g)!=="svelte-mpix11"&&(g.textContent=ee),C=o(e),m=r(e,"P",{"data-svelte-h":!0}),l(m)!=="svelte-hk9p6e"&&(m.innerHTML=te),I=o(e),N(b.$$.fragment,e),S=o(e),y=r(e,"P",{"data-svelte-h":!0}),l(y)!=="svelte-grssqq"&&(y.innerHTML=ae),E=o(e),_=r(e,"P",{"data-svelte-h":!0}),l(_)!=="svelte-x8qk33"&&(_.innerHTML=ie),W=o(e),N(v.$$.fragment,e),z=o(e),w=r(e,"P",{"data-svelte-h":!0}),l(w)!=="svelte-irqkaj"&&(w.innerHTML=ne),G=o(e),T=r(e,"UL",{"data-svelte-h":!0}),l(T)!=="svelte-18vnhys"&&(T.innerHTML=oe),j=o(e),H=r(e,"P",{"data-svelte-h":!0}),l(H)!=="svelte-12bet2i"&&(H.innerHTML=se),U=o(e),k=r(e,"P",{}),re(k).forEach(a),this.h()},h(){le(c,"name","hf:doc:metadata"),le(c,"content",be)},m(e,t){ge(document.head,c),i(e,x,t),i(e,$,t),i(e,P,t),O(h,e,t),i(e,L,t),i(e,p,t),i(e,M,t),i(e,u,t),i(e,A,t),O(f,e,t),i(e,q,t),i(e,d,t),i(e,R,t),i(e,g,t),i(e,C,t),i(e,m,t),i(e,I,t),O(b,e,t),i(e,S,t),i(e,y,t),i(e,E,t),i(e,_,t),i(e,W,t),O(v,e,t),i(e,z,t),i(e,w,t),i(e,G,t),i(e,T,t),i(e,j,t),i(e,H,t),i(e,U,t),i(e,k,t),D=!0},p:he,i(e){D||(B(h.$$.fragment,e),B(f.$$.fragment,e),B(b.$$.fragment,e),B(v.$$.fragment,e),D=!0)},o(e){J(h.$$.fragment,e),J(f.$$.fragment,e),J(b.$$.fragment,e),J(v.$$.fragment,e),D=!1},d(e){e&&(a(x),a($),a(P),a(L),a(p),a(M),a(u),a(A),a(q),a(d),a(R),a(g),a(C),a(m),a(I),a(S),a(y),a(E),a(_),a(W),a(z),a(w),a(G),a(T),a(j),a(H),a(U),a(k)),a(c),K(h,e),K(f,e),K(b,e),K(v,e)}}}const be='{"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 ye(V){return pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Te extends ue{constructor(c){super(),fe(this,c,ye,me,ce,{})}}export{Te as component};
