import{s as _t,o as kt,n as xt}from"../chunks/scheduler.37c15a92.js";import{S as vt,i as Zt,g as h,s as n,r as o,A as jt,h as f,f as s,c as l,j as Mt,u as r,x as $,k as Ut,y as It,a,v as p,d as u,t as m,w as d}from"../chunks/index.7cb9c9b8.js";import{T as Rt}from"../chunks/Tip.d10b3fc9.js";import{C as B}from"../chunks/CodeBlock.abae2786.js";import{C as Xt}from"../chunks/CourseFloatingBanner.df82c153.js";import{H as ht,E as Ht}from"../chunks/getInferenceSnippets.a2135f3c.js";function Gt(V){let i,y="⚠️ Note that the records with <code>completed</code> status (i.e., records that meet the minimum submitted responses configured in the task distribution settings) could have more than one response and that each response can have any status from <code>submitted</code>, <code>draft</code> or <code>discarded</code>.";return{c(){i=h("p"),i.innerHTML=y},l(c){i=f(c,"P",{"data-svelte-h":!0}),$(i)!=="svelte-1s9kaa1"&&(i.innerHTML=y)},m(c,z){a(c,i,z)},p:xt,d(c){c&&s(i)}}}function qt(V){let i,y,c,z,w,L,b,N,J,ft="We will learn now how to export and use the annotated data that we have in Argilla.",P,T,A,C,ct="First, we’ll need to make sure that we’re connected to our Argilla instance as in the previous steps:",W,M,S,U,$t="And now, we’ll load the dataset that we’ll be working with:",Q,_,D,k,gt="Loading the dataset and calling its records with <code>dataset.records</code> is enough to start using your dataset and records for your own purposes and pipelines. However, we’ll also learn how to do a few optional operations, like filtering the records and exporting your dataset to the Hugging Face Hub.",K,x,O,v,yt="Sometimes you only want to use the records that have been completed, so we will first filter the records in our dataset based on their status:",tt,Z,et,g,st,j,wt='Learn more about querying and filtering records in the <a href="https://docs.argilla.io/latest/how_to_guides/query/" rel="nofollow">Argilla docs</a>.',at,I,nt,R,bt="We can now export our annotations to the Hugging Face Hub, so we can share them with others. To do this, we’ll need to convert the records into a 🤗 Dataset and then push it to the Hub:",lt,X,it,H,Jt="Alternatively, we can export directly the complete Argilla dataset (including pending records) like this:",ot,G,rt,q,Tt="This is an interesting choice in case others want to open the dataset in their Argilla instances, as the settings are automatically saved and they can simply import the full dataset using a single line of code:",pt,E,ut,F,mt,Y,dt;return w=new ht({props:{title:"Use your annotated dataset",local:"use-your-annotated-dataset",headingTag:"h1"}}),b=new Xt({props:{chapter:10,classNames:"absolute z-10 right-0 top-0",notebooks:[{label:"Google Colab",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/master/course/en/chapter10/section5.ipynb"},{label:"Aws Studio",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/master/course/en/chapter10/section5.ipynb"}]}}),T=new ht({props:{title:"Load the dataset",local:"load-the-dataset",headingTag:"h2"}}),M=new B({props:{code:"aW1wb3J0JTIwYXJnaWxsYSUyMGFzJTIwcmclMEElMEFIRl9UT0tFTiUyMCUzRCUyMCUyMi4uLiUyMiUyMCUyMCUyMyUyMG9ubHklMjBmb3IlMjBwcml2YXRlJTIwc3BhY2VzJTBBJTBBY2xpZW50JTIwJTNEJTIwcmcuQXJnaWxsYSglMEElMjAlMjAlMjAlMjBhcGlfdXJsJTNEJTIyLi4uJTIyJTJDJTBBJTIwJTIwJTIwJTIwYXBpX2tleSUzRCUyMi4uLiUyMiUyQyUwQSUyMCUyMCUyMCUyMGhlYWRlcnMlM0QlN0IlMjJBdXRob3JpemF0aW9uJTIyJTNBJTIwZiUyMkJlYXJlciUyMCU3QkhGX1RPS0VOJTdEJTIyJTdEJTJDJTIwJTIwJTIzJTIwb25seSUyMGZvciUyMHByaXZhdGUlMjBzcGFjZXMlMEEp",highlighted:`<span class="hljs-keyword">import</span> argilla <span class="hljs-keyword">as</span> rg

HF_TOKEN = <span class="hljs-string">&quot;...&quot;</span>  <span class="hljs-comment"># only for private spaces</span>

client = rg.Argilla(
    api_url=<span class="hljs-string">&quot;...&quot;</span>,
    api_key=<span class="hljs-string">&quot;...&quot;</span>,
    headers={<span class="hljs-string">&quot;Authorization&quot;</span>: <span class="hljs-string">f&quot;Bearer <span class="hljs-subst">{HF_TOKEN}</span>&quot;</span>},  <span class="hljs-comment"># only for private spaces</span>
)`,wrap:!1}}),_=new B({props:{code:"ZGF0YXNldCUyMCUzRCUyMGNsaWVudC5kYXRhc2V0cyhuYW1lJTNEJTIyYWdfbmV3cyUyMik=",highlighted:'dataset = client.datasets(name=<span class="hljs-string">&quot;ag_news&quot;</span>)',wrap:!1}}),x=new ht({props:{title:"Filter the dataset",local:"filter-the-dataset",headingTag:"h2"}}),Z=new B({props:{code:"c3RhdHVzX2ZpbHRlciUyMCUzRCUyMHJnLlF1ZXJ5KGZpbHRlciUzRHJnLkZpbHRlciglNUIoJTIyc3RhdHVzJTIyJTJDJTIwJTIyJTNEJTNEJTIyJTJDJTIwJTIyY29tcGxldGVkJTIyKSU1RCkpJTBBJTBBZmlsdGVyZWRfcmVjb3JkcyUyMCUzRCUyMGRhdGFzZXQucmVjb3JkcyhzdGF0dXNfZmlsdGVyKQ==",highlighted:`status_filter = rg.Query(<span class="hljs-built_in">filter</span>=rg.Filter([(<span class="hljs-string">&quot;status&quot;</span>, <span class="hljs-string">&quot;==&quot;</span>, <span class="hljs-string">&quot;completed&quot;</span>)]))

filtered_records = dataset.records(status_filter)`,wrap:!1}}),g=new Rt({props:{warning:!1,$$slots:{default:[Gt]},$$scope:{ctx:V}}}),I=new ht({props:{title:"Export to the Hub",local:"export-to-the-hub",headingTag:"h2"}}),X=new B({props:{code:"ZmlsdGVyZWRfcmVjb3Jkcy50b19kYXRhc2V0cygpLnB1c2hfdG9faHViKCUyMmFyZ2lsbGElMkZhZ19uZXdzX2Fubm90YXRlZCUyMik=",highlighted:'filtered_records.to_datasets().push_to_hub(<span class="hljs-string">&quot;argilla/ag_news_annotated&quot;</span>)',wrap:!1}}),G=new B({props:{code:"ZGF0YXNldC50b19odWIocmVwb19pZCUzRCUyMmFyZ2lsbGElMkZhZ19uZXdzX2Fubm90YXRlZCUyMik=",highlighted:'dataset.to_hub(repo_id=<span class="hljs-string">&quot;argilla/ag_news_annotated&quot;</span>)',wrap:!1}}),E=new B({props:{code:"ZGF0YXNldCUyMCUzRCUyMHJnLkRhdGFzZXQuZnJvbV9odWIocmVwb19pZCUzRCUyMmFyZ2lsbGElMkZhZ19uZXdzX2Fubm90YXRlZCUyMik=",highlighted:'dataset = rg.Dataset.from_hub(repo_id=<span class="hljs-string">&quot;argilla/ag_news_annotated&quot;</span>)',wrap:!1}}),F=new Ht({props:{source:"https://github.com/huggingface/course/blob/main/chapters/en/chapter10/5.mdx"}}),{c(){i=h("meta"),y=n(),c=h("p"),z=n(),o(w.$$.fragment),L=n(),o(b.$$.fragment),N=n(),J=h("p"),J.textContent=ft,P=n(),o(T.$$.fragment),A=n(),C=h("p"),C.textContent=ct,W=n(),o(M.$$.fragment),S=n(),U=h("p"),U.textContent=$t,Q=n(),o(_.$$.fragment),D=n(),k=h("p"),k.innerHTML=gt,K=n(),o(x.$$.fragment),O=n(),v=h("p"),v.textContent=yt,tt=n(),o(Z.$$.fragment),et=n(),o(g.$$.fragment),st=n(),j=h("p"),j.innerHTML=wt,at=n(),o(I.$$.fragment),nt=n(),R=h("p"),R.textContent=bt,lt=n(),o(X.$$.fragment),it=n(),H=h("p"),H.textContent=Jt,ot=n(),o(G.$$.fragment),rt=n(),q=h("p"),q.textContent=Tt,pt=n(),o(E.$$.fragment),ut=n(),o(F.$$.fragment),mt=n(),Y=h("p"),this.h()},l(t){const e=jt("svelte-u9bgzb",document.head);i=f(e,"META",{name:!0,content:!0}),e.forEach(s),y=l(t),c=f(t,"P",{}),Mt(c).forEach(s),z=l(t),r(w.$$.fragment,t),L=l(t),r(b.$$.fragment,t),N=l(t),J=f(t,"P",{"data-svelte-h":!0}),$(J)!=="svelte-rtacj6"&&(J.textContent=ft),P=l(t),r(T.$$.fragment,t),A=l(t),C=f(t,"P",{"data-svelte-h":!0}),$(C)!=="svelte-17912s9"&&(C.textContent=ct),W=l(t),r(M.$$.fragment,t),S=l(t),U=f(t,"P",{"data-svelte-h":!0}),$(U)!=="svelte-kzryh9"&&(U.textContent=$t),Q=l(t),r(_.$$.fragment,t),D=l(t),k=f(t,"P",{"data-svelte-h":!0}),$(k)!=="svelte-1peasv5"&&(k.innerHTML=gt),K=l(t),r(x.$$.fragment,t),O=l(t),v=f(t,"P",{"data-svelte-h":!0}),$(v)!=="svelte-nfhygw"&&(v.textContent=yt),tt=l(t),r(Z.$$.fragment,t),et=l(t),r(g.$$.fragment,t),st=l(t),j=f(t,"P",{"data-svelte-h":!0}),$(j)!=="svelte-1tk8wea"&&(j.innerHTML=wt),at=l(t),r(I.$$.fragment,t),nt=l(t),R=f(t,"P",{"data-svelte-h":!0}),$(R)!=="svelte-scmc2l"&&(R.textContent=bt),lt=l(t),r(X.$$.fragment,t),it=l(t),H=f(t,"P",{"data-svelte-h":!0}),$(H)!=="svelte-jc7lzo"&&(H.textContent=Jt),ot=l(t),r(G.$$.fragment,t),rt=l(t),q=f(t,"P",{"data-svelte-h":!0}),$(q)!=="svelte-471wcw"&&(q.textContent=Tt),pt=l(t),r(E.$$.fragment,t),ut=l(t),r(F.$$.fragment,t),mt=l(t),Y=f(t,"P",{}),Mt(Y).forEach(s),this.h()},h(){Ut(i,"name","hf:doc:metadata"),Ut(i,"content",Et)},m(t,e){It(document.head,i),a(t,y,e),a(t,c,e),a(t,z,e),p(w,t,e),a(t,L,e),p(b,t,e),a(t,N,e),a(t,J,e),a(t,P,e),p(T,t,e),a(t,A,e),a(t,C,e),a(t,W,e),p(M,t,e),a(t,S,e),a(t,U,e),a(t,Q,e),p(_,t,e),a(t,D,e),a(t,k,e),a(t,K,e),p(x,t,e),a(t,O,e),a(t,v,e),a(t,tt,e),p(Z,t,e),a(t,et,e),p(g,t,e),a(t,st,e),a(t,j,e),a(t,at,e),p(I,t,e),a(t,nt,e),a(t,R,e),a(t,lt,e),p(X,t,e),a(t,it,e),a(t,H,e),a(t,ot,e),p(G,t,e),a(t,rt,e),a(t,q,e),a(t,pt,e),p(E,t,e),a(t,ut,e),p(F,t,e),a(t,mt,e),a(t,Y,e),dt=!0},p(t,[e]){const Ct={};e&2&&(Ct.$$scope={dirty:e,ctx:t}),g.$set(Ct)},i(t){dt||(u(w.$$.fragment,t),u(b.$$.fragment,t),u(T.$$.fragment,t),u(M.$$.fragment,t),u(_.$$.fragment,t),u(x.$$.fragment,t),u(Z.$$.fragment,t),u(g.$$.fragment,t),u(I.$$.fragment,t),u(X.$$.fragment,t),u(G.$$.fragment,t),u(E.$$.fragment,t),u(F.$$.fragment,t),dt=!0)},o(t){m(w.$$.fragment,t),m(b.$$.fragment,t),m(T.$$.fragment,t),m(M.$$.fragment,t),m(_.$$.fragment,t),m(x.$$.fragment,t),m(Z.$$.fragment,t),m(g.$$.fragment,t),m(I.$$.fragment,t),m(X.$$.fragment,t),m(G.$$.fragment,t),m(E.$$.fragment,t),m(F.$$.fragment,t),dt=!1},d(t){t&&(s(y),s(c),s(z),s(L),s(N),s(J),s(P),s(A),s(C),s(W),s(S),s(U),s(Q),s(D),s(k),s(K),s(O),s(v),s(tt),s(et),s(st),s(j),s(at),s(nt),s(R),s(lt),s(it),s(H),s(ot),s(rt),s(q),s(pt),s(ut),s(mt),s(Y)),s(i),d(w,t),d(b,t),d(T,t),d(M,t),d(_,t),d(x,t),d(Z,t),d(g,t),d(I,t),d(X,t),d(G,t),d(E,t),d(F,t)}}}const Et='{"title":"Use your annotated dataset","local":"use-your-annotated-dataset","sections":[{"title":"Load the dataset","local":"load-the-dataset","sections":[],"depth":2},{"title":"Filter the dataset","local":"filter-the-dataset","sections":[],"depth":2},{"title":"Export to the Hub","local":"export-to-the-hub","sections":[],"depth":2}],"depth":1}';function Ft(V){return kt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pt extends vt{constructor(i){super(),Zt(this,i,Ft,qt,_t,{})}}export{Pt as component};
