import{s as oe,o as re,n as V}from"../chunks/scheduler.6062bdaf.js";import{S as se,i as ne,g as d,s as h,r as v,A as ie,h as f,f as r,c as p,j as P,u as T,x as J,k as R,y as w,a as g,v as x,d as H,t as k,w as W}from"../chunks/index.4bca734e.js";import{T as le}from"../chunks/Tip.b9ac1f03.js";import{D as ce}from"../chunks/Docstring.ed07512f.js";import{C as ae}from"../chunks/CodeBlock.fa01571c.js";import{E as ee}from"../chunks/ExampleCodeBlock.823fb173.js";import{H as te}from"../chunks/Heading.723dceba.js";function ge(y){let t,l="<code>HFSummaryWriter</code> is experimental. Its API is subject to change in the future without prior notice.";return{c(){t=d("p"),t.innerHTML=l},l(a){t=f(a,"P",{"data-svelte-h":!0}),J(t)!=="svelte-1jyxcko"&&(t.innerHTML=l)},m(a,i){g(a,t,i)},p:V,d(a){a&&r(t)}}}function he(y){let t,l="Examples:",a,i,u;return i=new ae({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhGU3VtbWFyeVdyaXRlciUwQSUwQWxvZ2dlciUyMCUzRCUyMEhGU3VtbWFyeVdyaXRlcihyZXBvX2lkJTNEJTIydGVzdF9oZl9sb2dnZXIlMjIlMkMlMjBjb21taXRfZXZlcnklM0QxNSklMEFsb2dnZXIuYWRkX3NjYWxhciglMjJhJTIyJTJDJTIwMSklMEFsb2dnZXIuYWRkX3NjYWxhciglMjJiJTIyJTJDJTIwMiklMEElMEFsb2dnZXIuc2NoZWR1bGVyLnRyaWdnZXIoKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HFSummaryWriter

<span class="hljs-comment"># Logs are automatically pushed every 15 minutes</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logger = HFSummaryWriter(repo_id=<span class="hljs-string">&quot;test_hf_logger&quot;</span>, commit_every=<span class="hljs-number">15</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logger.add_scalar(<span class="hljs-string">&quot;a&quot;</span>, <span class="hljs-number">1</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>logger.add_scalar(<span class="hljs-string">&quot;b&quot;</span>, <span class="hljs-number">2</span>)
...

<span class="hljs-comment"># You can also trigger a push manually</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>logger.scheduler.trigger()`,wrap:!1}}),{c(){t=d("p"),t.textContent=l,a=h(),v(i.$$.fragment)},l(s){t=f(s,"P",{"data-svelte-h":!0}),J(t)!=="svelte-kvfsh7"&&(t.textContent=l),a=p(s),T(i.$$.fragment,s)},m(s,m){g(s,t,m),g(s,a,m),x(i,s,m),u=!0},p:V,i(s){u||(H(i.$$.fragment,s),u=!0)},o(s){k(i.$$.fragment,s),u=!1},d(s){s&&(r(t),r(a)),W(i,s)}}}function pe(y){let t,l;return t=new ae({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhGU3VtbWFyeVdyaXRlciUwQSUwQXdpdGglMjBIRlN1bW1hcnlXcml0ZXIocmVwb19pZCUzRCUyMnRlc3RfaGZfbG9nZ2VyJTIyKSUyMGFzJTIwbG9nZ2VyJTNBJTBBJTIwJTIwJTIwJTIwbG9nZ2VyLmFkZF9zY2FsYXIoJTIyYSUyMiUyQyUyMDEpJTBBJTIwJTIwJTIwJTIwbG9nZ2VyLmFkZF9zY2FsYXIoJTIyYiUyMiUyQyUyMDIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> HFSummaryWriter

<span class="hljs-comment"># Logs are automatically pushed every 5 minutes (default) + when exiting the context manager</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> HFSummaryWriter(repo_id=<span class="hljs-string">&quot;test_hf_logger&quot;</span>) <span class="hljs-keyword">as</span> logger:
<span class="hljs-meta">... </span>    logger.add_scalar(<span class="hljs-string">&quot;a&quot;</span>, <span class="hljs-number">1</span>)
<span class="hljs-meta">... </span>    logger.add_scalar(<span class="hljs-string">&quot;b&quot;</span>, <span class="hljs-number">2</span>)`,wrap:!1}}),{c(){v(t.$$.fragment)},l(a){T(t.$$.fragment,a)},m(a,i){x(t,a,i),l=!0},p:V,i(a){l||(H(t.$$.fragment,a),l=!0)},o(a){k(t.$$.fragment,a),l=!1},d(a){W(t,a)}}}function ue(y){let t,l,a,i,u,s,m,z=`TensorBoard is a visualization toolkit for machine learning experimentation. TensorBoard allows tracking and visualizing
metrics such as loss and accuracy, visualizing the model graph, viewing histograms, displaying images and much more.
TensorBoard is well integrated with the Hugging Face Hub. The Hub automatically detects TensorBoard traces (such as
<code>tfevents</code>) when pushed to the Hub which starts an instance to visualize them. To get more information about TensorBoard
integration on the Hub, check out <a href="https://huggingface.co/docs/hub/tensorboard" rel="nofollow">this guide</a>.`,C,j,N=`To benefit from this integration, <code>huggingface_hub</code> provides a custom logger to push logs to the Hub. It works as a
drop-in replacement for <a href="https://tensorboardx.readthedocs.io/en/latest/tensorboard.html" rel="nofollow">SummaryWriter</a> with no extra
code needed. Traces are still saved locally and a background job push them to the Hub at regular interval.`,Z,F,q,n,S,L,M,Q="Wrapper around the tensorboard’s <code>SummaryWriter</code> to push training logs to the Hub.",E,I,A=`Data is logged locally and then pushed to the Hub asynchronously. Pushing data to the Hub is done in a separate
thread to avoid blocking the training script. In particular, if the upload fails for any reason (e.g. a connection
issue), the main script will not be interrupted. Data is automatically pushed to the Hub every <code>commit_every</code>
minutes (default to every 5 minutes).`,G,_,B,b,Y,$,X,U,D;return u=new te({props:{title:"TensorBoard logger",local:"tensorboard-logger",headingTag:"h1"}}),F=new te({props:{title:"HFSummaryWriter",local:"huggingface_hub.HFSummaryWriter",headingTag:"h2"}}),S=new ce({props:{name:"class huggingface_hub.HFSummaryWriter",anchor:"huggingface_hub.HFSummaryWriter",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"huggingface_hub.HFSummaryWriter.repo_id",description:`<strong>repo_id</strong> (<code>str</code>) &#x2014;
The id of the repo to which the logs will be pushed.`,name:"repo_id"},{anchor:"huggingface_hub.HFSummaryWriter.logdir",description:`<strong>logdir</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The directory where the logs will be written. If not specified, a local directory will be created by the
underlying <code>SummaryWriter</code> object.`,name:"logdir"},{anchor:"huggingface_hub.HFSummaryWriter.commit_every",description:`<strong>commit_every</strong> (<code>int</code> or <code>float</code>, <em>optional</em>) &#x2014;
The frequency (in minutes) at which the logs will be pushed to the Hub. Defaults to 5 minutes.`,name:"commit_every"},{anchor:"huggingface_hub.HFSummaryWriter.squash_history",description:`<strong>squash_history</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to squash the history of the repo after each commit. Defaults to <code>False</code>. Squashing commits is
useful to avoid degraded performances on the repo when it grows too large.`,name:"squash_history"},{anchor:"huggingface_hub.HFSummaryWriter.repo_type",description:`<strong>repo_type</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The type of the repo to which the logs will be pushed. Defaults to &#x201C;model&#x201D;.`,name:"repo_type"},{anchor:"huggingface_hub.HFSummaryWriter.repo_revision",description:`<strong>repo_revision</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The revision of the repo to which the logs will be pushed. Defaults to &#x201C;main&#x201D;.`,name:"repo_revision"},{anchor:"huggingface_hub.HFSummaryWriter.repo_private",description:`<strong>repo_private</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Whether to create a private repo or not. Defaults to False. This argument is ignored if the repo already
exists.`,name:"repo_private"},{anchor:"huggingface_hub.HFSummaryWriter.path_in_repo",description:`<strong>path_in_repo</strong> (<code>str</code>, <em>optional</em>) &#x2014;
The path to the folder in the repo where the logs will be pushed. Defaults to &#x201C;tensorboard/&#x201C;.`,name:"path_in_repo"},{anchor:"huggingface_hub.HFSummaryWriter.repo_allow_patterns",description:`<strong>repo_allow_patterns</strong> (<code>List[str]</code> or <code>str</code>, <em>optional</em>) &#x2014;
A list of patterns to include in the upload. Defaults to <code>&quot;*.tfevents.*&quot;</code>. Check out the
<a href="https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-folder" rel="nofollow">upload guide</a> for more details.`,name:"repo_allow_patterns"},{anchor:"huggingface_hub.HFSummaryWriter.repo_ignore_patterns",description:`<strong>repo_ignore_patterns</strong> (<code>List[str]</code> or <code>str</code>, <em>optional</em>) &#x2014;
A list of patterns to exclude in the upload. Check out the
<a href="https://huggingface.co/docs/huggingface_hub/guides/upload#upload-a-folder" rel="nofollow">upload guide</a> for more details.`,name:"repo_ignore_patterns"},{anchor:"huggingface_hub.HFSummaryWriter.token",description:`<strong>token</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Authentication token. Will default to the stored token. See <a href="https://huggingface.co/settings/token" rel="nofollow">https://huggingface.co/settings/token</a> for more
details
kwargs &#x2014;
Additional keyword arguments passed to <code>SummaryWriter</code>.`,name:"token"}],source:"https://github.com/huggingface/huggingface_hub/blob/v0.20.3/src/huggingface_hub/_tensorboard_logger.py#L35"}}),_=new le({props:{warning:!0,$$slots:{default:[ge]},$$scope:{ctx:y}}}),b=new ee({props:{anchor:"huggingface_hub.HFSummaryWriter.example",$$slots:{default:[he]},$$scope:{ctx:y}}}),$=new ee({props:{anchor:"huggingface_hub.HFSummaryWriter.example-2",$$slots:{default:[pe]},$$scope:{ctx:y}}}),{c(){t=d("meta"),l=h(),a=d("p"),i=h(),v(u.$$.fragment),s=h(),m=d("p"),m.innerHTML=z,C=h(),j=d("p"),j.innerHTML=N,Z=h(),v(F.$$.fragment),q=h(),n=d("div"),v(S.$$.fragment),L=h(),M=d("p"),M.innerHTML=Q,E=h(),I=d("p"),I.innerHTML=A,G=h(),v(_.$$.fragment),B=h(),v(b.$$.fragment),Y=h(),v($.$$.fragment),X=h(),U=d("p"),this.h()},l(e){const o=ie("svelte-u9bgzb",document.head);t=f(o,"META",{name:!0,content:!0}),o.forEach(r),l=p(e),a=f(e,"P",{}),P(a).forEach(r),i=p(e),T(u.$$.fragment,e),s=p(e),m=f(e,"P",{"data-svelte-h":!0}),J(m)!=="svelte-1k63c81"&&(m.innerHTML=z),C=p(e),j=f(e,"P",{"data-svelte-h":!0}),J(j)!=="svelte-lh4s3l"&&(j.innerHTML=N),Z=p(e),T(F.$$.fragment,e),q=p(e),n=f(e,"DIV",{class:!0});var c=P(n);T(S.$$.fragment,c),L=p(c),M=f(c,"P",{"data-svelte-h":!0}),J(M)!=="svelte-1gj9gtd"&&(M.innerHTML=Q),E=p(c),I=f(c,"P",{"data-svelte-h":!0}),J(I)!=="svelte-37hlnu"&&(I.innerHTML=A),G=p(c),T(_.$$.fragment,c),B=p(c),T(b.$$.fragment,c),Y=p(c),T($.$$.fragment,c),c.forEach(r),X=p(e),U=f(e,"P",{}),P(U).forEach(r),this.h()},h(){R(t,"name","hf:doc:metadata"),R(t,"content",me),R(n,"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,o){w(document.head,t),g(e,l,o),g(e,a,o),g(e,i,o),x(u,e,o),g(e,s,o),g(e,m,o),g(e,C,o),g(e,j,o),g(e,Z,o),x(F,e,o),g(e,q,o),g(e,n,o),x(S,n,null),w(n,L),w(n,M),w(n,E),w(n,I),w(n,G),x(_,n,null),w(n,B),x(b,n,null),w(n,Y),x($,n,null),g(e,X,o),g(e,U,o),D=!0},p(e,[o]){const c={};o&2&&(c.$$scope={dirty:o,ctx:e}),_.$set(c);const K={};o&2&&(K.$$scope={dirty:o,ctx:e}),b.$set(K);const O={};o&2&&(O.$$scope={dirty:o,ctx:e}),$.$set(O)},i(e){D||(H(u.$$.fragment,e),H(F.$$.fragment,e),H(S.$$.fragment,e),H(_.$$.fragment,e),H(b.$$.fragment,e),H($.$$.fragment,e),D=!0)},o(e){k(u.$$.fragment,e),k(F.$$.fragment,e),k(S.$$.fragment,e),k(_.$$.fragment,e),k(b.$$.fragment,e),k($.$$.fragment,e),D=!1},d(e){e&&(r(l),r(a),r(i),r(s),r(m),r(C),r(j),r(Z),r(q),r(n),r(X),r(U)),r(t),W(u,e),W(F,e),W(S),W(_),W(b),W($)}}}const me='{"title":"TensorBoard logger","local":"tensorboard-logger","sections":[{"title":"HFSummaryWriter","local":"huggingface_hub.HFSummaryWriter","sections":[],"depth":2}],"depth":1}';function de(y){return re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Te extends se{constructor(t){super(),ne(this,t,de,ue,oe,{})}}export{Te as component};
