import{s as ne,o as se,n as q}from"../chunks/scheduler.6062bdaf.js";import{S as ie,i as le,g,s as h,r as y,A as ce,h as f,f as o,c as u,j as N,u as b,x as C,k as Y,y as W,a as l,v as _,d as w,t as $,w as T}from"../chunks/index.4bca734e.js";import{T as me}from"../chunks/Tip.b9ac1f03.js";import{D as he}from"../chunks/Docstring.ff53aa02.js";import{C as oe}from"../chunks/CodeBlock.cbbddafc.js";import{E as re}from"../chunks/ExampleCodeBlock.d2834193.js";import{H as ae,E as ue}from"../chunks/index.60dd99e8.js";function de(M){let t,c="<code>HFSummaryWriter</code> is experimental. Its API is subject to change in the future without prior notice.";return{c(){t=g("p"),t.innerHTML=c},l(r){t=f(r,"P",{"data-svelte-h":!0}),C(t)!=="svelte-1jyxcko"&&(t.innerHTML=c)},m(r,i){l(r,t,i)},p:q,d(r){r&&o(t)}}}function pe(M){let t,c="Examples:",r,i,d;return i=new oe({props:{code:"JTIzJTIwVGFrZW4lMjBmcm9tJTIwaHR0cHMlM0ElMkYlMkZweXRvcmNoLm9yZyUyRmRvY3MlMkZzdGFibGUlMkZ0ZW5zb3Jib2FyZC5odG1sJTBBLSUyMGZyb20lMjB0b3JjaC51dGlscy50ZW5zb3Jib2FyZCUyMGltcG9ydCUyMFN1bW1hcnlXcml0ZXIlMEElMkIlMjBmcm9tJTIwaHVnZ2luZ2ZhY2VfaHViJTIwaW1wb3J0JTIwSEZTdW1tYXJ5V3JpdGVyJTBBJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBLSUyMHdyaXRlciUyMCUzRCUyMFN1bW1hcnlXcml0ZXIoKSUwQSUyQiUyMHdyaXRlciUyMCUzRCUyMEhGU3VtbWFyeVdyaXRlcihyZXBvX2lkJTNEJTIydXNlcm5hbWUlMkZteS10cmFpbmVkLW1vZGVsJTIyKSUwQSUwQWZvciUyMG5faXRlciUyMGluJTIwcmFuZ2UoMTAwKSUzQSUwQSUyMCUyMCUyMCUyMHdyaXRlci5hZGRfc2NhbGFyKCdMb3NzJTJGdHJhaW4nJTJDJTIwbnAucmFuZG9tLnJhbmRvbSgpJTJDJTIwbl9pdGVyKSUwQSUyMCUyMCUyMCUyMHdyaXRlci5hZGRfc2NhbGFyKCdMb3NzJTJGdGVzdCclMkMlMjBucC5yYW5kb20ucmFuZG9tKCklMkMlMjBuX2l0ZXIpJTBBJTIwJTIwJTIwJTIwd3JpdGVyLmFkZF9zY2FsYXIoJ0FjY3VyYWN5JTJGdHJhaW4nJTJDJTIwbnAucmFuZG9tLnJhbmRvbSgpJTJDJTIwbl9pdGVyKSUwQSUyMCUyMCUyMCUyMHdyaXRlci5hZGRfc2NhbGFyKCdBY2N1cmFjeSUyRnRlc3QnJTJDJTIwbnAucmFuZG9tLnJhbmRvbSgpJTJDJTIwbl9pdGVyKQ==",highlighted:`# Taken from https://pytorch.org/docs/stable/tensorboard.html
<span class="hljs-deletion">- from torch.utils.tensorboard import SummaryWriter</span>
<span class="hljs-addition">+ from huggingface_hub import HFSummaryWriter</span>

import numpy as np

<span class="hljs-deletion">- writer = SummaryWriter()</span>
<span class="hljs-addition">+ writer = HFSummaryWriter(repo_id=&quot;username/my-trained-model&quot;)</span>

for n_iter in range(100):
    writer.add_scalar(&#x27;Loss/train&#x27;, np.random.random(), n_iter)
    writer.add_scalar(&#x27;Loss/test&#x27;, np.random.random(), n_iter)
    writer.add_scalar(&#x27;Accuracy/train&#x27;, np.random.random(), n_iter)
    writer.add_scalar(&#x27;Accuracy/test&#x27;, np.random.random(), n_iter)`,wrap:!1}}),{c(){t=g("p"),t.textContent=c,r=h(),y(i.$$.fragment)},l(n){t=f(n,"P",{"data-svelte-h":!0}),C(t)!=="svelte-kvfsh7"&&(t.textContent=c),r=u(n),b(i.$$.fragment,n)},m(n,p){l(n,t,p),l(n,r,p),_(i,n,p),d=!0},p:q,i(n){d||(w(i.$$.fragment,n),d=!0)},o(n){$(i.$$.fragment,n),d=!1},d(n){n&&(o(t),o(r)),T(i,n)}}}function ge(M){let t,c;return t=new oe({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMEhGU3VtbWFyeVdyaXRlciUwQSUwQXdpdGglMjBIRlN1bW1hcnlXcml0ZXIocmVwb19pZCUzRCUyMnRlc3RfaGZfbG9nZ2VyJTIyJTJDJTIwY29tbWl0X2V2ZXJ5JTNEMTUpJTIwYXMlMjBsb2dnZXIlM0ElMEElMjAlMjAlMjAlMjBsb2dnZXIuYWRkX3NjYWxhciglMjJhJTIyJTJDJTIwMSklMEElMjAlMjAlMjAlMjBsb2dnZXIuYWRkX3NjYWxhciglMjJiJTIyJTJDJTIwMik=",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 (5 by 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>, commit_every=<span class="hljs-number">15</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(r){b(t.$$.fragment,r)},m(r,i){_(t,r,i),c=!0},p:q,i(r){c||(w(t.$$.fragment,r),c=!0)},o(r){$(t.$$.fragment,r),c=!1},d(r){T(t,r)}}}function fe(M){let t,c,r,i,d,n,p,P=`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>.`,G,S,Q=`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,k,B,s,x,D,F,K="Wrapper around the tensorboard’s <code>SummaryWriter</code> to push training logs to the Hub.",E,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).`,V,J,A,v,z,H,X,U,R,I,L;return d=new ae({props:{title:"TensorBoard logger",local:"tensorboard-logger",headingTag:"h1"}}),k=new ae({props:{title:"HFSummaryWriter",local:"huggingface_hub.HFSummaryWriter",headingTag:"h2"}}),x=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 make the repo private. If <code>None</code> (default), the repo will be public unless the organization&#x2019;s default is private. This value 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`,name:"token"},{anchor:"huggingface_hub.HFSummaryWriter.kwargs",description:`<strong>kwargs</strong> &#x2014;
Additional keyword arguments passed to <code>SummaryWriter</code>.`,name:"kwargs"}],source:"https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/_tensorboard_logger.py#L47"}}),J=new me({props:{warning:!0,$$slots:{default:[de]},$$scope:{ctx:M}}}),v=new re({props:{anchor:"huggingface_hub.HFSummaryWriter.example",$$slots:{default:[pe]},$$scope:{ctx:M}}}),H=new re({props:{anchor:"huggingface_hub.HFSummaryWriter.example-2",$$slots:{default:[ge]},$$scope:{ctx:M}}}),U=new ue({props:{source:"https://github.com/huggingface/huggingface_hub/blob/main/docs/source/en/package_reference/tensorboard.md"}}),{c(){t=g("meta"),c=h(),r=g("p"),i=h(),y(d.$$.fragment),n=h(),p=g("p"),p.innerHTML=P,G=h(),S=g("p"),S.innerHTML=Q,Z=h(),y(k.$$.fragment),B=h(),s=g("div"),y(x.$$.fragment),D=h(),F=g("p"),F.innerHTML=K,E=h(),j=g("p"),j.innerHTML=O,V=h(),y(J.$$.fragment),A=h(),y(v.$$.fragment),z=h(),y(H.$$.fragment),X=h(),y(U.$$.fragment),R=h(),I=g("p"),this.h()},l(e){const a=ce("svelte-u9bgzb",document.head);t=f(a,"META",{name:!0,content:!0}),a.forEach(o),c=u(e),r=f(e,"P",{}),N(r).forEach(o),i=u(e),b(d.$$.fragment,e),n=u(e),p=f(e,"P",{"data-svelte-h":!0}),C(p)!=="svelte-1k63c81"&&(p.innerHTML=P),G=u(e),S=f(e,"P",{"data-svelte-h":!0}),C(S)!=="svelte-lh4s3l"&&(S.innerHTML=Q),Z=u(e),b(k.$$.fragment,e),B=u(e),s=f(e,"DIV",{class:!0});var m=N(s);b(x.$$.fragment,m),D=u(m),F=f(m,"P",{"data-svelte-h":!0}),C(F)!=="svelte-1gj9gtd"&&(F.innerHTML=K),E=u(m),j=f(m,"P",{"data-svelte-h":!0}),C(j)!=="svelte-37hlnu"&&(j.innerHTML=O),V=u(m),b(J.$$.fragment,m),A=u(m),b(v.$$.fragment,m),z=u(m),b(H.$$.fragment,m),m.forEach(o),X=u(e),b(U.$$.fragment,e),R=u(e),I=f(e,"P",{}),N(I).forEach(o),this.h()},h(){Y(t,"name","hf:doc:metadata"),Y(t,"content",ye),Y(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,a){W(document.head,t),l(e,c,a),l(e,r,a),l(e,i,a),_(d,e,a),l(e,n,a),l(e,p,a),l(e,G,a),l(e,S,a),l(e,Z,a),_(k,e,a),l(e,B,a),l(e,s,a),_(x,s,null),W(s,D),W(s,F),W(s,E),W(s,j),W(s,V),_(J,s,null),W(s,A),_(v,s,null),W(s,z),_(H,s,null),l(e,X,a),_(U,e,a),l(e,R,a),l(e,I,a),L=!0},p(e,[a]){const m={};a&2&&(m.$$scope={dirty:a,ctx:e}),J.$set(m);const ee={};a&2&&(ee.$$scope={dirty:a,ctx:e}),v.$set(ee);const te={};a&2&&(te.$$scope={dirty:a,ctx:e}),H.$set(te)},i(e){L||(w(d.$$.fragment,e),w(k.$$.fragment,e),w(x.$$.fragment,e),w(J.$$.fragment,e),w(v.$$.fragment,e),w(H.$$.fragment,e),w(U.$$.fragment,e),L=!0)},o(e){$(d.$$.fragment,e),$(k.$$.fragment,e),$(x.$$.fragment,e),$(J.$$.fragment,e),$(v.$$.fragment,e),$(H.$$.fragment,e),$(U.$$.fragment,e),L=!1},d(e){e&&(o(c),o(r),o(i),o(n),o(p),o(G),o(S),o(Z),o(B),o(s),o(X),o(R),o(I)),o(t),T(d,e),T(k,e),T(x),T(J),T(v),T(H),T(U,e)}}}const ye='{"title":"TensorBoard logger","local":"tensorboard-logger","sections":[{"title":"HFSummaryWriter","local":"huggingface_hub.HFSummaryWriter","sections":[],"depth":2}],"depth":1}';function be(M){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class He extends ie{constructor(t){super(),le(this,t,be,fe,ne,{})}}export{He as component};
