import{s as re,o as ie,n as me}from"../chunks/scheduler.6062bdaf.js";import{S as pe,i as ce,g as f,s as r,r as $,A as ge,h,f as t,c as i,j as E,u as _,x as I,k as X,y as g,a as m,v,d as w,t as M,w as U}from"../chunks/index.4bca734e.js";import{H as oe,g as fe}from"../chunks/Heading.949e2f88.js";import{D as V}from"../chunks/Docstring.5c2fc3ce.js";import{C as he}from"../chunks/CodeBlock.fa01571c.js";import{E as de}from"../chunks/ExampleCodeBlock.29b93798.js";function ue(W){let n,j="Usage:",u,p,c;return p=new he({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=r(),$(p.$$.fragment)},l(a){n=h(a,"P",{"data-svelte-h":!0}),I(n)!=="svelte-5wyjqd"&&(n.textContent=j),u=i(a),_(p.$$.fragment,a)},m(a,d){m(a,n,d),m(a,u,d),v(p,a,d),c=!0},p:me,i(a){c||(w(p.$$.fragment,a),c=!0)},o(a){M(p.$$.fragment,a),c=!1},d(a){a&&(t(n),t(u)),U(p,a)}}}function ye(W){let n,j,u,p,c,a,d,ee='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,S,q,k,te='<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>.',Q,l,x,A,H,se="Access a remote Hugging Face Hub repository as if were a local file system.",N,y,D,J,F,B,Z,C,K,b,G,O,T,ae="List the contents of a directory.",R,L,Y;return c=new oe({props:{title:"Filesystem API",local:"filesystem-api",headingTag:"h1"}}),S=new oe({props:{title:"HfFileSystem",local:"huggingface_hub.HfFileSystem",headingTag:"h2"}}),x=new V({props:{name:"class huggingface_hub.HfFileSystem",anchor:"huggingface_hub.HfFileSystem",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"huggingface_hub.HfFileSystem.endpoint",description:`<strong>endpoint</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The endpoint to use. If not provided, the default one (<a href="https://huggingface.co" rel="nofollow">https://huggingface.co</a>) is used.`,name:"endpoint"},{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.19.2/src/huggingface_hub/hf_file_system.py#L53"}}),y=new de({props:{anchor:"huggingface_hub.HfFileSystem.example",$$slots:{default:[ue]},$$scope:{ctx:W}}}),F=new V({props:{name:"__init__",anchor:"huggingface_hub.HfFileSystem.__init__",parameters:[{name:"*args",val:""},{name:"endpoint",val:": typing.Optional[str] = None"},{name:"token",val:": typing.Optional[str] = None"},{name:"**storage_options",val:""}],source:"https://github.com/huggingface/huggingface_hub/blob/v0.19.2/src/huggingface_hub/hf_file_system.py#L87"}}),C=new V({props:{name:"resolve_path",anchor:"huggingface_hub.HfFileSystem.resolve_path",parameters:[{name:"path",val:": str"},{name:"revision",val:": typing.Optional[str] = None"}],source:"https://github.com/huggingface/huggingface_hub/blob/v0.19.2/src/huggingface_hub/hf_file_system.py#L140"}}),G=new V({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:": typing.Optional[str] = None"},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/huggingface_hub/blob/v0.19.2/src/huggingface_hub/hf_file_system.py#L277"}}),{c(){n=f("meta"),j=r(),u=f("p"),p=r(),$(c.$$.fragment),a=r(),d=f("p"),d.innerHTML=ee,P=r(),$(S.$$.fragment),q=r(),k=f("p"),k.innerHTML=te,Q=r(),l=f("div"),$(x.$$.fragment),A=r(),H=f("p"),H.textContent=se,N=r(),$(y.$$.fragment),D=r(),J=f("div"),$(F.$$.fragment),B=r(),Z=f("div"),$(C.$$.fragment),K=r(),b=f("div"),$(G.$$.fragment),O=r(),T=f("p"),T.textContent=ae,R=r(),L=f("p"),this.h()},l(e){const s=ge("svelte-u9bgzb",document.head);n=h(s,"META",{name:!0,content:!0}),s.forEach(t),j=i(e),u=h(e,"P",{}),E(u).forEach(t),p=i(e),_(c.$$.fragment,e),a=i(e),d=h(e,"P",{"data-svelte-h":!0}),I(d)!=="svelte-em1lpf"&&(d.innerHTML=ee),P=i(e),_(S.$$.fragment,e),q=i(e),k=h(e,"P",{"data-svelte-h":!0}),I(k)!=="svelte-1c4o3of"&&(k.innerHTML=te),Q=i(e),l=h(e,"DIV",{class:!0});var o=E(l);_(x.$$.fragment,o),A=i(o),H=h(o,"P",{"data-svelte-h":!0}),I(H)!=="svelte-xq4u8v"&&(H.textContent=se),N=i(o),_(y.$$.fragment,o),D=i(o),J=h(o,"DIV",{class:!0});var ne=E(J);_(F.$$.fragment,ne),ne.forEach(t),B=i(o),Z=h(o,"DIV",{class:!0});var le=E(Z);_(C.$$.fragment,le),le.forEach(t),K=i(o),b=h(o,"DIV",{class:!0});var z=E(b);_(G.$$.fragment,z),O=i(z),T=h(z,"P",{"data-svelte-h":!0}),I(T)!=="svelte-f8hcny"&&(T.textContent=ae),z.forEach(t),o.forEach(t),R=i(e),L=h(e,"P",{}),E(L).forEach(t),this.h()},h(){X(n,"name","hf:doc:metadata"),X(n,"content",be),X(J,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),X(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),v(c,e,s),m(e,a,s),m(e,d,s),m(e,P,s),v(S,e,s),m(e,q,s),m(e,k,s),m(e,Q,s),m(e,l,s),v(x,l,null),g(l,A),g(l,H),g(l,N),v(y,l,null),g(l,D),g(l,J),v(F,J,null),g(l,B),g(l,Z),v(C,Z,null),g(l,K),g(l,b),v(G,b,null),g(b,O),g(b,T),m(e,R,s),m(e,L,s),Y=!0},p(e,[s]){const o={};s&2&&(o.$$scope={dirty:s,ctx:e}),y.$set(o)},i(e){Y||(w(c.$$.fragment,e),w(S.$$.fragment,e),w(x.$$.fragment,e),w(y.$$.fragment,e),w(F.$$.fragment,e),w(C.$$.fragment,e),w(G.$$.fragment,e),Y=!0)},o(e){M(c.$$.fragment,e),M(S.$$.fragment,e),M(x.$$.fragment,e),M(y.$$.fragment,e),M(F.$$.fragment,e),M(C.$$.fragment,e),M(G.$$.fragment,e),Y=!1},d(e){e&&(t(j),t(u),t(p),t(a),t(d),t(P),t(q),t(k),t(Q),t(l),t(R),t(L)),t(n),U(c,e),U(S,e),U(x),U(y),U(F),U(C),U(G)}}}const be='{"title":"Filesystem API","local":"filesystem-api","sections":[{"title":"HfFileSystem","local":"huggingface_hub.HfFileSystem","sections":[],"depth":2}],"depth":1}';function $e(W){return ie(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=fe}),[]}class Se extends pe{constructor(n){super(),ce(this,n,$e,ye,re,{})}}export{Se as component};
