import{s as me,o as ce,n as pe}from"../chunks/scheduler.6062bdaf.js";import{S as ge,i as fe,g as f,s as r,r as y,A as he,h,f as t,c as i,j as X,u as b,x as I,k as L,y as g,a as m,v as _,d as $,t as v,w}from"../chunks/index.4bca734e.js";import{D as A}from"../chunks/Docstring.d7918b6d.js";import{C as ue}from"../chunks/CodeBlock.fa01571c.js";import{E as de}from"../chunks/ExampleCodeBlock.d27cbfa4.js";import{H as ie,E as ye}from"../chunks/EditOnGithub.74ab2baa.js";function be(W){let n,j="Usage:",d,c,p;return c=new ue({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhmRmlsZVN5c3RlbSUwQSUwQWZzJTIwJTNEJTIwSGZGaWxlU3lzdGVtKCklMEElMEElMjMlMjBMaXN0JTIwZmlsZXMlMEFmcy5nbG9iKCUyMm15LXVzZXJuYW1lJTJGbXktbW9kZWwlMkYqLmJpbiUyMiklMEFmcy5scyglMjJkYXRhc2V0cyUyRm15LXVzZXJuYW1lJTJGbXktZGF0YXNldCUyMiUyQyUyMGRldGFpbCUzREZhbHNlKSUwQSUwQSUyMyUyMFJlYWQlMkZ3cml0ZSUyMGZpbGVzJTBBd2l0aCUyMGZzLm9wZW4oJTIybXktdXNlcm5hbWUlMkZteS1tb2RlbCUyRnB5dG9yY2hfbW9kZWwuYmluJTIyKSUyMGFzJTIwZiUzQSUwQSUyMCUyMCUyMCUyMGRhdGElMjAlM0QlMjBmLnJlYWQoKSUwQXdpdGglMjBmcy5vcGVuKCUyMm15LXVzZXJuYW1lJTJGbXktbW9kZWwlMkZweXRvcmNoX21vZGVsLmJpbiUyMiUyQyUyMCUyMndiJTIyKSUyMGFzJTIwZiUzQSUwQSUyMCUyMCUyMCUyMGYud3JpdGUoZGF0YSk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HfFileSystem

<span class="hljs-meta">&gt;&gt;&gt; </span>fs = HfFileSystem()

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># List files</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>fs.glob(<span class="hljs-string">&quot;my-username/my-model/*.bin&quot;</span>)
[<span class="hljs-string">&#x27;my-username/my-model/pytorch_model.bin&#x27;</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>fs.ls(<span class="hljs-string">&quot;datasets/my-username/my-dataset&quot;</span>, detail=<span class="hljs-literal">False</span>)
[<span class="hljs-string">&#x27;datasets/my-username/my-dataset/.gitattributes&#x27;</span>, <span class="hljs-string">&#x27;datasets/my-username/my-dataset/README.md&#x27;</span>, <span class="hljs-string">&#x27;datasets/my-username/my-dataset/data.json&#x27;</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Read/write files</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> fs.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;my-username/my-model/pytorch_model.bin&quot;</span>) <span class="hljs-keyword">as</span> f:
<span class="hljs-meta">... </span>    data = f.read()
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> fs.<span class="hljs-built_in">open</span>(<span class="hljs-string">&quot;my-username/my-model/pytorch_model.bin&quot;</span>, <span class="hljs-string">&quot;wb&quot;</span>) <span class="hljs-keyword">as</span> f:
<span class="hljs-meta">... </span>    f.write(data)`,wrap:!1}}),{c(){n=f("p"),n.textContent=j,d=r(),y(c.$$.fragment)},l(a){n=h(a,"P",{"data-svelte-h":!0}),I(n)!=="svelte-5wyjqd"&&(n.textContent=j),d=i(a),b(c.$$.fragment,a)},m(a,u){m(a,n,u),m(a,d,u),_(c,a,u),p=!0},p:pe,i(a){p||($(c.$$.fragment,a),p=!0)},o(a){v(c.$$.fragment,a),p=!1},d(a){a&&(t(n),t(d)),w(c,a)}}}function _e(W){let n,j,d,c,p,a,u,se='The <code>HfFileSystem</code> class provides a pythonic file interface to the Hugging Face Hub based on <a href="https://filesystem-spec.readthedocs.io/en/latest/" rel="nofollow"><code>fsspec</code></a>.',P,k,Q,S,ae='<code>HfFileSystem</code> is based on <a href="https://filesystem-spec.readthedocs.io/en/latest/" rel="nofollow">fsspec</a>, so it is compatible with most of the APIs that it offers. For more details, check out <a href="../guides/hf_file_system">our guide</a> and fsspec’s <a href="https://filesystem-spec.readthedocs.io/en/latest/api.html#fsspec.spec.AbstractFileSystem" rel="nofollow">API Reference</a>.',R,l,x,D,J,ne="Access a remote Hugging Face Hub repository as if were a local file system.",B,M,K,Z,F,O,E,C,ee,U,G,te,T,le="List the contents of a directory.",Y,H,z,q,V;return p=new ie({props:{title:"Filesystem API",local:"filesystem-api",headingTag:"h1"}}),k=new ie({props:{title:"HfFileSystem",local:"huggingface_hub.HfFileSystem",headingTag:"h2"}}),x=new A({props:{name:"class huggingface_hub.HfFileSystem",anchor:"huggingface_hub.HfFileSystem",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"huggingface_hub.HfFileSystem.token",description:`<strong>token</strong> (<code>str</code> or <code>bool</code>, <em>optional</em>) &#x2014;
A valid user access token (string). Defaults to the locally saved
token, which is the recommended method for authentication (see
<a href="https://huggingface.co/docs/huggingface_hub/quick-start#authentication" rel="nofollow">https://huggingface.co/docs/huggingface_hub/quick-start#authentication</a>).
To disable authentication, pass <code>False</code>.`,name:"token"}],source:"https://github.com/huggingface/huggingface_hub/blob/vr_2320/src/huggingface_hub/hf_file_system.py#L72"}}),M=new de({props:{anchor:"huggingface_hub.HfFileSystem.example",$$slots:{default:[be]},$$scope:{ctx:W}}}),F=new A({props:{name:"__init__",anchor:"huggingface_hub.HfFileSystem.__init__",parameters:[{name:"*args",val:""},{name:"endpoint",val:": Optional = None"},{name:"token",val:": Union = None"},{name:"**storage_options",val:""}],source:"https://github.com/huggingface/huggingface_hub/blob/vr_2320/src/huggingface_hub/hf_file_system.py#L107"}}),C=new A({props:{name:"resolve_path",anchor:"huggingface_hub.HfFileSystem.resolve_path",parameters:[{name:"path",val:": str"},{name:"revision",val:": Optional = None"}],source:"https://github.com/huggingface/huggingface_hub/blob/vr_2320/src/huggingface_hub/hf_file_system.py#L142"}}),G=new A({props:{name:"ls",anchor:"huggingface_hub.HfFileSystem.ls",parameters:[{name:"path",val:": str"},{name:"detail",val:": bool = True"},{name:"refresh",val:": bool = False"},{name:"revision",val:": Optional = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/huggingface_hub/blob/vr_2320/src/huggingface_hub/hf_file_system.py#L283"}}),H=new ye({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/package_reference/hf_file_system.md"}}),{c(){n=f("meta"),j=r(),d=f("p"),c=r(),y(p.$$.fragment),a=r(),u=f("p"),u.innerHTML=se,P=r(),y(k.$$.fragment),Q=r(),S=f("p"),S.innerHTML=ae,R=r(),l=f("div"),y(x.$$.fragment),D=r(),J=f("p"),J.textContent=ne,B=r(),y(M.$$.fragment),K=r(),Z=f("div"),y(F.$$.fragment),O=r(),E=f("div"),y(C.$$.fragment),ee=r(),U=f("div"),y(G.$$.fragment),te=r(),T=f("p"),T.textContent=le,Y=r(),y(H.$$.fragment),z=r(),q=f("p"),this.h()},l(e){const s=he("svelte-u9bgzb",document.head);n=h(s,"META",{name:!0,content:!0}),s.forEach(t),j=i(e),d=h(e,"P",{}),X(d).forEach(t),c=i(e),b(p.$$.fragment,e),a=i(e),u=h(e,"P",{"data-svelte-h":!0}),I(u)!=="svelte-em1lpf"&&(u.innerHTML=se),P=i(e),b(k.$$.fragment,e),Q=i(e),S=h(e,"P",{"data-svelte-h":!0}),I(S)!=="svelte-1c4o3of"&&(S.innerHTML=ae),R=i(e),l=h(e,"DIV",{class:!0});var o=X(l);b(x.$$.fragment,o),D=i(o),J=h(o,"P",{"data-svelte-h":!0}),I(J)!=="svelte-xq4u8v"&&(J.textContent=ne),B=i(o),b(M.$$.fragment,o),K=i(o),Z=h(o,"DIV",{class:!0});var oe=X(Z);b(F.$$.fragment,oe),oe.forEach(t),O=i(o),E=h(o,"DIV",{class:!0});var re=X(E);b(C.$$.fragment,re),re.forEach(t),ee=i(o),U=h(o,"DIV",{class:!0});var N=X(U);b(G.$$.fragment,N),te=i(N),T=h(N,"P",{"data-svelte-h":!0}),I(T)!=="svelte-f8hcny"&&(T.textContent=le),N.forEach(t),o.forEach(t),Y=i(e),b(H.$$.fragment,e),z=i(e),q=h(e,"P",{}),X(q).forEach(t),this.h()},h(){L(n,"name","hf:doc:metadata"),L(n,"content",$e),L(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),L(l,"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,s){g(document.head,n),m(e,j,s),m(e,d,s),m(e,c,s),_(p,e,s),m(e,a,s),m(e,u,s),m(e,P,s),_(k,e,s),m(e,Q,s),m(e,S,s),m(e,R,s),m(e,l,s),_(x,l,null),g(l,D),g(l,J),g(l,B),_(M,l,null),g(l,K),g(l,Z),_(F,Z,null),g(l,O),g(l,E),_(C,E,null),g(l,ee),g(l,U),_(G,U,null),g(U,te),g(U,T),m(e,Y,s),_(H,e,s),m(e,z,s),m(e,q,s),V=!0},p(e,[s]){const o={};s&2&&(o.$$scope={dirty:s,ctx:e}),M.$set(o)},i(e){V||($(p.$$.fragment,e),$(k.$$.fragment,e),$(x.$$.fragment,e),$(M.$$.fragment,e),$(F.$$.fragment,e),$(C.$$.fragment,e),$(G.$$.fragment,e),$(H.$$.fragment,e),V=!0)},o(e){v(p.$$.fragment,e),v(k.$$.fragment,e),v(x.$$.fragment,e),v(M.$$.fragment,e),v(F.$$.fragment,e),v(C.$$.fragment,e),v(G.$$.fragment,e),v(H.$$.fragment,e),V=!1},d(e){e&&(t(j),t(d),t(c),t(a),t(u),t(P),t(Q),t(S),t(R),t(l),t(Y),t(z),t(q)),t(n),w(p,e),w(k,e),w(x),w(M),w(F),w(C),w(G),w(H,e)}}}const $e='{"title":"Filesystem API","local":"filesystem-api","sections":[{"title":"HfFileSystem","local":"huggingface_hub.HfFileSystem","sections":[],"depth":2}],"depth":1}';function ve(W){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends ge{constructor(n){super(),fe(this,n,ve,_e,me,{})}}export{xe as component};
