import{s as me,o as pe,n as ce}from"../chunks/scheduler.6062bdaf.js";import{S as ge,i as fe,g as f,s as o,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 N}from"../chunks/Docstring.81ba5e3c.js";import{C as de}from"../chunks/CodeBlock.fa01571c.js";import{E as ue}from"../chunks/ExampleCodeBlock.30e7542f.js";import{H as ie,E as ye}from"../chunks/EditOnGithub.74ab2baa.js";function be(P){let n,j="Usage:",u,p,c;return p=new de({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,u=o(),y(p.$$.fragment)},l(a){n=h(a,"P",{"data-svelte-h":!0}),I(n)!=="svelte-5wyjqd"&&(n.textContent=j),u=i(a),b(p.$$.fragment,a)},m(a,d){m(a,n,d),m(a,u,d),$(p,a,d),c=!0},p:ce,i(a){c||(_(p.$$.fragment,a),c=!0)},o(a){v(p.$$.fragment,a),c=!1},d(a){a&&(t(n),t(u)),w(p,a)}}}function $e(P){let n,j,u,p,c,a,d,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>.',q,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,B,J,ne="Access a remote Hugging Face Hub repository as if were a local file system.",D,M,K,Z,F,O,E,C,ee,U,G,te,T,le="List the contents of a directory.",Y,H,z,W,V;return c=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 N({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>, <em>optional</em>) &#x2014;
Authentication token, obtained with <code>HfApi.login</code> method. Will default to the stored token.`,name:"token"}],source:"https://github.com/huggingface/huggingface_hub/blob/v0.23.0/src/huggingface_hub/hf_file_system.py#L72"}}),M=new ue({props:{anchor:"huggingface_hub.HfFileSystem.example",$$slots:{default:[be]},$$scope:{ctx:P}}}),F=new N({props:{name:"__init__",anchor:"huggingface_hub.HfFileSystem.__init__",parameters:[{name:"*args",val:""},{name:"endpoint",val:": Optional = None"},{name:"token",val:": Optional = None"},{name:"**storage_options",val:""}],source:"https://github.com/huggingface/huggingface_hub/blob/v0.23.0/src/huggingface_hub/hf_file_system.py#L104"}}),C=new N({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/v0.23.0/src/huggingface_hub/hf_file_system.py#L139"}}),G=new N({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/v0.23.0/src/huggingface_hub/hf_file_system.py#L280"}}),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=o(),u=f("p"),p=o(),y(c.$$.fragment),a=o(),d=f("p"),d.innerHTML=se,q=o(),y(k.$$.fragment),Q=o(),S=f("p"),S.innerHTML=ae,R=o(),l=f("div"),y(x.$$.fragment),B=o(),J=f("p"),J.textContent=ne,D=o(),y(M.$$.fragment),K=o(),Z=f("div"),y(F.$$.fragment),O=o(),E=f("div"),y(C.$$.fragment),ee=o(),U=f("div"),y(G.$$.fragment),te=o(),T=f("p"),T.textContent=le,Y=o(),y(H.$$.fragment),z=o(),W=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),u=h(e,"P",{}),X(u).forEach(t),p=i(e),b(c.$$.fragment,e),a=i(e),d=h(e,"P",{"data-svelte-h":!0}),I(d)!=="svelte-em1lpf"&&(d.innerHTML=se),q=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 r=X(l);b(x.$$.fragment,r),B=i(r),J=h(r,"P",{"data-svelte-h":!0}),I(J)!=="svelte-xq4u8v"&&(J.textContent=ne),D=i(r),b(M.$$.fragment,r),K=i(r),Z=h(r,"DIV",{class:!0});var re=X(Z);b(F.$$.fragment,re),re.forEach(t),O=i(r),E=h(r,"DIV",{class:!0});var oe=X(E);b(C.$$.fragment,oe),oe.forEach(t),ee=i(r),U=h(r,"DIV",{class:!0});var A=X(U);b(G.$$.fragment,A),te=i(A),T=h(A,"P",{"data-svelte-h":!0}),I(T)!=="svelte-f8hcny"&&(T.textContent=le),A.forEach(t),r.forEach(t),Y=i(e),b(H.$$.fragment,e),z=i(e),W=h(e,"P",{}),X(W).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,u,s),m(e,p,s),$(c,e,s),m(e,a,s),m(e,d,s),m(e,q,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,B),g(l,J),g(l,D),$(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,W,s),V=!0},p(e,[s]){const r={};s&2&&(r.$$scope={dirty:s,ctx:e}),M.$set(r)},i(e){V||(_(c.$$.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(c.$$.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(u),t(p),t(a),t(d),t(q),t(Q),t(S),t(R),t(l),t(Y),t(z),t(W)),t(n),w(c,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(P){return pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends ge{constructor(n){super(),fe(this,n,ve,$e,me,{})}}export{xe as component};
