import{s as Re,o as We,n as Ne}from"../chunks/scheduler.6062bdaf.js";import{S as Be,i as Ge,g,s as o,r as b,A as Je,h as l,f as n,c as i,j as Z,u as $,x as d,k as ee,y as r,a as s,v as w,d as v,t as k,w as x}from"../chunks/index.4bca734e.js";import{T as Ae}from"../chunks/Tip.b9ac1f03.js";import{D as pe}from"../chunks/Docstring.ed07512f.js";import{H as ne}from"../chunks/Heading.723dceba.js";function Ke(S){let a,T=`<a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a> is a drop-in replacement method for <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.notebook_login">notebook_login()</a> as it wraps and
extends its capabilities.`;return{c(){a=g("p"),a.innerHTML=T},l(c){a=l(c,"P",{"data-svelte-h":!0}),d(a)!=="svelte-1ag0ewy"&&(a.innerHTML=T)},m(c,y){s(c,a,y)},p:Ne,d(c){c&&n(a)}}}function Qe(S){let a,T=`When the token is not passed, <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a> will automatically detect if the script runs
in a notebook or not. However, this detection might not be accurate due to the
variety of notebooks that exists nowadays. If that is the case, you can always force
the UI by using <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.notebook_login">notebook_login()</a> or <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.interpreter_login">interpreter_login()</a>.`;return{c(){a=g("p"),a.innerHTML=T},l(c){a=l(c,"P",{"data-svelte-h":!0}),d(a)!=="svelte-w2i80j"&&(a.innerHTML=T)},m(c,y){s(c,a,y)},p:Ne,d(c){c&&n(a)}}}function Xe(S){let a,T,c,y,I,oe,M,Ie="The <code>huggingface_hub</code> library allows users to programmatically login and logout the machine to the Hub.",ie,P,Me='For more details about authentication, check out <a href="../quick-start#authentication">this section</a>.',ae,E,re,u,F,me,U,Pe="Login the machine to access the Hub.",_e,A,Ee=`The <code>token</code> is persisted in cache and set as a git credential. Once done, the machine
is logged in and the access token will be available across all <code>huggingface_hub</code>
components. If <code>token</code> is not provided, it will be prompted to the user either with
a widget (in a notebook) or via the terminal.`,be,N,Fe=`To login from outside of a script, one can also use <code>huggingface-cli login</code> which is
a cli command that wraps <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a>.`,$e,L,we,H,se,D,ge,f,q,ve,R,De="Displays a prompt to login to the HF website and store the token.",ke,W,qe=`This is equivalent to <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a> without passing a token when not run in a notebook.
<a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.interpreter_login">interpreter_login()</a> is useful if you want to force the use of the terminal prompt
instead of a notebook widget.`,xe,B,Ve='For more details, see <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a>.',le,V,ce,p,z,Te,G,ze="Displays a widget to login to the HF website and store the token.",ye,J,je=`This is equivalent to <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a> without passing a token when run in a notebook.
<a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.notebook_login">notebook_login()</a> is useful if you want to force the use of the notebook widget
instead of a prompt in the terminal.`,Le,K,Oe='For more details, see <a href="/docs/huggingface_hub/main/en/package_reference/login#huggingface_hub.login">login()</a>.',ue,j,he,m,O,He,Q,Se="Logout the machine from the Hub.",Ce,X,Ue="Token is deleted from the machine and removed from git credential.",de,te,fe;return I=new ne({props:{title:"Login and logout",local:"login-and-logout",headingTag:"h1"}}),E=new ne({props:{title:"login",local:"huggingface_hub.login",headingTag:"h2"}}),F=new pe({props:{name:"huggingface_hub.login",anchor:"huggingface_hub.login",parameters:[{name:"token",val:": typing.Optional[str] = None"},{name:"add_to_git_credential",val:": bool = False"},{name:"new_session",val:": bool = True"},{name:"write_permission",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.login.token",description:`<strong>token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
User access token to generate from <a href="https://huggingface.co/settings/token" rel="nofollow">https://huggingface.co/settings/token</a>.`,name:"token"},{anchor:"huggingface_hub.login.add_to_git_credential",description:`<strong>add_to_git_credential</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, token will be set as git credential. If no git credential helper
is configured, a warning will be displayed to the user. If <code>token</code> is <code>None</code>,
the value of <code>add_to_git_credential</code> is ignored and will be prompted again
to the end user.`,name:"add_to_git_credential"},{anchor:"huggingface_hub.login.new_session",description:`<strong>new_session</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, will request a token even if one is already saved on the machine.`,name:"new_session"},{anchor:"huggingface_hub.login.write_permission",description:`<strong>write_permission</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, requires a token with write permission.`,name:"write_permission"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L49",raiseDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<ul>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ValueError"
  rel="nofollow"
><code>ValueError</code></a> —
If an organization token is passed. Only personal account tokens are valid
to login.</li>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ValueError"
  rel="nofollow"
><code>ValueError</code></a> —
If token is invalid.</li>
<li><a
  href="https://docs.python.org/3/library/exceptions.html#ImportError"
  rel="nofollow"
><code>ImportError</code></a> —
If running in a notebook but <code>ipywidgets</code> is not installed.</li>
</ul>
`,raiseType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>ValueError</code> or <code>ImportError</code></p>
`}}),L=new Ae({props:{$$slots:{default:[Ke]},$$scope:{ctx:S}}}),H=new Ae({props:{$$slots:{default:[Qe]},$$scope:{ctx:S}}}),D=new ne({props:{title:"interpreter_login",local:"huggingface_hub.interpreter_login",headingTag:"h2"}}),q=new pe({props:{name:"huggingface_hub.interpreter_login",anchor:"huggingface_hub.interpreter_login",parameters:[{name:"new_session",val:": bool = True"},{name:"write_permission",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.interpreter_login.new_session",description:`<strong>new_session</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, will request a token even if one is already saved on the machine.`,name:"new_session"},{anchor:"huggingface_hub.interpreter_login.write_permission",description:`<strong>write_permission</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, requires a token with write permission.`,name:"write_permission"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L154"}}),V=new ne({props:{title:"notebook_login",local:"huggingface_hub.notebook_login",headingTag:"h2"}}),z=new pe({props:{name:"huggingface_hub.notebook_login",anchor:"huggingface_hub.notebook_login",parameters:[{name:"new_session",val:": bool = True"},{name:"write_permission",val:": bool = False"}],parametersDescription:[{anchor:"huggingface_hub.notebook_login.new_session",description:`<strong>new_session</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
If <code>True</code>, will request a token even if one is already saved on the machine.`,name:"new_session"},{anchor:"huggingface_hub.notebook_login.write_permission",description:`<strong>write_permission</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, requires a token with write permission.`,name:"write_permission"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L219"}}),j=new ne({props:{title:"logout",local:"huggingface_hub.logout",headingTag:"h2"}}),O=new pe({props:{name:"huggingface_hub.logout",anchor:"huggingface_hub.logout",parameters:[],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_login.py#L116"}}),{c(){a=g("meta"),T=o(),c=g("p"),y=o(),b(I.$$.fragment),oe=o(),M=g("p"),M.innerHTML=Ie,ie=o(),P=g("p"),P.innerHTML=Me,ae=o(),b(E.$$.fragment),re=o(),u=g("div"),b(F.$$.fragment),me=o(),U=g("p"),U.textContent=Pe,_e=o(),A=g("p"),A.innerHTML=Ee,be=o(),N=g("p"),N.innerHTML=Fe,$e=o(),b(L.$$.fragment),we=o(),b(H.$$.fragment),se=o(),b(D.$$.fragment),ge=o(),f=g("div"),b(q.$$.fragment),ve=o(),R=g("p"),R.textContent=De,ke=o(),W=g("p"),W.innerHTML=qe,xe=o(),B=g("p"),B.innerHTML=Ve,le=o(),b(V.$$.fragment),ce=o(),p=g("div"),b(z.$$.fragment),Te=o(),G=g("p"),G.textContent=ze,ye=o(),J=g("p"),J.innerHTML=je,Le=o(),K=g("p"),K.innerHTML=Oe,ue=o(),b(j.$$.fragment),he=o(),m=g("div"),b(O.$$.fragment),He=o(),Q=g("p"),Q.textContent=Se,Ce=o(),X=g("p"),X.textContent=Ue,de=o(),te=g("p"),this.h()},l(e){const t=Je("svelte-u9bgzb",document.head);a=l(t,"META",{name:!0,content:!0}),t.forEach(n),T=i(e),c=l(e,"P",{}),Z(c).forEach(n),y=i(e),$(I.$$.fragment,e),oe=i(e),M=l(e,"P",{"data-svelte-h":!0}),d(M)!=="svelte-1d46tyn"&&(M.innerHTML=Ie),ie=i(e),P=l(e,"P",{"data-svelte-h":!0}),d(P)!=="svelte-pa4dpn"&&(P.innerHTML=Me),ae=i(e),$(E.$$.fragment,e),re=i(e),u=l(e,"DIV",{class:!0});var h=Z(u);$(F.$$.fragment,h),me=i(h),U=l(h,"P",{"data-svelte-h":!0}),d(U)!=="svelte-h0rxjs"&&(U.textContent=Pe),_e=i(h),A=l(h,"P",{"data-svelte-h":!0}),d(A)!=="svelte-1m8kult"&&(A.innerHTML=Ee),be=i(h),N=l(h,"P",{"data-svelte-h":!0}),d(N)!=="svelte-1v57n7z"&&(N.innerHTML=Fe),$e=i(h),$(L.$$.fragment,h),we=i(h),$(H.$$.fragment,h),h.forEach(n),se=i(e),$(D.$$.fragment,e),ge=i(e),f=l(e,"DIV",{class:!0});var _=Z(f);$(q.$$.fragment,_),ve=i(_),R=l(_,"P",{"data-svelte-h":!0}),d(R)!=="svelte-17ujnkh"&&(R.textContent=De),ke=i(_),W=l(_,"P",{"data-svelte-h":!0}),d(W)!=="svelte-oxcptm"&&(W.innerHTML=qe),xe=i(_),B=l(_,"P",{"data-svelte-h":!0}),d(B)!=="svelte-a7n1vs"&&(B.innerHTML=Ve),_.forEach(n),le=i(e),$(V.$$.fragment,e),ce=i(e),p=l(e,"DIV",{class:!0});var C=Z(p);$(z.$$.fragment,C),Te=i(C),G=l(C,"P",{"data-svelte-h":!0}),d(G)!=="svelte-sme73"&&(G.textContent=ze),ye=i(C),J=l(C,"P",{"data-svelte-h":!0}),d(J)!=="svelte-1tdfl0z"&&(J.innerHTML=je),Le=i(C),K=l(C,"P",{"data-svelte-h":!0}),d(K)!=="svelte-a7n1vs"&&(K.innerHTML=Oe),C.forEach(n),ue=i(e),$(j.$$.fragment,e),he=i(e),m=l(e,"DIV",{class:!0});var Y=Z(m);$(O.$$.fragment,Y),He=i(Y),Q=l(Y,"P",{"data-svelte-h":!0}),d(Q)!=="svelte-1462z46"&&(Q.textContent=Se),Ce=i(Y),X=l(Y,"P",{"data-svelte-h":!0}),d(X)!=="svelte-1x6nsdy"&&(X.textContent=Ue),Y.forEach(n),de=i(e),te=l(e,"P",{}),Z(te).forEach(n),this.h()},h(){ee(a,"name","hf:doc:metadata"),ee(a,"content",Ye),ee(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),ee(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,t){r(document.head,a),s(e,T,t),s(e,c,t),s(e,y,t),w(I,e,t),s(e,oe,t),s(e,M,t),s(e,ie,t),s(e,P,t),s(e,ae,t),w(E,e,t),s(e,re,t),s(e,u,t),w(F,u,null),r(u,me),r(u,U),r(u,_e),r(u,A),r(u,be),r(u,N),r(u,$e),w(L,u,null),r(u,we),w(H,u,null),s(e,se,t),w(D,e,t),s(e,ge,t),s(e,f,t),w(q,f,null),r(f,ve),r(f,R),r(f,ke),r(f,W),r(f,xe),r(f,B),s(e,le,t),w(V,e,t),s(e,ce,t),s(e,p,t),w(z,p,null),r(p,Te),r(p,G),r(p,ye),r(p,J),r(p,Le),r(p,K),s(e,ue,t),w(j,e,t),s(e,he,t),s(e,m,t),w(O,m,null),r(m,He),r(m,Q),r(m,Ce),r(m,X),s(e,de,t),s(e,te,t),fe=!0},p(e,[t]){const h={};t&2&&(h.$$scope={dirty:t,ctx:e}),L.$set(h);const _={};t&2&&(_.$$scope={dirty:t,ctx:e}),H.$set(_)},i(e){fe||(v(I.$$.fragment,e),v(E.$$.fragment,e),v(F.$$.fragment,e),v(L.$$.fragment,e),v(H.$$.fragment,e),v(D.$$.fragment,e),v(q.$$.fragment,e),v(V.$$.fragment,e),v(z.$$.fragment,e),v(j.$$.fragment,e),v(O.$$.fragment,e),fe=!0)},o(e){k(I.$$.fragment,e),k(E.$$.fragment,e),k(F.$$.fragment,e),k(L.$$.fragment,e),k(H.$$.fragment,e),k(D.$$.fragment,e),k(q.$$.fragment,e),k(V.$$.fragment,e),k(z.$$.fragment,e),k(j.$$.fragment,e),k(O.$$.fragment,e),fe=!1},d(e){e&&(n(T),n(c),n(y),n(oe),n(M),n(ie),n(P),n(ae),n(re),n(u),n(se),n(ge),n(f),n(le),n(ce),n(p),n(ue),n(he),n(m),n(de),n(te)),n(a),x(I,e),x(E,e),x(F),x(L),x(H),x(D,e),x(q),x(V,e),x(z),x(j,e),x(O)}}}const Ye='{"title":"Login and logout","local":"login-and-logout","sections":[{"title":"login","local":"huggingface_hub.login","sections":[],"depth":2},{"title":"interpreter_login","local":"huggingface_hub.interpreter_login","sections":[],"depth":2},{"title":"notebook_login","local":"huggingface_hub.notebook_login","sections":[],"depth":2},{"title":"logout","local":"huggingface_hub.logout","sections":[],"depth":2}],"depth":1}';function Ze(S){return We(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class at extends Be{constructor(a){super(),Ge(this,a,Ze,Xe,Re,{})}}export{at as component};
