(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9177],{53985:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/jobs/[job]/[task]",function(){return t(12)}])},6639:function(e,s,t){"use strict";t.d(s,{Z:function(){return a}});/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let a=(0,t(60998).Z)("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]])},41825:function(e,s,t){"use strict";t.d(s,{l:function(){return u}});var a=t(85893),r=t(67294),n=t(45895),i=t(6639);/**
 * @license lucide-react v0.407.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */let l=(0,t(60998).Z)("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);var c=t(470),d=t(17853);let o="skypilot-dcgm-gpu/skypilot-dcgm-gpu-metrics",x=[{label:"15m",value:"15m"},{label:"1h",value:"1h"},{label:"6h",value:"6h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"}],m=[{id:"1",title:"GPU Utilization",keyPrefix:"gpu-util"},{id:"2",title:"GPU Memory Utilization",keyPrefix:"gpu-memory"},{id:"3",title:"GPU Temperature",keyPrefix:"gpu-temp"},{id:"4",title:"GPU Power Usage",keyPrefix:"gpu-power"}],h=(e,s,t)=>{let a=(0,d.ki)(),r=new URLSearchParams({orgId:"1",from:t.from,to:t.to,timezone:"browser","var-cluster":s,"var-node":"$__all","var-gpu":"$__all",theme:"light",panelId:e});return"".concat(a,"/d-solo/").concat(o,"?").concat(r.toString(),"&__feature.dashboardSceneSolo")};function u(e){let{clusterNameOnCloud:s,displayName:t,refreshTrigger:u=0,storageKey:f="skypilot-gpu-metrics-expanded",headerExtra:j=null,noMetricsMessage:g="No GPU metrics available."}=e,[v,b]=(0,r.useState)({from:"now-1h",to:"now"}),[N,p]=(0,r.useState)(()=>"true"===localStorage.getItem(f)),y=e=>{b({from:"now-".concat(e),to:"now"})};return(0,a.jsx)("div",{className:"mt-6",children:(0,a.jsxs)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 ".concat(N?"pt-4":"py-4"),children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsxs)("button",{onClick:()=>{let e=!N;p(e),localStorage.setItem(f,String(e))},className:"flex items-center text-left focus:outline-none hover:text-gray-700 transition-colors duration-200",children:[N?(0,a.jsx)(n.Z,{className:"w-5 h-5 mr-2"}):(0,a.jsx)(i.Z,{className:"w-5 h-5 mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"GPU Metrics"})]}),j]}),(0,a.jsx)(c.WH,{content:"Open in Grafana",children:(0,a.jsx)("button",{onClick:()=>{let e=new URLSearchParams({orgId:"1",from:v.from,to:v.to,timezone:"browser","var-cluster":s,"var-node":"$__all","var-gpu":"$__all"});window.open((0,d.JP)("/d/".concat(o,"?").concat(e.toString())),"_blank")},className:"p-1.5 rounded-md text-gray-500 hover:text-gray-700 hover:bg-gray-100 transition-colors","aria-label":"Open in Grafana",children:(0,a.jsx)(l,{className:"w-4 h-4"})})})]}),N&&(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"mb-4 p-4 bg-gray-50 rounded-md border border-gray-200",children:[(0,a.jsx)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Time Range:"}),(0,a.jsx)("div",{className:"flex gap-1",children:x.map(e=>(0,a.jsx)("button",{onClick:()=>y(e.value),className:"px-2 py-1 text-xs font-medium rounded border transition-colors ".concat(v.from==="now-".concat(e.value)&&"now"===v.to?"bg-sky-blue text-white border-sky-blue":"bg-white text-gray-600 border-gray-300 hover:bg-gray-50"),children:e.label},e.value))})]})}),(0,a.jsxs)("div",{className:"mt-2 text-xs text-gray-500",children:["Showing: ",t," • Time: ",v.from," to"," ",v.to]})]}),s?(0,a.jsx)("div",{className:"grid gap-4 [grid-template-columns:repeat(auto-fit,minmax(300px,1fr))]",children:m.map(e=>(0,a.jsx)("div",{className:"bg-white rounded-md border border-gray-200 shadow-sm",children:(0,a.jsx)("div",{className:"p-2",children:(0,a.jsx)("iframe",{src:h(e.id,s,v),width:"100%",height:"400",frameBorder:"0",title:e.title,className:"rounded"},"".concat(e.keyPrefix,"-").concat(s,"-").concat(v.from,"-").concat(v.to,"-").concat(u))})},e.id))}):(0,a.jsx)("div",{className:"p-4 text-center text-gray-500 bg-gray-50 rounded-md",children:g})]})]})})}},23001:function(e,s,t){"use strict";t.d(s,{X:function(){return r}});var a=t(67294);function r(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:768,[s,t]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let s=()=>{t(window.innerWidth<e)};return s(),window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},[e]),s}},12:function(e,s,t){"use strict";t.r(s);var a=t(85893),r=t(67294),n=t(55739),i=t(11163),l=t(37673),c=t(68969),d=t(41664),o=t.n(d),x=t(13626),m=t(45895),h=t(6639),u=t(16826),f=t(470),j=t(99307),g=t(23001),v=t(9008),b=t.n(v),N=t(20546),p=t(6378),y=t(21494),k=t(17853),w=t(41825);function _(e){let{taskData:s,taskIndex:t,poolsData:r}=e;return(0,a.jsxs)("div",{className:"grid grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Task"}),(0,a.jsxs)("div",{className:"text-base mt-1",children:[t,s.task&&(0,a.jsxs)("span",{className:"text-gray-500",children:[" (",s.task,")"]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsxs)(o(),{href:"/jobs/".concat(s.id),className:"text-sky-blue hover:text-sky-blue-bright hover:underline",children:[s.id,s.name?" (".concat(s.name,")"):""]})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Status"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(j.OE,{status:s.status})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"User"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(N.H,{username:s.user,userHash:s.user_hash})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Workspace"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(o(),{href:"/workspaces",className:"text-gray-700 hover:text-blue-600 hover:underline",children:s.workspace||"default"})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Duration"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,f.LU)(s.job_duration)})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Requested Resources"}),(0,a.jsx)("div",{className:"text-base mt-1",children:s.requested_resources||s.resources_str||"N/A"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Infra"}),(0,a.jsx)("div",{className:"text-base mt-1",children:s.infra?(0,a.jsx)(f.Md,{content:s.full_infra||s.infra,className:"text-sm text-muted-foreground",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(o(),{href:"/infra",className:"text-blue-600 hover:underline",children:s.cloud||s.infra.split("(")[0].trim()}),s.infra.includes("(")&&(0,a.jsx)("span",{children:" "+s.infra.substring(s.infra.indexOf("("))})]})}):"-"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Recoveries"}),(0,a.jsx)("div",{className:"text-base mt-1",children:s.recoveries||0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Pool"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,f.os)(s.pool,s.pool_hash,r)})]}),s.details&&(0,a.jsxs)("div",{className:"col-span-2",children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Details"}),(0,a.jsx)("div",{className:"text-base mt-1 text-gray-700 whitespace-pre-wrap",children:s.details})]})]})}function S(e){let{taskData:s,taskIndex:t,refreshFlag:i,setIsLoadingLogs:l,isLoadingLogs:d}=e,o=["PENDING","SUBMITTED","STARTING"].includes(s.status),x=["RECOVERING"].includes(s.status),m=r.useMemo(()=>({jobId:s.id,task:t,controller:!1}),[s.id,t]),h=r.useCallback(e=>{console.error("Error streaming logs:",e)},[]),{lines:u,isLoading:j,hasReceivedFirstChunk:g}=(0,y.V)({streamFn:c.NJ,streamArgs:m,enabled:!o&&!x,refreshTrigger:i,onError:h});return r.useEffect(()=>{l(j)},[j,l]),(0,a.jsx)("div",{className:"max-h-96 overflow-y-auto",children:o?(0,a.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,a.jsx)("span",{children:"Waiting for the task to start; refresh in a few moments."})}):x?(0,a.jsx)("div",{className:"bg-[#f7f7f7] flex items-center justify-center py-4 text-gray-500",children:(0,a.jsx)("span",{children:"Waiting for the task to recover; refresh in a few moments."})}):g||u.length?(0,a.jsx)(f.$B,{logs:u}):d?(0,a.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,a.jsx)(n.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading logs..."})]}):(0,a.jsx)(f.$B,{logs:u})})}s.default=function(){var e,s;let t=(0,i.useRouter)(),{job:d,task:j}=t.query,[v,N]=(0,r.useState)(0),{jobData:y,loading:P}=(0,c.UA)(d,v),[E,T]=(0,r.useState)([]),[I,L]=(0,r.useState)(!1),[R,U]=(0,r.useState)(!0),[Z,C]=(0,r.useState)(!1),[D,G]=(0,r.useState)(0),[z,M]=(0,r.useState)(!0),O=(0,g.X)(),[W,q]=(0,r.useState)(!1),[H,$]=(0,r.useState)(0);r.useEffect(()=>{!P&&R&&U(!1)},[P,R]),(0,r.useEffect)(()=>{(async function(){try{let e=await p.ZP.get(c.vs,[{}]);T(e.pools||[])}catch(e){console.error("Error fetching pools data:",e),T([])}})()},[]),(0,r.useEffect)(()=>{(async()=>{q(await (0,k.TO)())})()},[]);let F=async()=>{L(!0);try{N(e=>e+1),G(e=>e+1),$(e=>e+1)}catch(e){console.error("Error refreshing data:",e)}finally{L(!1)}},J=()=>{G(e=>e+1)};if(!t.isReady)return(0,a.jsx)("div",{children:"Loading..."});let A=(null==y?void 0:null===(e=y.jobs)||void 0===e?void 0:e.filter(e=>String(e.id)===String(d)))||[],B=parseInt(j,10),X=A[B]||null,V=A.length>0?A[0].name:"",K=X?"Task ".concat(j,": ").concat(X.task||"Unnamed"," | Job ").concat(d," | SkyPilot Dashboard"):"Task Details | SkyPilot Dashboard";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(b(),{children:(0,a.jsx)("title",{children:K})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"text-base flex items-center flex-wrap",children:[(0,a.jsx)(o(),{href:"/jobs",className:"text-sky-blue hover:underline",children:"Managed Jobs"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsxs)(o(),{href:"/jobs/".concat(d),className:"text-sky-blue hover:underline",children:[d," ",V?"(".concat(V,")"):""]}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsxs)("span",{className:"text-gray-700",children:["Task ",j,(null==X?void 0:X.task)&&(0,a.jsxs)("span",{className:"text-gray-500",children:[" (",X.task,")"]})]})]}),(0,a.jsxs)("div",{className:"text-sm flex items-center",children:[(P||I||Z)&&(0,a.jsxs)("div",{className:"flex items-center mr-4",children:[(0,a.jsx)(n.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsx)(f.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,a.jsxs)("button",{onClick:F,disabled:P||I,className:"text-sky-blue hover:text-sky-blue-bright font-medium inline-flex items-center h-8",children:[(0,a.jsx)(x.Z,{className:"w-4 h-4 mr-1.5"}),!O&&(0,a.jsx)("span",{children:"Refresh"})]})})]})]}),P&&R?(0,a.jsxs)("div",{className:"flex items-center justify-center py-32",children:[(0,a.jsx)(n.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]}):X?(0,a.jsxs)("div",{className:"space-y-8",children:[(0,a.jsx)("div",{id:"details-section",children:(0,a.jsxs)(l.Zb,{children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Task Details"})}),(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)(_,{taskData:X,taskIndex:B,poolsData:E})})]})}),W&&(null===(s=X.full_infra)||void 0===s?void 0:s.includes("Kubernetes"))&&!X.pool&&X.cluster_name_on_cloud&&(0,a.jsx)(w.l,{clusterNameOnCloud:X.cluster_name_on_cloud,displayName:X.task||"Task ".concat(j),refreshTrigger:H,storageKey:"skypilot-task-gpu-metrics-expanded"}),(0,a.jsx)("div",{id:"logs-section",className:"mt-6",children:(0,a.jsxs)(l.Zb,{children:[(0,a.jsxs)("button",{onClick:()=>M(!z),className:"flex items-center justify-between w-full px-4 py-4 text-left focus:outline-none",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[z?(0,a.jsx)(m.Z,{className:"w-5 h-5 mr-2 text-gray-500"}):(0,a.jsx)(h.Z,{className:"w-5 h-5 mr-2 text-gray-500"}),(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Logs"}),(0,a.jsxs)("span",{className:"ml-2 text-xs text-gray-500",children:["(Task ",j," logs)"]})]}),z&&(0,a.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,a.jsx)(f.WH,{content:"Download task logs",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),(0,c.jh)({jobId:parseInt(d),controller:!1})},className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,a.jsx)(u.Z,{className:"w-4 h-4"})})}),(0,a.jsx)(f.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:e=>{e.stopPropagation(),J()},disabled:Z,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,a.jsx)(x.Z,{className:"w-4 h-4 ".concat(Z?"animate-spin":"")})})})]})]}),z&&(0,a.jsx)("div",{className:"p-4",children:(0,a.jsx)(S,{taskData:X,taskIndex:B,refreshFlag:D,setIsLoadingLogs:C,isLoadingLogs:Z})})]})})]}):(0,a.jsx)("div",{className:"flex items-center justify-center py-32",children:(0,a.jsx)("span",{children:"Task not found"})})]})]})}}},function(e){e.O(0,[5739,3850,9224,6612,2888,9774,179],function(){return e(e.s=53985)}),_N_E=e.O()}]);