import{s as ne,o as se,n as N}from"../chunks/scheduler.6062bdaf.js";import{S as ie,i as le,g as d,s as h,r as y,A as ce,h as f,f as r,c as p,j as V,u as b,x as U,k as z,y as W,a as l,v as _,d as $,t as w,w as v}from"../chunks/index.4bca734e.js";import{T as ge}from"../chunks/Tip.b9ac1f03.js";import{D as he}from"../chunks/Docstring.d7918b6d.js";import{C as re}from"../chunks/CodeBlock.fa01571c.js";import{E as ae}from"../chunks/ExampleCodeBlock.d27cbfa4.js";import{H as oe,E as pe}from"../chunks/EditOnGithub.74ab2baa.js";function ue(T){let t,c="<code>HFSummaryWriter</code> is experimental. Its API is subject to change in the future without prior notice.";return{c(){t=d("p"),t.innerHTML=c},l(a){t=f(a,"P",{"data-svelte-h":!0}),U(t)!=="svelte-1jyxcko"&&(t.innerHTML=c)},m(a,i){l(a,t,i)},p:N,d(a){a&&r(t)}}}function me(T){let t,c="Examples:",a,i,u;return i=new re({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=c,a=h(),y(i.$$.fragment)},l(n){t=f(n,"P",{"data-svelte-h":!0}),U(t)!=="svelte-kvfsh7"&&(t.textContent=c),a=p(n),b(i.$$.fragment,n)},m(n,m){l(n,t,m),l(n,a,m),_(i,n,m),u=!0},p:N,i(n){u||($(i.$$.fragment,n),u=!0)},o(n){w(i.$$.fragment,n),u=!1},d(n){n&&(r(t),r(a)),v(i,n)}}}function de(T){let t,c;return t=new re({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(){y(t.$$.fragment)},l(a){b(t.$$.fragment,a)},m(a,i){_(t,a,i),c=!0},p:N,i(a){c||($(t.$$.fragment,a),c=!0)},o(a){w(t.$$.fragment,a),c=!1},d(a){v(t,a)}}}function fe(T){let t,c,a,i,u,n,m,Q=`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>.`,Z,j,A=`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.`,q,F,X,s,S,L,I,K="Wrapper around the tensorboard’s <code>SummaryWriter</code> to push training logs to the Hub.",B,J,O=`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).`,Y,x,P,H,R,k,E,M,D,C,G;return u=new oe({props:{title:"TensorBoard logger",local:"tensorboard-logger",headingTag:"h1"}}),F=new oe({props:{title:"HFSummaryWriter",local:"huggingface_hub.HFSummaryWriter",headingTag:"h2"}}),S=new he({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/vr_2373/src/huggingface_hub/_tensorboard_logger.py#L46"}}),x=new ge({props:{warning:!0,$$slots:{default:[ue]},$$scope:{ctx:T}}}),H=new ae({props:{anchor:"huggingface_hub.HFSummaryWriter.example",$$slots:{default:[me]},$$scope:{ctx:T}}}),k=new ae({props:{anchor:"huggingface_hub.HFSummaryWriter.example-2",$$slots:{default:[de]},$$scope:{ctx:T}}}),M=new pe({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/package_reference/tensorboard.md"}}),{c(){t=d("meta"),c=h(),a=d("p"),i=h(),y(u.$$.fragment),n=h(),m=d("p"),m.innerHTML=Q,Z=h(),j=d("p"),j.innerHTML=A,q=h(),y(F.$$.fragment),X=h(),s=d("div"),y(S.$$.fragment),L=h(),I=d("p"),I.innerHTML=K,B=h(),J=d("p"),J.innerHTML=O,Y=h(),y(x.$$.fragment),P=h(),y(H.$$.fragment),R=h(),y(k.$$.fragment),E=h(),y(M.$$.fragment),D=h(),C=d("p"),this.h()},l(e){const o=ce("svelte-u9bgzb",document.head);t=f(o,"META",{name:!0,content:!0}),o.forEach(r),c=p(e),a=f(e,"P",{}),V(a).forEach(r),i=p(e),b(u.$$.fragment,e),n=p(e),m=f(e,"P",{"data-svelte-h":!0}),U(m)!=="svelte-1k63c81"&&(m.innerHTML=Q),Z=p(e),j=f(e,"P",{"data-svelte-h":!0}),U(j)!=="svelte-lh4s3l"&&(j.innerHTML=A),q=p(e),b(F.$$.fragment,e),X=p(e),s=f(e,"DIV",{class:!0});var g=V(s);b(S.$$.fragment,g),L=p(g),I=f(g,"P",{"data-svelte-h":!0}),U(I)!=="svelte-1gj9gtd"&&(I.innerHTML=K),B=p(g),J=f(g,"P",{"data-svelte-h":!0}),U(J)!=="svelte-37hlnu"&&(J.innerHTML=O),Y=p(g),b(x.$$.fragment,g),P=p(g),b(H.$$.fragment,g),R=p(g),b(k.$$.fragment,g),g.forEach(r),E=p(e),b(M.$$.fragment,e),D=p(e),C=f(e,"P",{}),V(C).forEach(r),this.h()},h(){z(t,"name","hf:doc:metadata"),z(t,"content",ye),z(s,"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),l(e,c,o),l(e,a,o),l(e,i,o),_(u,e,o),l(e,n,o),l(e,m,o),l(e,Z,o),l(e,j,o),l(e,q,o),_(F,e,o),l(e,X,o),l(e,s,o),_(S,s,null),W(s,L),W(s,I),W(s,B),W(s,J),W(s,Y),_(x,s,null),W(s,P),_(H,s,null),W(s,R),_(k,s,null),l(e,E,o),_(M,e,o),l(e,D,o),l(e,C,o),G=!0},p(e,[o]){const g={};o&2&&(g.$$scope={dirty:o,ctx:e}),x.$set(g);const ee={};o&2&&(ee.$$scope={dirty:o,ctx:e}),H.$set(ee);const te={};o&2&&(te.$$scope={dirty:o,ctx:e}),k.$set(te)},i(e){G||($(u.$$.fragment,e),$(F.$$.fragment,e),$(S.$$.fragment,e),$(x.$$.fragment,e),$(H.$$.fragment,e),$(k.$$.fragment,e),$(M.$$.fragment,e),G=!0)},o(e){w(u.$$.fragment,e),w(F.$$.fragment,e),w(S.$$.fragment,e),w(x.$$.fragment,e),w(H.$$.fragment,e),w(k.$$.fragment,e),w(M.$$.fragment,e),G=!1},d(e){e&&(r(c),r(a),r(i),r(n),r(m),r(Z),r(j),r(q),r(X),r(s),r(E),r(D),r(C)),r(t),v(u,e),v(F,e),v(S),v(x),v(H),v(k),v(M,e)}}}const ye='{"title":"TensorBoard logger","local":"tensorboard-logger","sections":[{"title":"HFSummaryWriter","local":"huggingface_hub.HFSummaryWriter","sections":[],"depth":2}],"depth":1}';function be(T){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ke extends ie{constructor(t){super(),le(this,t,be,fe,ne,{})}}export{ke as component};
