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