skypilot-nightly 1.0.0.dev20250717__py3-none-any.whl → 1.0.0.dev20250718__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. sky/__init__.py +2 -2
  2. sky/client/sdk.py +1 -1
  3. sky/dashboard/out/404.html +1 -1
  4. sky/dashboard/out/_next/static/{Et5IQ5Y3WvH608nXClo4z → FUjweqdImyeYhMYFON-Se}/_buildManifest.js +1 -1
  5. sky/dashboard/out/_next/static/chunks/1043-734e57d2b27dfe5d.js +1 -0
  6. sky/dashboard/out/_next/static/chunks/8969-8e0b2055bf5dd499.js +1 -0
  7. sky/dashboard/out/_next/static/chunks/{9984.b56614f3c4c5961d.js → 9984.2b5e3fa69171bff9.js} +1 -1
  8. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-fa406155b4223d0d.js +11 -0
  9. sky/dashboard/out/_next/static/chunks/pages/jobs/{[job]-14d404b7dd28502a.js → [job]-c5b357bfd9502fbe.js} +1 -1
  10. sky/dashboard/out/_next/static/chunks/webpack-6b0575ea521af4f3.js +1 -0
  11. sky/dashboard/out/clusters/[cluster]/[job].html +1 -1
  12. sky/dashboard/out/clusters/[cluster].html +1 -1
  13. sky/dashboard/out/clusters.html +1 -1
  14. sky/dashboard/out/config.html +1 -1
  15. sky/dashboard/out/index.html +1 -1
  16. sky/dashboard/out/infra/[context].html +1 -1
  17. sky/dashboard/out/infra.html +1 -1
  18. sky/dashboard/out/jobs/[job].html +1 -1
  19. sky/dashboard/out/jobs.html +1 -1
  20. sky/dashboard/out/users.html +1 -1
  21. sky/dashboard/out/volumes.html +1 -1
  22. sky/dashboard/out/workspace/new.html +1 -1
  23. sky/dashboard/out/workspaces/[name].html +1 -1
  24. sky/dashboard/out/workspaces.html +1 -1
  25. sky/jobs/client/sdk.py +1 -1
  26. sky/jobs/server/core.py +14 -0
  27. sky/serve/client/sdk.py +1 -1
  28. sky/server/common.py +4 -0
  29. sky/server/rest.py +71 -26
  30. {skypilot_nightly-1.0.0.dev20250717.dist-info → skypilot_nightly-1.0.0.dev20250718.dist-info}/METADATA +1 -1
  31. {skypilot_nightly-1.0.0.dev20250717.dist-info → skypilot_nightly-1.0.0.dev20250718.dist-info}/RECORD +36 -36
  32. sky/dashboard/out/_next/static/chunks/1043-90a88c46f27b3df5.js +0 -1
  33. sky/dashboard/out/_next/static/chunks/8969-743abf4bc86baf48.js +0 -1
  34. sky/dashboard/out/_next/static/chunks/pages/clusters/[cluster]/[job]-9096ea50b8e2cf9e.js +0 -6
  35. sky/dashboard/out/_next/static/chunks/webpack-c3b45b7b0eaef66f.js +0 -1
  36. /sky/dashboard/out/_next/static/{Et5IQ5Y3WvH608nXClo4z → FUjweqdImyeYhMYFON-Se}/_ssgManifest.js +0 -0
  37. {skypilot_nightly-1.0.0.dev20250717.dist-info → skypilot_nightly-1.0.0.dev20250718.dist-info}/WHEEL +0 -0
  38. {skypilot_nightly-1.0.0.dev20250717.dist-info → skypilot_nightly-1.0.0.dev20250718.dist-info}/entry_points.txt +0 -0
  39. {skypilot_nightly-1.0.0.dev20250717.dist-info → skypilot_nightly-1.0.0.dev20250718.dist-info}/licenses/LICENSE +0 -0
  40. {skypilot_nightly-1.0.0.dev20250717.dist-info → skypilot_nightly-1.0.0.dev20250718.dist-info}/top_level.txt +0 -0
sky/__init__.py CHANGED
@@ -5,7 +5,7 @@ from typing import Optional
5
5
  import urllib.request
6
6
 
7
7
  # Replaced with the current commit when building the wheels.
8
- _SKYPILOT_COMMIT_SHA = '5ed1775c386bbd0cc4b9d1c80fc0d2d91b352870'
8
+ _SKYPILOT_COMMIT_SHA = '663a28261fc98dfa69214e1d4f1b0bb7b02664e0'
9
9
 
10
10
 
11
11
  def _get_git_commit():
@@ -35,7 +35,7 @@ def _get_git_commit():
35
35
 
36
36
 
37
37
  __commit__ = _get_git_commit()
38
- __version__ = '1.0.0.dev20250717'
38
+ __version__ = '1.0.0.dev20250718'
39
39
  __root_dir__ = os.path.dirname(os.path.abspath(__file__))
40
40
 
41
41
 
sky/client/sdk.py CHANGED
@@ -716,7 +716,7 @@ def exec( # pylint: disable=redefined-builtin
716
716
  @usage_lib.entrypoint
717
717
  @server_common.check_server_healthy_or_start
718
718
  @annotations.client_api
719
- @rest.retry_on_server_unavailable()
719
+ @rest.retry_transient_errors()
720
720
  def tail_logs(cluster_name: str,
721
721
  job_id: Optional[int],
722
722
  follow: bool,
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/219887b94512388c.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/219887b94512388c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-c3b45b7b0eaef66f.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-efc06c2733009cd3.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-c0a4f1ea606d48d2.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-771a40cde532309b.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c72a1f77a3c0be1b.js" defer=""></script><script src="/dashboard/_next/static/Et5IQ5Y3WvH608nXClo4z/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/Et5IQ5Y3WvH608nXClo4z/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"Et5IQ5Y3WvH608nXClo4z","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width"/><meta name="next-head-count" content="2"/><link rel="preload" href="/dashboard/_next/static/css/219887b94512388c.css" as="style"/><link rel="stylesheet" href="/dashboard/_next/static/css/219887b94512388c.css" data-n-g=""/><noscript data-n-css=""></noscript><script defer="" nomodule="" src="/dashboard/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js"></script><script src="/dashboard/_next/static/chunks/webpack-6b0575ea521af4f3.js" defer=""></script><script src="/dashboard/_next/static/chunks/framework-efc06c2733009cd3.js" defer=""></script><script src="/dashboard/_next/static/chunks/main-c0a4f1ea606d48d2.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_app-771a40cde532309b.js" defer=""></script><script src="/dashboard/_next/static/chunks/pages/_error-c72a1f77a3c0be1b.js" defer=""></script><script src="/dashboard/_next/static/FUjweqdImyeYhMYFON-Se/_buildManifest.js" defer=""></script><script src="/dashboard/_next/static/FUjweqdImyeYhMYFON-Se/_ssgManifest.js" defer=""></script></head><body><div id="__next"></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":404}},"page":"/_error","query":{},"buildId":"FUjweqdImyeYhMYFON-Se","assetPrefix":"/dashboard","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -1 +1 @@
1
- self.__BUILD_MANIFEST=function(s,c,a,e,t,f,u,n,r,i,b,j,k,d,o){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-927ddeebe57a8ac3.js"],"/_error":["static/chunks/pages/_error-c72a1f77a3c0be1b.js"],"/clusters":["static/chunks/pages/clusters-102d169e87913ba1.js"],"/clusters/[cluster]":[s,c,a,e,t,r,b,f,u,n,j,i,k,d,o,"static/chunks/1871-76491ac174a95278.js","static/chunks/pages/clusters/[cluster]-0c37ee1ac5f3474d.js"],"/clusters/[cluster]/[job]":[s,c,a,e,t,f,u,n,"static/chunks/pages/clusters/[cluster]/[job]-9096ea50b8e2cf9e.js"],"/config":["static/chunks/pages/config-a2673b256b6d416f.js"],"/infra":["static/chunks/pages/infra-ae9d2f705ce582c9.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-8b0809f59034d509.js"],"/jobs":["static/chunks/pages/jobs-5bbdc71878f0a068.js"],"/jobs/[job]":[s,c,a,e,t,r,f,u,n,i,"static/chunks/pages/jobs/[job]-14d404b7dd28502a.js"],"/users":["static/chunks/pages/users-19e98664bdd61643.js"],"/volumes":["static/chunks/pages/volumes-61ea7ba7e56f8d06.js"],"/workspace/new":["static/chunks/pages/workspace/new-5629d4e551dba1ee.js"],"/workspaces":["static/chunks/pages/workspaces-a1e43d9ef51a9cea.js"],"/workspaces/[name]":[s,c,a,e,t,r,b,f,u,n,j,i,k,d,o,"static/chunks/1141-d8c6404a7c6fffe6.js","static/chunks/pages/workspaces/[name]-7c0187f43757a548.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/[job]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/616-162f3033ffcd3d31.js","static/chunks/5230-df791914b54d91d9.js","static/chunks/5739-5ea3ffa10fc884f2.js","static/chunks/1664-d65361e92b85e786.js","static/chunks/804-9f5e98ce84d46bdd.js","static/chunks/6989-eab0e9c16b64fd9f.js","static/chunks/3698-9fa11dafb5cad4a6.js","static/chunks/9470-b6f6a35283863a6f.js","static/chunks/1272-1ef0bf0237faccdb.js","static/chunks/8969-743abf4bc86baf48.js","static/chunks/3947-b059261d6fa88a1f.js","static/chunks/6990-dcb411b566e64cde.js","static/chunks/1043-90a88c46f27b3df5.js","static/chunks/6601-d4a381403a8bae91.js","static/chunks/938-6a9ffdaa21eee969.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
1
+ self.__BUILD_MANIFEST=function(s,c,a,e,t,f,u,n,r,b,i,j,d,k,o){return{__rewrites:{afterFiles:[],beforeFiles:[],fallback:[]},"/":["static/chunks/pages/index-927ddeebe57a8ac3.js"],"/_error":["static/chunks/pages/_error-c72a1f77a3c0be1b.js"],"/clusters":["static/chunks/pages/clusters-102d169e87913ba1.js"],"/clusters/[cluster]":[s,c,a,e,t,r,i,f,u,n,j,b,d,k,o,"static/chunks/1871-76491ac174a95278.js","static/chunks/pages/clusters/[cluster]-0c37ee1ac5f3474d.js"],"/clusters/[cluster]/[job]":[s,c,a,e,t,f,u,n,"static/chunks/pages/clusters/[cluster]/[job]-fa406155b4223d0d.js"],"/config":["static/chunks/pages/config-a2673b256b6d416f.js"],"/infra":["static/chunks/pages/infra-ae9d2f705ce582c9.js"],"/infra/[context]":["static/chunks/pages/infra/[context]-8b0809f59034d509.js"],"/jobs":["static/chunks/pages/jobs-5bbdc71878f0a068.js"],"/jobs/[job]":[s,c,a,e,t,r,f,u,n,b,"static/chunks/pages/jobs/[job]-c5b357bfd9502fbe.js"],"/users":["static/chunks/pages/users-19e98664bdd61643.js"],"/volumes":["static/chunks/pages/volumes-61ea7ba7e56f8d06.js"],"/workspace/new":["static/chunks/pages/workspace/new-5629d4e551dba1ee.js"],"/workspaces":["static/chunks/pages/workspaces-a1e43d9ef51a9cea.js"],"/workspaces/[name]":[s,c,a,e,t,r,i,f,u,n,j,b,d,k,o,"static/chunks/1141-d8c6404a7c6fffe6.js","static/chunks/pages/workspaces/[name]-7c0187f43757a548.js"],sortedPages:["/","/_app","/_error","/clusters","/clusters/[cluster]","/clusters/[cluster]/[job]","/config","/infra","/infra/[context]","/jobs","/jobs/[job]","/users","/volumes","/workspace/new","/workspaces","/workspaces/[name]"]}}("static/chunks/616-162f3033ffcd3d31.js","static/chunks/5230-df791914b54d91d9.js","static/chunks/5739-5ea3ffa10fc884f2.js","static/chunks/1664-d65361e92b85e786.js","static/chunks/804-9f5e98ce84d46bdd.js","static/chunks/6989-eab0e9c16b64fd9f.js","static/chunks/3698-9fa11dafb5cad4a6.js","static/chunks/9470-b6f6a35283863a6f.js","static/chunks/1272-1ef0bf0237faccdb.js","static/chunks/8969-8e0b2055bf5dd499.js","static/chunks/3947-b059261d6fa88a1f.js","static/chunks/6990-dcb411b566e64cde.js","static/chunks/1043-734e57d2b27dfe5d.js","static/chunks/6601-d4a381403a8bae91.js","static/chunks/938-6a9ffdaa21eee969.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1043],{326:function(e,t,a){a.d(t,{$N:function(){return p},Be:function(){return _},Vq:function(){return c},cN:function(){return f},cZ:function(){return d},fK:function(){return g}});var r=a(5893),s=a(7294),o=a(6327),n=a(2350),l=a(3767);let c=o.fC;o.xz;let u=o.h_;o.x8;let i=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.aV,{ref:t,className:(0,n.cn)("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",a),...s})});i.displayName=o.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:a,children:s,...c}=e;return(0,r.jsxs)(u,{children:[(0,r.jsx)(i,{}),(0,r.jsxs)(o.VY,{ref:t,className:(0,n.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border border-gray-200 bg-white p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",a),...c,children:[s,(0,r.jsxs)(o.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-gray-100 data-[state=open]:text-gray-500",children:[(0,r.jsx)(l.Z,{className:"h-4 w-4"}),(0,r.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});d.displayName=o.VY.displayName;let g=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...a})};g.displayName="DialogHeader";let f=e=>{let{className:t,...a}=e;return(0,r.jsx)("div",{className:(0,n.cn)("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a})};f.displayName="DialogFooter";let p=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.Dx,{ref:t,className:(0,n.cn)("text-lg font-semibold leading-none tracking-tight",a),...s})});p.displayName=o.Dx.displayName;let _=s.forwardRef((e,t)=>{let{className:a,...s}=e;return(0,r.jsx)(o.dk,{ref:t,className:(0,n.cn)("text-sm text-gray-500",a),...s})});_.displayName=o.dk.displayName},3266:function(e,t,a){a.d(t,{QL:function(){return g},Sl:function(){return i},getClusters:function(){return c},uR:function(){return u}});var r=a(7294),s=a(5821),o=a(7145),n=a(6378);let l={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function c(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await o.x.fetch("/status",{cluster_names:e,all_users:!0})).map(e=>{let t="",a=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let a=Math.floor((t-3)/2),r=a+(t-3)%2;return 0===a?e.substring(0,r)+"...":e.substring(0,r)+"..."+e.substring(e.length-a)}(t,25)),{status:l[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:a?"".concat(e.cloud," (").concat(a,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,to_down:e.to_down,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){return console.error("Error fetching clusters:",e),[]}}async function u(){try{let e=await o.x.fetch("/cost_report",{days:30});console.log("Raw cluster history data:",e);let t=e.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let a=e.user_name||"-";return{status:e.status?l[e.status]:"TERMINATED",cluster:e.name,user:a,user_hash:e.user_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,to_down:!1,cluster_hash:e.cluster_hash,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",t),t}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function i(e){let{clusterName:t,jobId:a,onNewLog:r,workspace:n}=e;try{await o.x.stream("/logs",{follow:!1,cluster_name:t,job_id:a,override_skypilot_config:{active_workspace:n||"default"}},r)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,s.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function d(e){let{clusterName:t,workspace:a}=e;try{return(await o.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:a}})).map(e=>{var r;let s=e.end_at?e.end_at:Date.now()/1e3,o=0,n=0;return e.submitted_at&&(o=s-e.submitted_at),e.start_at&&(n=s-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,user_hash:e.user_hash,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:o,job_duration:n,infra:"",logs:"",workspace:a||"default",git_commit:(null===(r=e.metadata)||void 0===r?void 0:r.git_commit)||"-"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function g(e){let{cluster:t,job:a=null}=e,[s,o]=(0,r.useState)(null),[l,u]=(0,r.useState)(null),[i,g]=(0,r.useState)(!0),[f,p]=(0,r.useState)(!0),_=(0,r.useCallback)(async()=>{if(t)try{g(!0);let e=await n.default.get(c,[{clusterNames:[t]}]);return o(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{g(!1)}return null},[t]),m=(0,r.useCallback)(async e=>{if(t)try{p(!0);let a=await n.default.get(d,[{clusterName:t,workspace:e||"default"}]);u(a)}catch(e){console.error("Error fetching cluster job data:",e)}finally{p(!1)}},[t]),h=(0,r.useCallback)(async()=>{n.default.invalidate(c,[{clusterNames:[t]}]);let e=await _();e&&(n.default.invalidate(d,[{clusterName:t,workspace:e.workspace||"default"}]),await m(e.workspace))},[_,m,t]),b=(0,r.useCallback)(async()=>{s&&(n.default.invalidate(d,[{clusterName:t,workspace:s.workspace||"default"}]),await m(s.workspace))},[m,s,t]);return(0,r.useEffect)(()=>{(async()=>{let e=await _();e&&m(e.workspace)})()},[t,a,_,m]),{clusterData:s,clusterJobData:l,loading:i,clusterDetailsLoading:i,clusterJobsLoading:f,refreshData:h,refreshClusterJobsOnly:b}}},2045:function(e,t,a){a.d(t,{l4:function(){return n}});var r=a(3225),s=a(7145);async function o(e,t){try{let a=[];try{let e=await s.x.get("/enabled_clouds"),t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("X-Request-ID"),r=await s.x.get("/api/get?request_id=".concat(t)),o=await r.json();a=o.return_value?JSON.parse(o.return_value):[],console.log("Enabled clouds:",a)}catch(e){console.error("Error fetching enabled clouds:",e),a=[]}let o={};r.$m.forEach(e=>{let t=a.includes(e.toLowerCase());o[e]={name:e,clusters:0,jobs:0,enabled:t}}),e.forEach(e=>{if(e.cloud){let t=e.cloud;o[t]&&(o[t].clusters+=1,o[t].enabled=!0)}}),t.forEach(e=>{if(e.cloud){let t=e.cloud;o[t]&&(o[t].jobs+=1,o[t].enabled=!0)}});let n=r.$m.length,l=Object.values(o).filter(e=>e.enabled).length;return{clouds:Object.values(o).filter(e=>e.enabled).sort((e,t)=>e.name.localeCompare(t.name)),totalClouds:n,enabledClouds:l}}catch(e){return console.error("Error fetching cloud infrastructure:",e),{clouds:[],totalClouds:r.$m.length,enabledClouds:0}}}async function n(){let{getClusters:e}=await Promise.resolve().then(a.bind(a,3266)),{getManagedJobs:t}=await Promise.resolve().then(a.bind(a,8969)),r=(await Promise.resolve().then(a.bind(a,6378))).default,[s,n]=await Promise.all([r.get(e),r.get(t,[{allUsers:!0}])]),c=s||[],u=(null==n?void 0:n.jobs)||[],[i,d]=await Promise.all([l(c,u),o(c,u)]);return{gpuData:i,cloudData:d}}async function l(e,t){return await g({clusters:e||[],jobs:t||[]})}async function c(){try{let e=await s.x.post("/realtime_kubernetes_gpu_availability",{context:null,name_filter:null,quantity_filter:null});if(!e.ok)return console.error("Error fetching Kubernetes context GPUs (in getKubernetesContextGPUs): ".concat(e.status," ").concat(e.statusText)),[];let t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("x-request-id");if(!t)return console.error("No request ID returned for Kubernetes GPU availability (in getKubernetesContextGPUs)"),[];let a=await s.x.get("/api/get?request_id=".concat(t)),r=await a.text();if(500===a.status){try{let e=JSON.parse(r);if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);console.error("[infra.jsx] getKubernetesContextGPUs: Server error detail:",t.message)}catch(t){console.error("[infra.jsx] getKubernetesContextGPUs: Error parsing server error JSON:",t,"Original error text:",e.detail.error)}}catch(e){console.error("[infra.jsx] getKubernetesContextGPUs: Error parsing 500 error response JSON:",e,"Raw text was:",r)}return[]}let o=JSON.parse(r);return o.return_value?JSON.parse(o.return_value):[]}catch(e){return console.error("[infra.jsx] Outer error in getKubernetesContextGPUs:",e),[]}}async function u(){try{let e=await s.x.get("/all_contexts");if(!e.ok)return console.error("Error fetching all contexts: ".concat(e.status," ").concat(e.statusText)),[];let t=e.headers.get("X-Skypilot-Request-ID")||e.headers.get("x-request-id");if(!t)return console.error("No request ID returned for /all_contexts"),[];let a=await s.x.get("/api/get?request_id=".concat(t)),r=await a.json();return r.return_value?JSON.parse(r.return_value):[]}catch(e){return console.error("[infra.jsx] Error in getAllContexts:",e),[]}}async function i(e){try{let t=await s.x.post("/kubernetes_node_info",{context:e}),a=t.headers.get("X-Skypilot-Request-ID")||t.headers.get("x-request-id"),r=await s.x.get("/api/get?request_id=".concat(a));if(500===r.status){try{let e=await r.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);console.error("Error fetching Kubernetes per node GPUs:",t.message)}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{}}let o=await r.json();return(o.return_value?JSON.parse(o.return_value):{}).node_info_dict||{}}catch(t){return console.error("[infra.jsx] Error in getKubernetesPerNodeGPUs for context",e,":",t),{}}}async function d(e){try{let t=e.clusters,a=e.jobs,r={};return t.forEach(e=>{let t=null;if("Kubernetes"===e.cloud)(t=e.region)&&(t="kubernetes/".concat(t));else if("SSH"===e.cloud&&(t=e.region)){let e=t.startsWith("ssh-")?t.substring(4):t;t="ssh/".concat(e)}t&&(r[t]||(r[t]={clusters:0,jobs:0}),r[t].clusters+=1)}),a.forEach(e=>{let t=null;if("Kubernetes"===e.cloud)(t=e.region)&&(t="kubernetes/".concat(t));else if("SSH"===e.cloud&&(t=e.region)){let e=t.startsWith("ssh-")?t.substring(4):t;t="ssh/".concat(e)}t&&(r[t]||(r[t]={clusters:0,jobs:0}),r[t].jobs+=1)}),r}catch(e){return console.error("=== Error in getContextClustersAndJobs ===",e),{}}}async function g(e){try{let o=await u();if(!o||0===o.length)return console.log("No contexts found from /all_contexts endpoint."),{allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{}};let n=await d(e),l=await c(),g=new Map;l&&l.forEach(e=>{g.set(e[0],e[1])});let f={},p={},_={};for(let e of o){p[e]||(p[e]=[]);let o=g.get(e);if(o&&o.length>0)for(let t of o){let a=t[0],r=t[1].join(", "),s=t[2],o=t[3];a in f?(f[a].gpu_total+=s,f[a].gpu_free+=o):f[a]={gpu_total:s,gpu_free:o,gpu_name:a},p[e].push({gpu_name:a,gpu_requestable_qty_per_node:r,gpu_total:s,gpu_free:o,context:e})}let n=await i(e);if(n&&Object.keys(n).length>0)for(let o in n){var t,a,r,s;let l=n[o],c=l.accelerator_type||"-",u=null!==(r=null===(t=l.total)||void 0===t?void 0:t.accelerator_count)&&void 0!==r?r:0,i=null!==(s=null===(a=l.free)||void 0===a?void 0:a.accelerators_available)&&void 0!==s?s:0;_["".concat(e,"/").concat(o)]={node_name:l.name,gpu_name:c,gpu_total:u,gpu_free:i,ip_address:l.ip_address||null,context:e},"-"===c||p[e].some(e=>e.gpu_name===c)||(c in f||(f[c]={gpu_total:0,gpu_free:0,gpu_name:c}),p[e].find(e=>e.gpu_name===c)||p[e].push({gpu_name:c,gpu_requestable_qty_per_node:"-",gpu_total:0,gpu_free:0,context:e}))}0===p[e].length&&n&&Object.keys(n).length}return{allContextNames:o.sort(),allGPUs:Object.values(f).sort((e,t)=>e.gpu_name.localeCompare(t.gpu_name)),perContextGPUs:Object.values(p).flat().sort((e,t)=>e.context.localeCompare(t.context)||e.gpu_name.localeCompare(t.gpu_name)),perNodeGPUs:Object.values(_).sort((e,t)=>e.context.localeCompare(t.context)||e.node_name.localeCompare(t.node_name)||e.gpu_name.localeCompare(t.gpu_name)),contextStats:n}}catch(e){return console.error("[infra.jsx] Outer error in getKubernetesGPUs:",e),{allContextNames:[],allGPUs:[],perContextGPUs:[],perNodeGPUs:[],contextStats:{}}}}},3081:function(e,t,a){a.d(t,{R:function(){return s}}),a(3266),a(8969);var r=a(7145);async function s(){try{let e=await r.x.get("/users");if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return(await e.json()).map(e=>({userId:e.id,username:e.name,role:e.role,created_at:e.created_at}))||[]}catch(e){return console.error("Failed to fetch users:",e),[]}}},9238:function(e,t,a){a.d(t,{C:function(){return s},w:function(){return o}});var r=a(7145);async function s(){try{return(await r.x.fetch("/volumes",{},"GET")).map(e=>{var t,a,r;let s=e.cloud||"";return e.region&&(s+="/".concat(e.region)),e.zone&&(s+="/".concat(e.zone)),{name:e.name,launched_at:e.launched_at,user_hash:e.user_hash,user_name:e.user_name||"-",workspace:e.workspace||"-",last_attached_at:e.last_attached_at,status:e.status,type:e.type,cloud:e.cloud,region:e.region,zone:e.zone,infra:s,size:"".concat(e.size,"Gi"),config:e.config,storage_class:(null===(t=e.config)||void 0===t?void 0:t.storage_class_name)||"-",access_mode:(null===(a=e.config)||void 0===a?void 0:a.access_mode)||"-",namespace:(null===(r=e.config)||void 0===r?void 0:r.namespace)||"-",name_on_cloud:e.name_on_cloud,usedby_pods:e.usedby_pods,usedby_clusters:e.usedby_clusters}})||[]}catch(e){return console.error("Failed to fetch volumes:",e),[]}}async function o(e){let t="";try{let a=(await r.x.post("/volumes/delete",{names:[e]})).headers.get("X-Request-ID"),s=await r.x.get("/api/get?request_id=".concat(a));if(500===s.status){try{let e=await s.json();if(e.detail&&e.detail.error)try{t=JSON.parse(e.detail.error).message}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{success:!1,msg:t}}return{success:!0}}catch(e){return console.error("Failed to delete volume:",e),{success:!1,msg:e.message}}}},6856:function(e,t,a){var r=a(6378),s=a(3266),o=a(8969),n=a(7324),l=a(3081),c=a(2045),u=a(9238);let i={base:{getClusters:{fn:s.getClusters,args:[]},getClusterHistory:{fn:s.uR,args:[]},getManagedJobs:{fn:o.getManagedJobs,args:[{allUsers:!0}]},getWorkspaces:{fn:n.fX,args:[]},getUsers:{fn:l.R,args:[]},getInfraData:{fn:c.l4,args:[]},getVolumes:{fn:u.C,args:[]}},dynamic:{getEnabledClouds:{fn:n.yz,requiresWorkspaces:!0}},pages:{clusters:["getClusters","getClusterHistory","getWorkspaces","getUsers"],jobs:["getManagedJobs","getClusters","getWorkspaces","getUsers"],infra:["getInfraData","getClusters","getManagedJobs"],workspaces:["getWorkspaces","getClusters","getManagedJobs","getEnabledClouds"],users:["getUsers","getClusters","getManagedJobs"],volumes:["getVolumes"]}};class d{async preloadForPage(e,t){let{backgroundPreload:a=!0,force:r=!1}=t||{};if(!i.pages[e]){console.warn("Unknown page: ".concat(e));return}console.log("[CachePreloader] Preloading cache for page: ".concat(e));try{await this._loadPageData(e,r),a&&this._backgroundPreloadOtherPages(e)}catch(t){console.error("[CachePreloader] Error preloading for page ".concat(e,":"),t)}}async _loadPageData(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=i.pages[e],s=[];for(let e of a)if(i.base[e]){let{fn:a,args:o}=i.base[e];t&&r.default.invalidate(a,o),s.push(r.default.get(a,o))}else"getEnabledClouds"===e&&s.push(this._loadEnabledCloudsForAllWorkspaces(t));await Promise.allSettled(s),console.log("[CachePreloader] Loaded data for page: ".concat(e))}async _loadEnabledCloudsForAllWorkspaces(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{e&&r.default.invalidate(n.fX);let t=await r.default.get(n.fX),a=Object.keys(t||{}).map(t=>(e&&r.default.invalidate(n.yz,[t]),r.default.get(n.yz,[t])));await Promise.allSettled(a)}catch(e){console.error("[CachePreloader] Error loading enabled clouds:",e)}}_backgroundPreloadOtherPages(e){if(this.isPreloading)return;this.isPreloading=!0;let t=Object.keys(i.pages).filter(t=>t!==e);console.log("[CachePreloader] Background preloading pages: ".concat(t.join(", "))),Promise.allSettled(t.map(async e=>{try{await this._loadPageData(e,!1),console.log("[CachePreloader] Background loaded: ".concat(e))}catch(t){console.error("[CachePreloader] Background load failed for ".concat(e,":"),t)}})).then(()=>{this.isPreloading=!1,console.log("[CachePreloader] Background preloading complete")})}async preloadBaseFunctions(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];console.log("[CachePreloader] Preloading all base functions");let t=Object.entries(i.base).map(t=>{let[a,{fn:s,args:o}]=t;return e&&r.default.invalidate(s,o),r.default.get(s,o).catch(e=>{console.error("[CachePreloader] Failed to preload ".concat(a,":"),e)})});await Promise.allSettled(t),console.log("[CachePreloader] Base functions preloaded")}getCacheStats(){return{...r.default.getStats(),isPreloading:this.isPreloading}}clearCache(){r.default.clear(),this.isPreloading=!1,this.preloadPromises.clear(),console.log("[CachePreloader] Cache cleared")}constructor(){this.isPreloading=!1,this.preloadPromises=new Map}}let g=new d;t.ZP=g}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8969],{8969:function(e,t,r){r.d(t,{Ce:function(){return u},NJ:function(){return d},UA:function(){return l},getManagedJobs:function(){return i}});var o=r(7294),a=r(5821),n=r(3225),c=r(6378),s=r(7145);async function i(){let{allUsers:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{let t=(await s.x.post("/jobs/queue",{all_users:e,verbose:!0})).headers.get("X-Skypilot-Request-ID"),r=await s.x.get("/api/get?request_id=".concat(t));if(500===r.status){try{let e=await r.json();if(e.detail&&e.detail.error)try{let t=JSON.parse(e.detail.error);if(t.type&&t.type===n.iW)return{jobs:[],controllerStopped:!0}}catch(e){console.error("Error parsing JSON:",e)}}catch(e){console.error("Error parsing JSON:",e)}return{jobs:[],controllerStopped:!1}}let o=await r.json();return{jobs:(o.return_value?JSON.parse(o.return_value):[]).map(e=>{var t;let r=[];e.submitted_at&&r.push({time:new Date(1e3*e.submitted_at),event:"Job submitted."}),e.start_at&&r.push({time:new Date(1e3*e.start_at),event:"Job started."}),e.end_at&&("CANCELLING"==e.status||"CANCELLED"==e.status?r.push({time:new Date(1e3*e.end_at),event:"Job cancelled."}):r.push({time:new Date(1e3*e.end_at),event:"Job completed."})),e.last_recovered_at&&e.last_recovered_at!=e.start_at&&r.push({time:new Date(1e3*e.last_recovered_at),event:"Job recovered."});let o=(e.end_at?e.end_at:Date.now()/1e3)-e.submitted_at,a=e.cloud,n=e.cluster_resources;if(!a){if(e.cluster_resources&&"-"!==e.cluster_resources)try{a=e.cluster_resources.split("(")[0].split("x").pop().trim(),n=e.cluster_resources.replace("".concat(a,"("),"(").replace("x ","x")}catch(e){a="Unknown"}else a="Unknown"}let c="",s=c=e.zone?e.zone:e.region;c&&c.length>15&&(c="".concat(c.substring(0,Math.floor(6)),"...").concat(c.substring(c.length-Math.ceil(6))));let i=a+" ("+c+")";"-"===c&&(i=a);let l=a+" ("+s+")";return"-"===s&&(l=a),{id:e.job_id,task:e.task_name,name:e.job_name,job_duration:e.job_duration,total_duration:o,workspace:e.workspace,status:e.status,requested_resources:e.resources,resources_str:n,resources_str_full:e.cluster_resources_full||n,cloud:a,region:e.region,infra:i,full_infra:l,recoveries:e.recovery_count,details:e.details||e.failure_reason,user:e.user_name,user_hash:e.user_hash,submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,events:r,dag_yaml:e.user_yaml,entrypoint:e.entrypoint,git_commit:(null===(t=e.metadata)||void 0===t?void 0:t.git_commit)||"-"}}),controllerStopped:!1}}catch(e){return console.error("Error fetching managed job data:",e),{jobs:[],controllerStopped:!1}}}function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,[r,a]=(0,o.useState)(null),[n,s]=(0,o.useState)(!0);return(0,o.useEffect)(()=>{(async function(){if(e)try{var t;s(!0);let r=await c.default.get(i,[{allUsers:!0}]),o=null==r?void 0:null===(t=r.jobs)||void 0===t?void 0:t.find(t=>String(t.id)===String(e));o?a({jobs:[o],controllerStopped:r.controllerStopped||!1}):a({jobs:[],controllerStopped:r.controllerStopped||!1})}catch(e){console.error("Error fetching single managed job data:",e),a({jobs:[],controllerStopped:!1})}finally{s(!1)}})()},[e,t]),{jobData:r,loading:n}}async function d(e){let t,{jobId:r,controller:o=!1,signal:c,onNewLog:s}=e,i=Date.now(),l=new Promise(e=>{let r=()=>{let o=Date.now()-i;o>=3e4?e({timeout:!0}):t=setTimeout(r,3e4-o)};t=setTimeout(r,3e4)}),d=window.location.origin,u="".concat(d).concat(n.f4),h=(async()=>{try{let e=(await fetch("".concat(u,"/jobs/logs"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({controller:o,follow:!1,job_id:r,tail:1e3}),...c?{signal:c}:{}})).body.getReader();try{for(;;){let{done:t,value:r}=await e.read();if(t)break;i=Date.now();let o=new TextDecoder().decode(r);s(o)}}finally{if(!c||!c.aborted)try{e.cancel()}catch(e){"AbortError"!==e.name&&console.warn("Error canceling reader:",e)}t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),b=await Promise.race([h,l]);if(t&&clearTimeout(t),b.timeout){(0,a.C)("Log request for job ".concat(r," timed out after ").concat(30,"s of inactivity"),"warning");return}}async function u(e,t,r){let o="",c="",s="",i={};if("restartcontroller"===e)o="Restarting",c="restarted",s="jobs/queue",i={all_users:!0,refresh:!0},t="controller";else throw Error("Invalid action: ".concat(e));(0,a.C)("".concat(o," job ").concat(t,"..."),"info");let l=window.location.origin,d="".concat(l).concat(n.f4);try{try{let e=(await fetch("".concat(d,"/").concat(s),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})).headers.get("X-Skypilot-Request-ID"),l=await fetch("".concat(d,"/api/get?request_id=").concat(e));if(200===l.status)(0,a.C)("Job ".concat(t," ").concat(c," successfully."),"success");else if(500===l.status)try{let e=await l.json();if(e.detail&&e.detail.error)try{let c=JSON.parse(e.detail.error);c.type&&c.type===n.Bo?(0,a.C)("".concat(o," job ").concat(t," is not supported!"),"error",1e4):c.type&&c.type===n.mF?(0,a.C)("Cluster ".concat(r," does not exist."),"error"):c.type&&c.type===n.iW?(0,a.C)("Cluster ".concat(r," is not up."),"error"):(0,a.C)("".concat(o," job ").concat(t," failed: ").concat(c.type),"error")}catch(r){(0,a.C)("".concat(o," job ").concat(t," failed: ").concat(e.detail.error),"error")}else(0,a.C)("".concat(o," job ").concat(t," failed with no details."),"error")}catch(e){(0,a.C)("".concat(o," job ").concat(t," failed with parse error."),"error")}else(0,a.C)("".concat(o," job ").concat(t," failed with status ").concat(l.status,"."),"error")}catch(e){console.error("Fetch error:",e),(0,a.C)("Network error ".concat(o," job ").concat(t,": ").concat(e.message),"error")}}catch(e){console.error("Error in handleStop:",e),(0,a.C)("Critical error ".concat(o," job ").concat(t,": ").concat(e.message),"error")}}},5821:function(e,t,r){r.d(t,{C:function(){return o}});function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,o=document.getElementById("toast-container");o||((o=document.createElement("div")).id="toast-container",o.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(o));let a=document.createElement("div");switch(a.className="rounded-md border-l-4 p-4 shadow-md flex items-center justify-between max-w-md w-full mb-2 pointer-events-auto",t){case"success":a.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":a.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":a.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:a.className+=" bg-blue-100 border-blue-500 text-blue-800"}return a.innerHTML='\n <div class="flex-1 mr-2">\n <p class="text-sm font-medium">'.concat(e,'</p>\n </div>\n <button class="text-gray-500 hover:text-gray-700 focus:outline-none" aria-label="Close toast">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n '),o.appendChild(a),a.querySelector("button").addEventListener("click",()=>{o.removeChild(a)}),setTimeout(()=>{o.contains(a)&&o.removeChild(a)},r),a}},6378:function(e,t,r){r.r(t),r.d(t,{DashboardCache:function(){return a},dashboardCache:function(){return n}});let o=r(1214).ej.DEFAULT_TTL;class a{async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=r.ttl||o,n=!1!==r.refreshOnAccess,c=this._generateKey(e,t),s=e.name||"anonymous",i=this.cache.get(c),l=Date.now();if(i&&l-i.lastUpdated<a){let r=Math.round((l-i.lastUpdated)/1e3);return this._debug("Cache HIT for ".concat(s," (age: ").concat(r,"s, TTL: ").concat(Math.round(a/1e3),"s)")),n&&(this.cache.set(c,{data:i.data,lastUpdated:l}),this._debug("Cache TTL refreshed for ".concat(s))),this.backgroundJobs.has(c)||this._refreshInBackground(e,t,c),i.data}try{let r=await e(...t);return this.cache.set(c,{data:r,lastUpdated:l}),r}catch(e){if(i)return console.warn("Failed to fetch fresh data for ".concat(c,", returning stale data:"),e),i.data;throw e}}invalidate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=this._generateKey(e,t);this.cache.delete(r),this.backgroundJobs.delete(r)}invalidateFunction(e){let t=e.name||"anonymous",r=[];for(let e of this.cache.keys())e.startsWith("".concat(t,"_"))&&r.push(e);r.forEach(e=>{this.cache.delete(e),this.backgroundJobs.delete(e)})}clear(){this.cache.clear(),this.backgroundJobs.clear()}getStats(){return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,keys:Array.from(this.cache.keys())}}getDetailedStats(){let e=Date.now(),t=[];for(let[r,o]of this.cache.entries()){let a=e-o.lastUpdated;t.push({key:r,age:Math.round(a/1e3),lastUpdated:new Date(o.lastUpdated).toISOString(),hasBackgroundJob:this.backgroundJobs.has(r)})}return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,entries:t.sort((e,t)=>e.age-t.age)}}setDebugMode(e){this.debugMode=e}_debug(e){for(var t=arguments.length,r=Array(t>1?t-1:0),o=1;o<t;o++)r[o-1]=arguments[o];this.debugMode&&console.log("[DashboardCache] ".concat(e),...r)}_refreshInBackground(e,t,r){this.backgroundJobs.set(r,!0),e(...t).then(e=>{this.cache.set(r,{data:e,lastUpdated:Date.now()})}).catch(e=>{console.warn("Background refresh failed for ".concat(r,":"),e)}).finally(()=>{this.backgroundJobs.delete(r)})}_generateKey(e,t){let r=function(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r);return t>>>0}(e.toString()),o=t.length>0?JSON.stringify(t):"";return"".concat(r,"_").concat(o)}constructor(){this.cache=new Map,this.backgroundJobs=new Map,this.debugMode=!1}}let n=new a;t.default=n}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9984],{9984:function(e,t,s){s.r(t),s.d(t,{ContextDetails:function(){return L},GPUs:function(){return Z},InfrastructureSection:function(){return A}});var a=s(5893),r=s(7294),l=s(5739);s(9470);var o=s(6409),n=s(8418),c=s(3626),i=s(3001),d=s(7853),m=s(2045),u=s(3266),h=s(8969),x=s(3225),g=s(5821);async function p(){try{let e=await fetch("".concat(x.f4,"/ssh_node_pools"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return await e.json()}catch(e){return console.error("Error fetching SSH Node Pools:",e),{}}}async function f(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error updating SSH Node Pools:",e),e}}async function y(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e),{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deleting SSH Node Pool:",e),e}}async function j(e,t){try{let s=new FormData;s.append("key_name",e),s.append("key_file",t);let a=await fetch("".concat(x.f4,"/ssh_node_pools/keys"),{method:"POST",body:s});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));return await a.json()}catch(e){throw console.error("Error uploading SSH key:",e),e}}async function N(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/deploy"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deploying SSH Node Pool:",e),e}}async function b(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/down"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error tearing down SSH Node Pool:",e),e}}async function w(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/status"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error fetching SSH Node Pool status:",e),e}}async function v(e){let t,{requestId:s,signal:a,onNewLog:r}=e,l=Date.now(),o=new Promise(e=>{let s=()=>{let a=Date.now()-l;a>=3e5?e({timeout:!0}):t=setTimeout(s,3e5-a)};t=setTimeout(s,3e5)}),n=(async()=>{try{let e=await fetch("".concat(x.f4,"/api/stream?request_id=").concat(s,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...a?{signal:a}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let o=e.body.getReader();try{for(;;){let{done:e,value:t}=await o.read();if(e)break;l=Date.now();let s=new TextDecoder().decode(t);r(s)}}finally{o.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),c=await Promise.race([n,o]);if(t&&clearTimeout(t),c.timeout){(0,g.C)("SSH deployment log stream timed out after ".concat(300,"s of inactivity"),"warning");return}}async function S(e){let t,{requestId:s,signal:a,onNewLog:r,operationType:l="operation"}=e,o=Date.now(),n=new Promise(e=>{let s=()=>{let a=Date.now()-o;a>=3e5?e({timeout:!0}):t=setTimeout(s,3e5-a)};t=setTimeout(s,3e5)}),c=(async()=>{try{let e=await fetch("".concat(x.f4,"/api/stream?request_id=").concat(s,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...a?{signal:a}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let l=e.body.getReader();try{for(;;){let{done:e,value:t}=await l.read();if(e)break;o=Date.now();let s=new TextDecoder().decode(t);r(s)}}finally{l.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),i=await Promise.race([c,n]);if(t&&clearTimeout(t),i.timeout){(0,g.C)("SSH ".concat(l," log stream timed out after ").concat(300,"s of inactivity"),"warning");return}}var _=s(326),C=s(803),P=s(2557),k=s(6185),T=s(9123);function E(e){let{isOpen:t,onClose:s,onSave:o,poolData:n=null,isLoading:c=!1}=e,[i,d]=(0,r.useState)(""),[m,u]=(0,r.useState)(""),[h,x]=(0,r.useState)("ubuntu"),[g,p]=(0,r.useState)(null),[f,y]=(0,r.useState)(""),[N,b]=(0,r.useState)({}),w=null!==n;(0,r.useEffect)(()=>{if(w&&n){var e,t,s;d(n.name||""),u(((null===(e=n.config)||void 0===e?void 0:e.hosts)||[]).join("\n")),x((null===(t=n.config)||void 0===t?void 0:t.user)||"ubuntu"),y((null===(s=n.config)||void 0===s?void 0:s.password)||"")}else d(""),u(""),x("ubuntu"),p(null),y("");b({})},[w,n]);let v=()=>{let e={};return i.trim()||(e.poolName="Pool name is required"),m.trim()||(e.hosts="At least one host is required"),h.trim()||(e.sshUser="SSH user is required"),g||f||(e.auth="Either SSH key file or password is required"),b(e),0===Object.keys(e).length},S=async()=>{if(!v())return;let e={hosts:m.split("\n").map(e=>e.trim()).filter(e=>e.length>0),user:h};try{if(g){let t=g.name;await j(t,g),e.identity_file="~/.sky/ssh_keys/".concat(t)}f&&(e.password=f),o(i,e)}catch(e){console.error("Failed to upload SSH key:",e),b({...N,keyUpload:"Failed to upload SSH key"})}},E=()=>{c||s()};return(0,a.jsx)(_.Vq,{open:t,onOpenChange:E,children:(0,a.jsxs)(_.cZ,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,a.jsx)(_.fK,{children:(0,a.jsx)(_.$N,{children:w?"Edit SSH Node Pool: ".concat(null==n?void 0:n.name):"Add SSH Node Pool"})}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"poolName",children:"Pool Name"}),(0,a.jsx)(P.I,{id:"poolName",placeholder:"my-ssh-cluster",value:i,onChange:e=>d(e.target.value),disabled:w,className:"placeholder:text-gray-500 ".concat(N.poolName?"border-red-500":"")}),N.poolName&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.poolName})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"hosts",children:"Hosts (one per line)"}),(0,a.jsx)(T.g,{id:"hosts",placeholder:"192.168.1.10\n192.168.1.11\nhostname.example.com",value:m,onChange:e=>u(e.target.value),rows:6,className:"placeholder:text-gray-500 ".concat(N.hosts?"border-red-500":"")}),N.hosts&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.hosts})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"sshUser",children:"SSH User"}),(0,a.jsx)(P.I,{id:"sshUser",placeholder:"ubuntu",value:h,onChange:e=>x(e.target.value),className:"placeholder:text-gray-500 ".concat(N.sshUser?"border-red-500":"")}),N.sshUser&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.sshUser})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"keyFile",children:"SSH Private Key File"}),(0,a.jsx)(P.I,{id:"keyFile",type:"file",accept:".pem,.key,id_rsa,id_ed25519",onChange:e=>{var t;return p((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},className:"border-0 bg-transparent p-0 shadow-none focus:ring-0 file:mr-2 file:text-sm file:py-1 file:px-3 file:border file:border-gray-300 file:rounded file:bg-gray-50 hover:file:bg-gray-100 file:cursor-pointer"}),N.keyUpload&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.keyUpload})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"password",children:"Password (optional, if sudo requires a password)"}),(0,a.jsx)(P.I,{id:"password",type:"password",placeholder:"Leave empty if using passwordless sudo",value:f,onChange:e=>y(e.target.value),className:"placeholder:text-gray-500"})]}),N.auth&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:N.auth})]}),(0,a.jsxs)(_.cN,{children:[(0,a.jsx)(C.z,{variant:"outline",onClick:E,disabled:c,children:"Cancel"}),(0,a.jsx)(C.z,{onClick:S,disabled:c,className:"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),"Saving..."]}):w?"Update Pool":"Create Pool"})]})]})})}var H=s(6378),D=s(6856),U=s(1214),I=s(1163),F=s(1664),q=s.n(F),O=s(6989);s(7673);let R=U.nb.REFRESH_INTERVAL,G=U.MO.NAME_TRUNCATE_LENGTH;function A(e){let{title:t,isLoading:s,isDataLoaded:r,contexts:o,gpus:n,groupedPerContextGPUs:c,groupedPerNodeGPUs:i,handleContextClick:d,contextStats:m={},isSSH:u=!1,actionButton:h=null}=e,x=o||[];return s||!r?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:t}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(l.Z,{size:24,className:"mr-3"}),(0,a.jsxs)("span",{className:"text-gray-500",children:["Loading ",t,"..."]})]})]})}):r&&0===x.length?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:t}),h]}),(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["No ",t," found or ",t," is not configured."]})]})}):r&&x.length>0?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:t}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[x.length," ",1===x.length?u?"pool":"context":u?"pools":"contexts"]})]}),h]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:u?"Node Pool":"Context"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Jobs"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Nodes"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"GPU Types"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"#GPUs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(x.length>5?"max-h-[250px] overflow-y-auto block":""),children:x.map(e=>{let t=c[e]||[],s=i[e]||[],r=t.reduce((e,t)=>e+(t.gpu_total||0),0),l=m[u?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e)]||{clusters:0,jobs:0},o=Object.keys(t.reduce((e,t)=>(e[t.gpu_name]=(e[t.gpu_name]||0)+(t.gpu_total||0),e),{})).join(", "),n=u?e.replace(/^ssh-/,""):e;return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3",children:(0,a.jsx)(O.Md,{content:n,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{className:"text-blue-600 hover:underline cursor-pointer",onClick:()=>d(e),children:n.length>G?"".concat(n.substring(0,Math.floor((G-3)/2)),"...").concat(n.substring(n.length-Math.ceil((G-3)/2))):n})})}),(0,a.jsx)("td",{className:"p-3",children:l.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:l.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:l.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:l.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:s.length}),(0,a.jsx)("td",{className:"p-3",children:o||"-"}),(0,a.jsx)("td",{className:"p-3",children:r})]},e)})})]})})}),n&&n.length>0&&(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsxs)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4 whitespace-nowrap",children:["GPU",(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-green-100 text-green-800 rounded-full text-xs font-medium whitespace-nowrap",children:[n.reduce((e,t)=>e+t.gpu_free,0)," ","of"," ",n.reduce((e,t)=>e+t.gpu_total,0)," ","free"]})]}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"Requestable"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/2",children:(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)("span",{children:"Utilization"})})})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(n.length>5?"max-h-[250px] overflow-y-auto block":""),children:n.map(e=>{let t=e.gpu_total-e.gpu_free,s=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,r=e.gpu_total>0?t/e.gpu_total*100:0,l=c?Object.values(c).flat().filter(t=>t.gpu_name===e.gpu_name&&(u?t.context.startsWith("ssh-"):!t.context.startsWith("ssh-"))).map(e=>e.gpu_requestable_qty_per_node).filter((e,t,s)=>s.indexOf(e)===t).join(", "):"-";return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"p-3 font-medium w-24 whitespace-nowrap",children:e.gpu_name}),(0,a.jsxs)("td",{className:"p-3 text-xs text-gray-600",children:[l||"-"," / node"]}),(0,a.jsx)("td",{className:"p-3 w-2/3",children:(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"flex-1 bg-gray-100 rounded-md h-5 flex overflow-hidden shadow-sm min-w-[100px] w-full",children:[r>0&&(0,a.jsx)("div",{style:{width:"".concat(r,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs font-medium",children:r>15&&"".concat(t," used")}),s>0&&(0,a.jsx)("div",{style:{width:"".concat(s,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs font-medium",children:s>15&&"".concat(e.gpu_free," free")})]})})})]},e.gpu_name)})})]})})})]})]})}):null}function L(e){let{contextName:t,gpusInContext:s,nodesInContext:o}=e,n=t.startsWith("ssh-"),[c,i]=(0,r.useState)([]),[m,u]=(0,r.useState)("$__all"),[h,x]=(0,r.useState)({from:"now-1h",to:"now"}),[g,p]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{y(await (0,d.TO)())})()},[]);let j=(0,r.useCallback)(async()=>{if(f){p(!0);try{let e=(0,d.ki)(),s="in-cluster"===t?"^$":t,a="query="+encodeURIComponent('group by (node) (DCGM_FI_DEV_GPU_TEMP{cluster=~"'.concat(s,'"})')),r="/api/datasources/proxy/1/api/v1/query?".concat(a);try{let t=await fetch("".concat(e).concat(r),{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(t.ok){let e=await t.json();if(e.data&&e.data.result&&e.data.result.length>0){let t=e.data.result.map(e=>e.metric.node).filter(Boolean).sort();i(t),console.log("Successfully fetched hosts for cluster ".concat(s||"in-cluster",":"),t)}else console.log("No nodes found for this cluster"),i([])}else console.log("HTTP ".concat(t.status," from ").concat(r,": ").concat(t.statusText)),i([])}catch(e){console.log("Failed to fetch from ".concat(r,":"),e),i([])}}catch(e){console.error("Error fetching available hosts:",e),i([])}finally{p(!1)}}},[f,t]);(0,r.useEffect)(()=>{f&&o&&o.length>0&&j()},[o,f,j]);let N=e=>{let s=(0,d.ki)(),a="in-cluster"===t?"^$":t;return"".concat(s,"/d-solo/skypilot-dcgm-cluster-dashboard/skypilot-dcgm-kubernetes-cluster-dashboard?orgId=1&timezone=browser&var-datasource=prometheus&var-host=").concat(encodeURIComponent(m),"&var-gpu=$__all&var-cluster=").concat(encodeURIComponent(a),"&refresh=5s&theme=light&from=").concat(encodeURIComponent(h.from),"&to=").concat(encodeURIComponent(h.to),"&panelId=").concat(e,"&__feature.dashboardSceneSolo")},b=e=>{x({"15m":{from:"now-15m",to:"now"},"1h":{from:"now-1h",to:"now"},"6h":{from:"now-6h",to:"now"},"24h":{from:"now-24h",to:"now"},"7d":{from:"now-7d",to:"now"}}[e])};return(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm h-full",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsx)("h4",{className:"text-lg font-semibold",children:"Available GPUs"})}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6",children:s.map(e=>{let t=e.gpu_total-e.gpu_free,s=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,r=e.gpu_total>0?t/e.gpu_total*100:0;return(0,a.jsxs)("div",{className:"p-3 bg-gray-50 rounded-md border border-gray-200 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-1.5 flex-wrap",children:[(0,a.jsxs)("div",{className:"font-medium text-gray-800 text-sm",children:[e.gpu_name,(0,a.jsxs)("span",{className:"text-xs text-gray-500 ml-2",children:["(Requestable: ",e.gpu_requestable_qty_per_node," / node)"]})]}),(0,a.jsxs)("span",{className:"text-xs font-medium",children:[e.gpu_free," free / ",e.gpu_total," total"]})]}),(0,a.jsxs)("div",{className:"w-full bg-gray-100 rounded-md h-4 flex overflow-hidden shadow-sm",children:[r>0&&(0,a.jsx)("div",{style:{width:"".concat(r,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs",children:r>15&&"".concat(t," used")}),s>0&&(0,a.jsx)("div",{style:{width:"".concat(s,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs",children:s>15&&"".concat(e.gpu_free," free")})]})]},e.gpu_name)})}),o&&o.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4",children:"Nodes"}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"Node"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"IP Address"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"GPU"}),(0,a.jsx)("th",{className:"p-3 text-right font-medium text-gray-600",children:"Availability"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:o.map((e,t)=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.node_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.ip_address||"-"}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.gpu_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-right text-gray-700",children:"".concat(e.gpu_free," of ").concat(e.gpu_total," free")})]},"".concat(e.node_name,"-").concat(t)))})]})})]}),f&&s&&s.length>0&&!n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4 mt-6",children:"GPU Metrics"}),(0,a.jsxs)("div",{className:"mb-4 p-4 bg-gray-50 rounded-md border border-gray-200",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[o&&o.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{htmlFor:"host-select",className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Node:"}),(0,a.jsxs)("select",{id:"host-select",value:m,onChange:e=>{u(e.target.value)},disabled:g,className:"px-3 py-1 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-sky-blue focus:border-transparent",children:[(0,a.jsx)("option",{value:"$__all",children:"All Nodes"}),c.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),g&&(0,a.jsx)("div",{className:"ml-2",children:(0,a.jsx)(l.Z,{size:16})})]}),(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:[{label:"15m",value:"15m"},{label:"1h",value:"1h"},{label:"6h",value:"6h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"}].map(e=>(0,a.jsx)("button",{onClick:()=>b(e.value),className:"px-2 py-1 text-xs font-medium rounded border transition-colors ".concat(h.from==="now-".concat(e.value)&&"now"===h.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.jsx)("div",{className:"mt-2 text-xs text-gray-500",children:o&&o.length>0?(0,a.jsxs)(a.Fragment,{children:["Showing:"," ","$__all"===m?"All nodes":m," ","• Time: ",h.from," to ",h.to,c.length>0&&(0,a.jsxs)("span",{children:[" ","• ",c.length," nodes available"]})]}):(0,a.jsxs)(a.Fragment,{children:["Cluster:"," ",n?t.replace(/^ssh-/,""):t," ","• Time: ",h.from," to ",h.to," • Showing metrics for all nodes in cluster"]})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(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:N("6"),width:"100%",height:"400",frameBorder:"0",title:"GPU Utilization",className:"rounded"},"gpu-util-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(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:N("18"),width:"100%",height:"400",frameBorder:"0",title:"GPU Memory",className:"rounded"},"gpu-memory-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(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:N("10"),width:"100%",height:"400",frameBorder:"0",title:"GPU Power Consumption",className:"rounded"},"gpu-power-".concat(m,"-").concat(h.from,"-").concat(h.to))})})]})]})]})})})}function z(e){var t;let{poolName:s,gpusInContext:c,nodesInContext:i,handleDeploySSHPool:d,handleEditSSHPool:m,handleDeleteSSHPool:u,poolConfig:h}=e,[x,g]=(0,r.useState)(null),[p,f]=(0,r.useState)(!0),[y,j]=(0,r.useState)({isOpen:!1,action:null,loading:!1}),[N,P]=(0,r.useState)({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});(0,r.useEffect)(()=>{(async()=>{try{f(!0);let e=await w(s);g(e)}catch(e){console.error("Failed to fetch SSH Node Pool status:",e),g({pool_name:s,status:"Error",reason:"Failed to fetch status"})}finally{f(!1)}})()},[s]);let{deployDisabled:k}=(()=>{if(!x)return{deployDisabled:!0};let e=x.status;return"Ready"===e?{deployDisabled:!0}:"Error"===e?{deployDisabled:!0}:{deployDisabled:!1}})(),T=async()=>{j({...y,loading:!0});try{if("deploy"===y.action){j({isOpen:!1,action:null,loading:!1}),P({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await d(s)).request_id;P(t=>({...t,requestId:e}));let t=new AbortController;await v({requestId:e,signal:t.signal,onNewLog:e=>{P(t=>({...t,logs:t.logs+e}))}}),P(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0})),setTimeout(async()=>{(async()=>{try{let e=await w(s);g(e)}catch(e){console.error("Failed to fetch SSH Node Pool status after deployment:",e)}})()},1e3)}catch(e){console.error("Deployment failed:",e),P(t=>({...t,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:t.logs+"\nDeployment failed: ".concat(e.message)}))}}else if("delete"===y.action){j({isOpen:!1,action:null,loading:!1}),P({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await b(s)).request_id;P(t=>({...t,requestId:e})),e&&await S({requestId:e,signal:null,onNewLog:e=>{P(t=>({...t,logs:t.logs+e}))},operationType:"down"}),await u(s),P(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0,logs:e.logs+"\nSSH Node Pool teardown completed successfully."}))}catch(e){console.error("Down operation failed:",e),P(t=>({...t,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:t.logs+"\nTeardown failed: ".concat(e.message)}))}}}catch(e){console.error("Action failed:",e),j({...y,loading:!1})}},E=()=>{j({isOpen:!1,action:null,loading:!1})},H=()=>{P({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null}),N.deploymentComplete&&setTimeout(()=>{(async()=>{try{let e=await w(s);g(e)}catch(e){console.error("Failed to refresh status:",e)}})()},1e3)},D="deploy"===y.action?{title:"Deploy SSH Node Pool",description:'Are you sure you want to deploy SSH Node Pool "'.concat(s,'"?'),details:["• Set up SkyPilot runtime on the configured SSH hosts","• Install required components and dependencies","• Make the node pool available for workloads","","This process may take a few minutes to complete."]}:{title:"Delete SSH Node Pool",description:'Are you sure you want to delete SSH Node Pool "'.concat(s,'"?'),details:["• Clean up any deployed resources","• Remove the SSH Node Pool configuration"]};return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-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 pt-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"SSH Node Pool Details"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border rounded flex items-center ".concat(k?"border-gray-300 bg-gray-100 text-gray-400 cursor-not-allowed":"border-green-300 bg-green-50 text-green-700 hover:bg-green-100"),onClick:k?void 0:()=>{j({isOpen:!0,action:"deploy",loading:!1})},disabled:k,children:[(0,a.jsx)(o.Z,{className:"w-4 h-4 mr-2"}),"Deploy"]}),(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border border-gray-300 rounded hover:bg-gray-50 flex items-center text-red-600 hover:text-red-700",onClick:()=>{j({isOpen:!0,action:"delete",loading:!1})},children:[(0,a.jsx)(n.Z,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]}),(0,a.jsx)("div",{className:"p-4",children:(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:"Pool Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:s})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Nodes"}),(0,a.jsx)("div",{className:"text-base mt-1",children:i?i.length:0})]}),(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:p?(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."})]}):x?(0,a.jsx)(e=>{let{status:t,reason:s}=e,r="Ready"===t,l="Not Ready"===t?"Click Deploy to set up this node pool":s;return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(r?"bg-green-100":"bg-red-100"," ").concat(r?"text-green-800":"text-red-800"),children:t}),!r&&l&&(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",l,")"]})]})},{status:x.status,reason:x.reason}):(0,a.jsx)("span",{className:"text-gray-500",children:"Unknown"})})]})]})})]})}),(0,a.jsx)(L,{contextName:"ssh-".concat(s),gpusInContext:c,nodesInContext:i}),(0,a.jsx)(_.Vq,{open:y.isOpen,onOpenChange:E,children:(0,a.jsxs)(_.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(_.fK,{className:"",children:[(0,a.jsx)(_.$N,{className:"",children:D.title}),(0,a.jsx)(_.Be,{className:"",children:D.description})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"text-sm text-gray-600 space-y-1",children:[(0,a.jsx)("p",{className:"font-medium mb-2",children:"This will:"}),D.details.map((e,t)=>(0,a.jsx)("p",{className:""===e?"pt-2":"",children:e},t))]})}),(0,a.jsxs)(_.cN,{className:"",children:[(0,a.jsx)(C.z,{variant:"outline",onClick:E,disabled:y.loading,className:"",children:"Cancel"}),(0,a.jsx)(C.z,{onClick:T,disabled:y.loading,className:"deploy"===y.action?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:y.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),"deploy"===y.action?"Deploying...":"Deleting..."]}):"deploy"===y.action?"Deploy":"Delete"})]})]})}),(0,a.jsx)(_.Vq,{open:N.isOpen,onOpenChange:N.isStreaming?void 0:H,children:(0,a.jsxs)(_.cZ,{className:"sm:max-w-4xl max-h-[80vh]",children:[(0,a.jsxs)(_.fK,{className:"",children:[(0,a.jsxs)(_.$N,{className:"",children:["Deploying SSH Node Pool: ",s]}),(0,a.jsx)(_.Be,{className:"",children:N.isStreaming?"Deployment in progress. Do not close this dialog.":N.deploymentSuccess?"Deployment completed successfully!":"Deployment completed with errors."})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm max-h-96 overflow-y-auto",children:[(0,a.jsx)("pre",{className:"whitespace-pre-wrap",children:(t=N.logs)?t.split("\n").map(e=>(e=e.replace(/\x1b\[[0-9;]*m/g,"")).match(/^D \d{2}-\d{2} \d{2}:\d{2}:\d{2}/)?null:e=(e=e.replace(/├──/g,"├─")).replace(/└──/g,"└─")).filter(e=>null!==e&&""!==e.trim()).join("\n"):""}),N.isStreaming&&(0,a.jsxs)("div",{className:"flex items-center mt-2",children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2 text-green-400"}),(0,a.jsx)("span",{className:"text-green-400",children:"Streaming logs..."})]})]})}),(0,a.jsx)(_.cN,{className:"",children:(0,a.jsx)(C.z,{onClick:H,disabled:N.isStreaming,className:N.deploymentSuccess?"bg-green-600 hover:bg-green-700 text-white":N.deploymentComplete&&!N.deploymentSuccess?"bg-red-600 hover:bg-red-700 text-white":"bg-gray-600 hover:bg-gray-700 text-white",children:N.isStreaming?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),"Deploying..."]}):"Close"})})]})})]})}function Z(){let[e,t]=(0,r.useState)(!0),[s,o]=(0,r.useState)(!0),[n,d]=(0,r.useState)(!0),x=r.useRef(null),g=(0,i.X)(),[j,b]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),S=(0,I.useRouter)(),[_,C]=(0,r.useState)([]),[P,k]=(0,r.useState)([]),[T,U]=(0,r.useState)([]),[F,O]=(0,r.useState)([]),[G,Z]=(0,r.useState)([]),[M,W]=(0,r.useState)(0),[$,B]=(0,r.useState)(0),[K,V]=(0,r.useState)({}),[J,X]=(0,r.useState)({}),[Q,Y]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(null),[es,ea]=(0,r.useState)(!1),[er,el]=(0,r.useState)(null),eo=r.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{showLoadingIndicators:!0};e.showLoadingIndicators&&(t(!0),o(!0));try{let e=await H.default.get(m.l4),{gpuData:t,cloudData:s}=e||{};if(t){let{allContextNames:e,allGPUs:s,perContextGPUs:a,perNodeGPUs:r,contextStats:l}=t;C(e||[]),k(s||[]),U(a||[]),O(r||[]),V(l||{}),b(!0)}else e&&null===e.gpuData?(C([]),k([]),U([]),O([]),V({}),b(!0)):e||console.log("No infra data received from cache");s?(Z(s.clouds||[]),W(s.totalClouds||0),B(s.enabledClouds||0),v(!0)):e&&null===e.cloudData?(Z([]),W(0),B(0),v(!0)):e||console.log("No cloud data received from cache"),await en()}catch(e){console.error("Error in fetchData:",e),C([]),k([]),U([]),O([]),V({}),Z([]),W(0),B(0),b(!0),v(!0)}finally{e.showLoadingIndicators&&(t(!1),o(!1)),n&&e.showLoadingIndicators&&d(!1)}},[n]),en=async()=>{try{let e=await p();X(e)}catch(e){console.error("Failed to fetch SSH Node Pools:",e),X({})}},ec=(e,t)=>{et({name:e,config:t}),Y(!0)},ei=async e=>{try{await y(e),await en(),el(null),S.push("/infra")}catch(e){throw console.error("Failed to delete SSH Node Pool:",e),e}},ed=async e=>{try{await N(e)}catch(e){throw console.error("Failed to deploy SSH Node Pool:",e),e}},em=async(e,t)=>{ea(!0);try{let s={...J};s[e]=t,await f(s),await en(),Y(!1)}catch(e){console.error("Failed to save SSH Node Pool:",e),alert("Failed to save SSH Node Pool. Please try again.")}finally{ea(!1)}};(0,r.useEffect)(()=>{x.current=eo},[eo]),(0,r.useEffect)(()=>{(async()=>{await D.ZP.preloadForPage("infra"),eo({showLoadingIndicators:!0})})()},[eo]),(0,r.useEffect)(()=>{let e=!0,t=setInterval(()=>{e&&x.current&&x.current({showLoadingIndicators:!1})},R);return()=>{e=!1,clearInterval(t)}},[]),(0,r.useEffect)(()=>()=>{b(!1),v(!1),d(!0)},[]),(P||[]).length,(P||[]).reduce((e,t)=>e+t.gpu_total,0),(P||[]).reduce((e,t)=>e+t.gpu_free,0);let eu=r.useMemo(()=>T?T.reduce((e,t)=>{let{context:s}=t;return e[s]||(e[s]=[]),e[s].push(t),e},{}):{},[T]),eh=r.useMemo(()=>_&&Array.isArray(_)?_.filter(e=>e.startsWith("ssh-")):[],[_]),ex=r.useMemo(()=>_&&Array.isArray(_)?_.filter(e=>!e.startsWith("ssh-")):[],[_]),eg=r.useMemo(()=>{if(!T||!P)return[];let e=new Set;return T.forEach(t=>{t.context.startsWith("ssh-")&&e.add(t.gpu_name)}),P.filter(t=>e.has(t.gpu_name))},[P,T]),ep=r.useMemo(()=>{if(!T||!P)return[];let e=new Set;return T.forEach(t=>{t.context.startsWith("ssh-")||e.add(t.gpu_name)}),P.filter(t=>e.has(t.gpu_name))},[P,T]),ef=r.useMemo(()=>F?F.reduce((e,t)=>{let{context:s}=t;return e[s]||(e[s]=[]),e[s].push(t),e},{}):{},[F]);(0,r.useEffect)(()=>{S.isReady&&S.query.context&&el(decodeURIComponent(Array.isArray(S.query.context)?S.query.context[0]:S.query.context))},[S.isReady,S.query.context]);let ey=e=>{el(e),S.push("/infra/".concat(encodeURIComponent(e)))},ej=e||s,eN=j&&w&&!n;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(q(),{href:"/infra",className:"text-sky-blue hover:underline ".concat(er?"":"cursor-default"),children:"Infrastructure"}),er&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),er.startsWith("ssh-")?(0,a.jsx)(q(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"SSH Node Pool"}):(0,a.jsx)(q(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"Kubernetes"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)("span",{className:"text-sky-blue",children:er.startsWith("ssh-")?er.replace(/^ssh-/,""):er})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[ej&&(0,a.jsxs)("div",{className:"flex items-center mr-2",children:[(0,a.jsx)(l.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:()=>{H.default.invalidate(u.getClusters),H.default.invalidate(h.getManagedJobs,[{allUsers:!0}]),H.default.invalidate(m.l4),x.current&&x.current({showLoadingIndicators:!0})},disabled:ej,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1.5"}),!g&&"Refresh"]})]})]}),eN?er?e&&!j?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(l.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]}):(t=>{let s=eu[t]||[],r=ef[t]||[];if(e&&!j)return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(l.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]});if(t.startsWith("ssh-")){let e=t.replace(/^ssh-/,"");return(0,a.jsx)(z,{poolName:e,gpusInContext:s,nodesInContext:r,handleDeploySSHPool:ed,handleEditSSHPool:ec,handleDeleteSSHPool:ei,poolConfig:J[e]})}return(0,a.jsx)(L,{contextName:t,gpusInContext:s,nodesInContext:r})})(er):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(A,{title:"SSH Node Pool",isLoading:e,isDataLoaded:j,contexts:eh,gpus:eg,groupedPerContextGPUs:eu,groupedPerNodeGPUs:ef,handleContextClick:ey,contextStats:K,isSSH:!0,actionButton:null}),(0,a.jsx)(A,{title:"Kubernetes",isLoading:e,isDataLoaded:j,contexts:ex,gpus:ep,groupedPerContextGPUs:eu,groupedPerNodeGPUs:ef,handleContextClick:ey,contextStats:K,isSSH:!1}),s||!w?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Cloud"}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(l.Z,{size:24,className:"mr-3"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading Cloud..."})]})]})}):(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cloud"}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[$," of ",M," enabled"]})]}),G&&0!==G.length?(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-32",children:"Cloud"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Jobs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:G.map(e=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 font-medium text-gray-700",children:e.name}),(0,a.jsx)("td",{className:"p-3",children:e.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:e.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:e.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:e.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})})]},e.name))})]})}):(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No enabled clouds available."})]})})]}):(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-32",children:[(0,a.jsx)(l.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading infrastructure data..."})]}),(0,a.jsx)(E,{isOpen:Q,onClose:()=>Y(!1),onSave:em,poolData:ee,isLoading:es})]})}},2557:function(e,t,s){s.d(t,{I:function(){return o}});var a=s(5893),r=s(7294),l=s(2350);let o=r.forwardRef((e,t)=>{let{className:s,type:r,...o}=e;return(0,a.jsx)("input",{type:r,className:(0,l.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...o})});o.displayName="Input"},6185:function(e,t,s){s.d(t,{_:function(){return i}});var a=s(5893),r=s(7294),l=s(9102),o=s(2003),n=s(2350);let c=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),i=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(l.f,{ref:t,className:(0,n.cn)(c(),s),...r})});i.displayName=l.f.displayName},9123:function(e,t,s){s.d(t,{g:function(){return o}});var a=s(5893),r=s(7294),l=s(2350);let o=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...r})});o.displayName="Textarea"},7853:function(e,t,s){s.d(t,{TO:function(){return l},ki:function(){return o}});let a=null,r=null,l=async()=>null!==a?a:r||(r=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),t=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==t.status}catch(e){return console.debug("Grafana availability check failed:",e),a=!1,!1}finally{r=null}})()),o=()=>"".concat(window.location.origin,"/grafana")}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9984],{9984:function(e,t,s){s.r(t),s.d(t,{ContextDetails:function(){return L},GPUs:function(){return Z},InfrastructureSection:function(){return G}});var a=s(5893),r=s(7294),l=s(5739);s(9470);var o=s(6409),n=s(8418),c=s(3626),i=s(3001),d=s(7853),m=s(2045),u=s(3266),h=s(8969),x=s(3225),p=s(5821);async function g(){try{let e=await fetch("".concat(x.f4,"/ssh_node_pools"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));return await e.json()}catch(e){return console.error("Error fetching SSH Node Pools:",e),{}}}async function f(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error updating SSH Node Pools:",e),e}}async function y(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e),{method:"DELETE",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deleting SSH Node Pool:",e),e}}async function j(e,t){try{let s=new FormData;s.append("key_name",e),s.append("key_file",t);let a=await fetch("".concat(x.f4,"/ssh_node_pools/keys"),{method:"POST",body:s});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));return await a.json()}catch(e){throw console.error("Error uploading SSH key:",e),e}}async function b(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/deploy"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error deploying SSH Node Pool:",e),e}}async function N(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/down"),{method:"POST",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error tearing down SSH Node Pool:",e),e}}async function w(e){try{let t=await fetch("".concat(x.f4,"/ssh_node_pools/").concat(e,"/status"),{method:"GET",headers:{"Content-Type":"application/json"}});if(!t.ok)throw Error("HTTP error! status: ".concat(t.status));return await t.json()}catch(e){throw console.error("Error fetching SSH Node Pool status:",e),e}}async function v(e){let t,{requestId:s,signal:a,onNewLog:r}=e,l=Date.now(),o=new Promise(e=>{let s=()=>{let a=Date.now()-l;a>=3e5?e({timeout:!0}):t=setTimeout(s,3e5-a)};t=setTimeout(s,3e5)}),n=(async()=>{try{let e=await fetch("".concat(x.f4,"/api/stream?request_id=").concat(s,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...a?{signal:a}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let o=e.body.getReader();try{for(;;){let{done:e,value:t}=await o.read();if(e)break;l=Date.now();let s=new TextDecoder().decode(t);r(s)}}finally{o.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),c=await Promise.race([n,o]);if(t&&clearTimeout(t),c.timeout){(0,p.C)("SSH deployment log stream timed out after ".concat(300,"s of inactivity"),"warning");return}}async function S(e){let t,{requestId:s,signal:a,onNewLog:r,operationType:l="operation"}=e,o=Date.now(),n=new Promise(e=>{let s=()=>{let a=Date.now()-o;a>=3e5?e({timeout:!0}):t=setTimeout(s,3e5-a)};t=setTimeout(s,3e5)}),c=(async()=>{try{let e=await fetch("".concat(x.f4,"/api/stream?request_id=").concat(s,"&format=plain&tail=").concat(1e3,"&follow=true"),{method:"GET",headers:{"Content-Type":"application/json"},...a?{signal:a}:{}});if(!e.ok)throw Error("HTTP error! status: ".concat(e.status));let l=e.body.getReader();try{for(;;){let{done:e,value:t}=await l.read();if(e)break;o=Date.now();let s=new TextDecoder().decode(t);r(s)}}finally{l.cancel(),t&&clearTimeout(t)}return{timeout:!1}}catch(e){if(t&&clearTimeout(t),"AbortError"===e.name)return{timeout:!1};throw e}})(),i=await Promise.race([c,n]);if(t&&clearTimeout(t),i.timeout){(0,p.C)("SSH ".concat(l," log stream timed out after ").concat(300,"s of inactivity"),"warning");return}}var _=s(326),C=s(803),P=s(2557),k=s(6185),T=s(9123);function E(e){let{isOpen:t,onClose:s,onSave:o,poolData:n=null,isLoading:c=!1}=e,[i,d]=(0,r.useState)(""),[m,u]=(0,r.useState)(""),[h,x]=(0,r.useState)("ubuntu"),[p,g]=(0,r.useState)(null),[f,y]=(0,r.useState)(""),[b,N]=(0,r.useState)({}),w=null!==n;(0,r.useEffect)(()=>{if(w&&n){var e,t,s;d(n.name||""),u(((null===(e=n.config)||void 0===e?void 0:e.hosts)||[]).join("\n")),x((null===(t=n.config)||void 0===t?void 0:t.user)||"ubuntu"),y((null===(s=n.config)||void 0===s?void 0:s.password)||"")}else d(""),u(""),x("ubuntu"),g(null),y("");N({})},[w,n]);let v=()=>{let e={};return i.trim()||(e.poolName="Pool name is required"),m.trim()||(e.hosts="At least one host is required"),h.trim()||(e.sshUser="SSH user is required"),p||f||(e.auth="Either SSH key file or password is required"),N(e),0===Object.keys(e).length},S=async()=>{if(!v())return;let e={hosts:m.split("\n").map(e=>e.trim()).filter(e=>e.length>0),user:h};try{if(p){let t=p.name;await j(t,p),e.identity_file="~/.sky/ssh_keys/".concat(t)}f&&(e.password=f),o(i,e)}catch(e){console.error("Failed to upload SSH key:",e),N({...b,keyUpload:"Failed to upload SSH key"})}},E=()=>{c||s()};return(0,a.jsx)(_.Vq,{open:t,onOpenChange:E,children:(0,a.jsxs)(_.cZ,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[(0,a.jsx)(_.fK,{children:(0,a.jsx)(_.$N,{children:w?"Edit SSH Node Pool: ".concat(null==n?void 0:n.name):"Add SSH Node Pool"})}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"poolName",children:"Pool Name"}),(0,a.jsx)(P.I,{id:"poolName",placeholder:"my-ssh-cluster",value:i,onChange:e=>d(e.target.value),disabled:w,className:"placeholder:text-gray-500 ".concat(b.poolName?"border-red-500":"")}),b.poolName&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:b.poolName})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"hosts",children:"Hosts (one per line)"}),(0,a.jsx)(T.g,{id:"hosts",placeholder:"192.168.1.10\n192.168.1.11\nhostname.example.com",value:m,onChange:e=>u(e.target.value),rows:6,className:"placeholder:text-gray-500 ".concat(b.hosts?"border-red-500":"")}),b.hosts&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:b.hosts})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"sshUser",children:"SSH User"}),(0,a.jsx)(P.I,{id:"sshUser",placeholder:"ubuntu",value:h,onChange:e=>x(e.target.value),className:"placeholder:text-gray-500 ".concat(b.sshUser?"border-red-500":"")}),b.sshUser&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:b.sshUser})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"keyFile",children:"SSH Private Key File"}),(0,a.jsx)(P.I,{id:"keyFile",type:"file",accept:".pem,.key,id_rsa,id_ed25519",onChange:e=>{var t;return g((null===(t=e.target.files)||void 0===t?void 0:t[0])||null)},className:"border-0 bg-transparent p-0 shadow-none focus:ring-0 file:mr-2 file:text-sm file:py-1 file:px-3 file:border file:border-gray-300 file:rounded file:bg-gray-50 hover:file:bg-gray-100 file:cursor-pointer"}),b.keyUpload&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:b.keyUpload})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(k._,{htmlFor:"password",children:"Password (optional, if sudo requires a password)"}),(0,a.jsx)(P.I,{id:"password",type:"password",placeholder:"Leave empty if using passwordless sudo",value:f,onChange:e=>y(e.target.value),className:"placeholder:text-gray-500"})]}),b.auth&&(0,a.jsx)("p",{className:"text-sm text-red-500",children:b.auth})]}),(0,a.jsxs)(_.cN,{children:[(0,a.jsx)(C.z,{variant:"outline",onClick:E,disabled:c,children:"Cancel"}),(0,a.jsx)(C.z,{onClick:S,disabled:c,className:"bg-blue-600 hover:bg-blue-700 text-white disabled:bg-gray-300 disabled:text-gray-500",children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),"Saving..."]}):w?"Update Pool":"Create Pool"})]})]})})}var H=s(6378),D=s(6856),U=s(1214),I=s(1163),F=s(1664),A=s.n(F),q=s(6989);s(7673);let O=U.nb.REFRESH_INTERVAL,R=U.MO.NAME_TRUNCATE_LENGTH;function G(e){let{title:t,isLoading:s,isDataLoaded:r,contexts:o,gpus:n,groupedPerContextGPUs:c,groupedPerNodeGPUs:i,handleContextClick:d,contextStats:m={},isSSH:u=!1,actionButton:h=null}=e,x=o||[];return s||!r?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:t}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(l.Z,{size:24,className:"mr-3"}),(0,a.jsxs)("span",{className:"text-gray-500",children:["Loading ",t,"..."]})]})]})}):r&&0===x.length?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:t}),h]}),(0,a.jsxs)("p",{className:"text-sm text-gray-500",children:["No ",t," found or ",t," is not configured."]})]})}):r&&x.length>0?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:t}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[x.length," ",1===x.length?u?"pool":"context":u?"pools":"contexts"]})]}),h]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:u?"Node Pool":"Context"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Jobs"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"Nodes"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"GPU Types"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/8",children:"#GPUs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(x.length>5?"max-h-[250px] overflow-y-auto block":""),children:x.map(e=>{let t=c[e]||[],s=i[e]||[],r=t.reduce((e,t)=>e+(t.gpu_total||0),0),l=m[u?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e)]||{clusters:0,jobs:0},o=Object.keys(t.reduce((e,t)=>(e[t.gpu_name]=(e[t.gpu_name]||0)+(t.gpu_total||0),e),{})).join(", "),n=u?e.replace(/^ssh-/,""):e;return(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3",children:(0,a.jsx)(q.Md,{content:n,className:"text-sm text-muted-foreground",children:(0,a.jsx)("span",{className:"text-blue-600 hover:underline cursor-pointer",onClick:()=>d(e),children:n.length>R?"".concat(n.substring(0,Math.floor((R-3)/2)),"...").concat(n.substring(n.length-Math.ceil((R-3)/2))):n})})}),(0,a.jsx)("td",{className:"p-3",children:l.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:l.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:l.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:l.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:s.length}),(0,a.jsx)("td",{className:"p-3",children:o||"-"}),(0,a.jsx)("td",{className:"p-3",children:r})]},e)})})]})})}),n&&n.length>0&&(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsxs)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4 whitespace-nowrap",children:["GPU",(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-green-100 text-green-800 rounded-full text-xs font-medium whitespace-nowrap",children:[n.reduce((e,t)=>e+t.gpu_free,0)," ","of"," ",n.reduce((e,t)=>e+t.gpu_total,0)," ","free"]})]}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/4",children:"Requestable"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-1/2",children:(0,a.jsx)("div",{className:"flex items-center",children:(0,a.jsx)("span",{children:"Utilization"})})})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200 ".concat(n.length>5?"max-h-[250px] overflow-y-auto block":""),children:n.map(e=>{let t=e.gpu_total-e.gpu_free,s=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,r=e.gpu_total>0?t/e.gpu_total*100:0,l=c?Object.values(c).flat().filter(t=>t.gpu_name===e.gpu_name&&(u?t.context.startsWith("ssh-"):!t.context.startsWith("ssh-"))).map(e=>e.gpu_requestable_qty_per_node).filter((e,t,s)=>s.indexOf(e)===t).join(", "):"-";return(0,a.jsxs)("tr",{children:[(0,a.jsx)("td",{className:"p-3 font-medium w-24 whitespace-nowrap",children:e.gpu_name}),(0,a.jsxs)("td",{className:"p-3 text-xs text-gray-600",children:[l||"-"," / node"]}),(0,a.jsx)("td",{className:"p-3 w-2/3",children:(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"flex-1 bg-gray-100 rounded-md h-5 flex overflow-hidden shadow-sm min-w-[100px] w-full",children:[r>0&&(0,a.jsx)("div",{style:{width:"".concat(r,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs font-medium",children:r>15&&"".concat(t," used")}),s>0&&(0,a.jsx)("div",{style:{width:"".concat(s,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs font-medium",children:s>15&&"".concat(e.gpu_free," free")})]})})})]},e.gpu_name)})})]})})})]})]})}):null}function L(e){let{contextName:t,gpusInContext:s,nodesInContext:o}=e,n=t.startsWith("ssh-"),[c,i]=(0,r.useState)([]),[m,u]=(0,r.useState)("$__all"),[h,x]=(0,r.useState)({from:"now-1h",to:"now"}),[p,g]=(0,r.useState)(!1),[f,y]=(0,r.useState)(!1);(0,r.useEffect)(()=>{(async()=>{y(await (0,d.TO)())})()},[]);let j=(0,r.useCallback)(async()=>{if(f){g(!0);try{let e=(0,d.ki)(),s="in-cluster"===t?"^$":t,a="query="+encodeURIComponent('group by (node) (DCGM_FI_DEV_GPU_TEMP{cluster=~"'.concat(s,'"})')),r="/api/datasources/proxy/1/api/v1/query?".concat(a);try{let t=await fetch("".concat(e).concat(r),{method:"GET",credentials:"include",headers:{Accept:"application/json"}});if(t.ok){let e=await t.json();if(e.data&&e.data.result&&e.data.result.length>0){let t=e.data.result.map(e=>e.metric.node).filter(Boolean).sort();i(t),console.log("Successfully fetched hosts for cluster ".concat(s||"in-cluster",":"),t)}else console.log("No nodes found for this cluster"),i([])}else console.log("HTTP ".concat(t.status," from ").concat(r,": ").concat(t.statusText)),i([])}catch(e){console.log("Failed to fetch from ".concat(r,":"),e),i([])}}catch(e){console.error("Error fetching available hosts:",e),i([])}finally{g(!1)}}},[f,t]);(0,r.useEffect)(()=>{f&&o&&o.length>0&&j()},[o,f,j]);let b=e=>{let s=(0,d.ki)(),a="in-cluster"===t?"^$":t;return"".concat(s,"/d-solo/skypilot-dcgm-cluster-dashboard/skypilot-dcgm-kubernetes-cluster-dashboard?orgId=1&timezone=browser&var-datasource=prometheus&var-host=").concat(encodeURIComponent(m),"&var-gpu=$__all&var-cluster=").concat(encodeURIComponent(a),"&refresh=5s&theme=light&from=").concat(encodeURIComponent(h.from),"&to=").concat(encodeURIComponent(h.to),"&panelId=").concat(e,"&__feature.dashboardSceneSolo")},N=e=>{x({"15m":{from:"now-15m",to:"now"},"1h":{from:"now-1h",to:"now"},"6h":{from:"now-6h",to:"now"},"24h":{from:"now-24h",to:"now"},"7d":{from:"now-7d",to:"now"}}[e])};return(0,a.jsx)("div",{className:"mb-4",children:(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm h-full",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("div",{className:"flex items-center justify-between mb-4",children:(0,a.jsx)("h4",{className:"text-lg font-semibold",children:"Available GPUs"})}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 mb-6",children:s.map(e=>{let t=e.gpu_total-e.gpu_free,s=e.gpu_total>0?e.gpu_free/e.gpu_total*100:0,r=e.gpu_total>0?t/e.gpu_total*100:0;return(0,a.jsxs)("div",{className:"p-3 bg-gray-50 rounded-md border border-gray-200 shadow-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-1.5 flex-wrap",children:[(0,a.jsxs)("div",{className:"font-medium text-gray-800 text-sm",children:[e.gpu_name,(0,a.jsxs)("span",{className:"text-xs text-gray-500 ml-2",children:["(Requestable: ",e.gpu_requestable_qty_per_node," / node)"]})]}),(0,a.jsxs)("span",{className:"text-xs font-medium",children:[e.gpu_free," free / ",e.gpu_total," total"]})]}),(0,a.jsxs)("div",{className:"w-full bg-gray-100 rounded-md h-4 flex overflow-hidden shadow-sm",children:[r>0&&(0,a.jsx)("div",{style:{width:"".concat(r,"%")},className:"bg-yellow-500 h-full flex items-center justify-center text-white text-xs",children:r>15&&"".concat(t," used")}),s>0&&(0,a.jsx)("div",{style:{width:"".concat(s,"%")},className:"bg-green-700 h-full flex items-center justify-center text-white text-xs",children:s>15&&"".concat(e.gpu_free," free")})]})]},e.gpu_name)})}),o&&o.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4",children:"Nodes"}),(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-100",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"Node"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"IP Address"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600",children:"GPU"}),(0,a.jsx)("th",{className:"p-3 text-right font-medium text-gray-600",children:"Availability"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:o.map((e,t)=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.node_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.ip_address||"-"}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-gray-700",children:e.gpu_name}),(0,a.jsx)("td",{className:"p-3 whitespace-nowrap text-right text-gray-700",children:"".concat(e.gpu_free," of ").concat(e.gpu_total," free")})]},"".concat(e.node_name,"-").concat(t)))})]})})]}),f&&s&&s.length>0&&!n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("h4",{className:"text-lg font-semibold mb-4 mt-6",children:"GPU Metrics"}),(0,a.jsxs)("div",{className:"mb-4 p-4 bg-gray-50 rounded-md border border-gray-200",children:[(0,a.jsxs)("div",{className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center",children:[o&&o.length>0&&(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("label",{htmlFor:"host-select",className:"text-sm font-medium text-gray-700 whitespace-nowrap",children:"Node:"}),(0,a.jsxs)("select",{id:"host-select",value:m,onChange:e=>{u(e.target.value)},disabled:p,className:"px-3 py-1 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-sky-blue focus:border-transparent",children:[(0,a.jsx)("option",{value:"$__all",children:"All Nodes"}),c.map(e=>(0,a.jsx)("option",{value:e,children:e},e))]}),p&&(0,a.jsx)("div",{className:"ml-2",children:(0,a.jsx)(l.Z,{size:16})})]}),(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:[{label:"15m",value:"15m"},{label:"1h",value:"1h"},{label:"6h",value:"6h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"}].map(e=>(0,a.jsx)("button",{onClick:()=>N(e.value),className:"px-2 py-1 text-xs font-medium rounded border transition-colors ".concat(h.from==="now-".concat(e.value)&&"now"===h.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.jsx)("div",{className:"mt-2 text-xs text-gray-500",children:o&&o.length>0?(0,a.jsxs)(a.Fragment,{children:["Showing:"," ","$__all"===m?"All nodes":m," ","• Time: ",h.from," to ",h.to,c.length>0&&(0,a.jsxs)("span",{children:[" ","• ",c.length," nodes available"]})]}):(0,a.jsxs)(a.Fragment,{children:["Cluster:"," ",n?t.replace(/^ssh-/,""):t," ","• Time: ",h.from," to ",h.to," • Showing metrics for all nodes in cluster"]})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[(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:b("6"),width:"100%",height:"400",frameBorder:"0",title:"GPU Utilization",className:"rounded"},"gpu-util-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(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:b("18"),width:"100%",height:"400",frameBorder:"0",title:"GPU Memory",className:"rounded"},"gpu-memory-".concat(m,"-").concat(h.from,"-").concat(h.to))})}),(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:b("10"),width:"100%",height:"400",frameBorder:"0",title:"GPU Power Consumption",className:"rounded"},"gpu-power-".concat(m,"-").concat(h.from,"-").concat(h.to))})})]})]})]})})})}function z(e){var t;let{poolName:s,gpusInContext:c,nodesInContext:i,handleDeploySSHPool:d,handleEditSSHPool:m,handleDeleteSSHPool:u,poolConfig:h}=e,[x,p]=(0,r.useState)(null),[g,f]=(0,r.useState)(!0),[y,j]=(0,r.useState)({isOpen:!1,action:null,loading:!1}),[b,P]=(0,r.useState)({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});(0,r.useEffect)(()=>{(async()=>{try{f(!0);let e=await w(s);p(e)}catch(e){console.error("Failed to fetch SSH Node Pool status:",e),p({pool_name:s,status:"Error",reason:"Failed to fetch status"})}finally{f(!1)}})()},[s]);let{deployDisabled:k}=(()=>{if(!x)return{deployDisabled:!0};let e=x.status;return"Ready"===e?{deployDisabled:!0}:"Error"===e?{deployDisabled:!0}:{deployDisabled:!1}})(),T=async()=>{j({...y,loading:!0});try{if("deploy"===y.action){j({isOpen:!1,action:null,loading:!1}),P({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await d(s)).request_id;P(t=>({...t,requestId:e}));let t=new AbortController;await v({requestId:e,signal:t.signal,onNewLog:e=>{P(t=>({...t,logs:t.logs+e}))}}),P(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0})),setTimeout(async()=>{(async()=>{try{let e=await w(s);p(e)}catch(e){console.error("Failed to fetch SSH Node Pool status after deployment:",e)}})()},1e3)}catch(e){console.error("Deployment failed:",e),P(t=>({...t,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:t.logs+"\nDeployment failed: ".concat(e.message)}))}}else if("delete"===y.action){j({isOpen:!1,action:null,loading:!1}),P({isOpen:!0,logs:"",isStreaming:!0,deploymentComplete:!1,deploymentSuccess:!1,requestId:null});try{let e=(await N(s)).request_id;P(t=>({...t,requestId:e})),e&&await S({requestId:e,signal:null,onNewLog:e=>{P(t=>({...t,logs:t.logs+e}))},operationType:"down"}),await u(s),P(e=>({...e,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!0,logs:e.logs+"\nSSH Node Pool teardown completed successfully."}))}catch(e){console.error("Down operation failed:",e),P(t=>({...t,isStreaming:!1,deploymentComplete:!0,deploymentSuccess:!1,logs:t.logs+"\nTeardown failed: ".concat(e.message)}))}}}catch(e){console.error("Action failed:",e),j({...y,loading:!1})}},E=()=>{j({isOpen:!1,action:null,loading:!1})},H=()=>{P({isOpen:!1,logs:"",isStreaming:!1,deploymentComplete:!1,deploymentSuccess:!1,requestId:null}),b.deploymentComplete&&setTimeout(()=>{(async()=>{try{let e=await w(s);p(e)}catch(e){console.error("Failed to refresh status:",e)}})()},1e3)},D="deploy"===y.action?{title:"Deploy SSH Node Pool",description:'Are you sure you want to deploy SSH Node Pool "'.concat(s,'"?'),details:["• Set up SkyPilot runtime on the configured SSH hosts","• Install required components and dependencies","• Make the node pool available for workloads","","This process may take a few minutes to complete."]}:{title:"Delete SSH Node Pool",description:'Are you sure you want to delete SSH Node Pool "'.concat(s,'"?'),details:["• Clean up any deployed resources","• Remove the SSH Node Pool configuration"]};return(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"mb-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 pt-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"SSH Node Pool Details"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border rounded flex items-center ".concat(k?"border-gray-300 bg-gray-100 text-gray-400 cursor-not-allowed":"border-green-300 bg-green-50 text-green-700 hover:bg-green-100"),onClick:k?void 0:()=>{j({isOpen:!0,action:"deploy",loading:!1})},disabled:k,children:[(0,a.jsx)(o.Z,{className:"w-4 h-4 mr-2"}),"Deploy"]}),(0,a.jsxs)("button",{className:"px-3 py-1 text-sm border border-gray-300 rounded hover:bg-gray-50 flex items-center text-red-600 hover:text-red-700",onClick:()=>{j({isOpen:!0,action:"delete",loading:!1})},children:[(0,a.jsx)(n.Z,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]}),(0,a.jsx)("div",{className:"p-4",children:(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:"Pool Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:s})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Nodes"}),(0,a.jsx)("div",{className:"text-base mt-1",children:i?i.length:0})]}),(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:g?(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading..."})]}):x?(0,a.jsx)(e=>{let{status:t,reason:s}=e,r="Ready"===t,l="Not Ready"===t?"Click Deploy to set up this node pool":s;return(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("span",{className:"px-2 py-0.5 rounded text-xs font-medium ".concat(r?"bg-green-100":"bg-red-100"," ").concat(r?"text-green-800":"text-red-800"),children:t}),!r&&l&&(0,a.jsxs)("span",{className:"text-sm text-gray-600",children:["(",l,")"]})]})},{status:x.status,reason:x.reason}):(0,a.jsx)("span",{className:"text-gray-500",children:"Unknown"})})]})]})})]})}),(0,a.jsx)(L,{contextName:"ssh-".concat(s),gpusInContext:c,nodesInContext:i}),(0,a.jsx)(_.Vq,{open:y.isOpen,onOpenChange:E,children:(0,a.jsxs)(_.cZ,{className:"sm:max-w-md",children:[(0,a.jsxs)(_.fK,{className:"",children:[(0,a.jsx)(_.$N,{className:"",children:D.title}),(0,a.jsx)(_.Be,{className:"",children:D.description})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"text-sm text-gray-600 space-y-1",children:[(0,a.jsx)("p",{className:"font-medium mb-2",children:"This will:"}),D.details.map((e,t)=>(0,a.jsx)("p",{className:""===e?"pt-2":"",children:e},t))]})}),(0,a.jsxs)(_.cN,{className:"",children:[(0,a.jsx)(C.z,{variant:"outline",onClick:E,disabled:y.loading,className:"",children:"Cancel"}),(0,a.jsx)(C.z,{onClick:T,disabled:y.loading,className:"deploy"===y.action?"bg-green-600 hover:bg-green-700 text-white":"bg-red-600 hover:bg-red-700 text-white",children:y.loading?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),"deploy"===y.action?"Deploying...":"Deleting..."]}):"deploy"===y.action?"Deploy":"Delete"})]})]})}),(0,a.jsx)(_.Vq,{open:b.isOpen,onOpenChange:b.isStreaming?void 0:H,children:(0,a.jsxs)(_.cZ,{className:"sm:max-w-4xl max-h-[80vh]",children:[(0,a.jsxs)(_.fK,{className:"",children:[(0,a.jsxs)(_.$N,{className:"",children:["Deploying SSH Node Pool: ",s]}),(0,a.jsx)(_.Be,{className:"",children:b.isStreaming?"Deployment in progress. Do not close this dialog.":b.deploymentSuccess?"Deployment completed successfully!":"Deployment completed with errors."})]}),(0,a.jsx)("div",{className:"py-4",children:(0,a.jsxs)("div",{className:"bg-black text-green-400 p-4 rounded-md font-mono text-sm max-h-96 overflow-y-auto",children:[(0,a.jsx)("pre",{className:"whitespace-pre-wrap",children:(t=b.logs)?t.split("\n").map(e=>(e=e.replace(/\x1b\[[0-9;]*m/g,"")).match(/^D \d{2}-\d{2} \d{2}:\d{2}:\d{2}/)?null:e=(e=e.replace(/├──/g,"├─")).replace(/└──/g,"└─")).filter(e=>null!==e&&""!==e.trim()).join("\n"):""}),b.isStreaming&&(0,a.jsxs)("div",{className:"flex items-center mt-2",children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2 text-green-400"}),(0,a.jsx)("span",{className:"text-green-400",children:"Streaming logs..."})]})]})}),(0,a.jsx)(_.cN,{className:"",children:(0,a.jsx)(C.z,{onClick:H,disabled:b.isStreaming,className:b.deploymentSuccess?"bg-green-600 hover:bg-green-700 text-white":b.deploymentComplete&&!b.deploymentSuccess?"bg-red-600 hover:bg-red-700 text-white":"bg-gray-600 hover:bg-gray-700 text-white",children:b.isStreaming?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.Z,{size:16,className:"mr-2"}),"Deploying..."]}):"Close"})})]})})]})}function Z(){let[e,t]=(0,r.useState)(!0),[s,o]=(0,r.useState)(!0),[n,d]=(0,r.useState)(!0),x=r.useRef(null),p=(0,i.X)(),[j,N]=(0,r.useState)(!1),[w,v]=(0,r.useState)(!1),S=(0,I.useRouter)(),[_,C]=(0,r.useState)([]),[P,k]=(0,r.useState)([]),[T,U]=(0,r.useState)([]),[F,q]=(0,r.useState)([]),[R,Z]=(0,r.useState)([]),[M,W]=(0,r.useState)(0),[$,B]=(0,r.useState)(0),[K,V]=(0,r.useState)({}),[J,X]=(0,r.useState)({}),[Q,Y]=(0,r.useState)(!1),[ee,et]=(0,r.useState)(null),[es,ea]=(0,r.useState)(!1),[er,el]=(0,r.useState)(null),eo=r.useCallback(async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{showLoadingIndicators:!0};e.showLoadingIndicators&&(t(!0),o(!0));try{let e=await H.default.get(m.l4),{gpuData:t,cloudData:s}=e||{};if(t){let{allContextNames:e,allGPUs:s,perContextGPUs:a,perNodeGPUs:r,contextStats:l}=t;C(e||[]),k(s||[]),U(a||[]),q(r||[]),V(l||{}),N(!0)}else e&&null===e.gpuData?(C([]),k([]),U([]),q([]),V({}),N(!0)):e||console.log("No infra data received from cache");s?(Z(s.clouds||[]),W(s.totalClouds||0),B(s.enabledClouds||0),v(!0)):e&&null===e.cloudData?(Z([]),W(0),B(0),v(!0)):e||console.log("No cloud data received from cache"),await en()}catch(e){console.error("Error in fetchData:",e),C([]),k([]),U([]),q([]),V({}),Z([]),W(0),B(0),N(!0),v(!0)}finally{e.showLoadingIndicators&&(t(!1),o(!1)),n&&e.showLoadingIndicators&&d(!1)}},[n]),en=async()=>{try{let e=await g();X(e)}catch(e){console.error("Failed to fetch SSH Node Pools:",e),X({})}},ec=(e,t)=>{et({name:e,config:t}),Y(!0)},ei=async e=>{try{await y(e),await en(),el(null),S.push("/infra")}catch(e){throw console.error("Failed to delete SSH Node Pool:",e),e}},ed=async e=>{try{await b(e)}catch(e){throw console.error("Failed to deploy SSH Node Pool:",e),e}},em=async(e,t)=>{ea(!0);try{let s={...J};s[e]=t,await f(s),await en(),Y(!1)}catch(e){console.error("Failed to save SSH Node Pool:",e),alert("Failed to save SSH Node Pool. Please try again.")}finally{ea(!1)}};(0,r.useEffect)(()=>{x.current=eo},[eo]),(0,r.useEffect)(()=>{(async()=>{await D.ZP.preloadForPage("infra"),eo({showLoadingIndicators:!0})})()},[eo]),(0,r.useEffect)(()=>{let e=!0,t=setInterval(()=>{e&&x.current&&x.current({showLoadingIndicators:!1})},O);return()=>{e=!1,clearInterval(t)}},[]),(0,r.useEffect)(()=>()=>{N(!1),v(!1),d(!0)},[]),(P||[]).length,(P||[]).reduce((e,t)=>e+t.gpu_total,0),(P||[]).reduce((e,t)=>e+t.gpu_free,0);let eu=r.useMemo(()=>T?T.reduce((e,t)=>{let{context:s}=t;return e[s]||(e[s]=[]),e[s].push(t),e},{}):{},[T]),eh=r.useMemo(()=>_&&Array.isArray(_)?_.filter(e=>e.startsWith("ssh-")):[],[_]),ex=r.useMemo(()=>_&&Array.isArray(_)?_.filter(e=>!e.startsWith("ssh-")):[],[_]),ep=r.useMemo(()=>{if(!T||!P)return[];let e=new Set;return T.forEach(t=>{t.context.startsWith("ssh-")&&e.add(t.gpu_name)}),P.filter(t=>e.has(t.gpu_name))},[P,T]),eg=r.useMemo(()=>{if(!T||!P)return[];let e=new Set;return T.forEach(t=>{t.context.startsWith("ssh-")||e.add(t.gpu_name)}),P.filter(t=>e.has(t.gpu_name))},[P,T]),ef=r.useMemo(()=>F?F.reduce((e,t)=>{let{context:s}=t;return e[s]||(e[s]=[]),e[s].push(t),e},{}):{},[F]);(0,r.useEffect)(()=>{S.isReady&&S.query.context&&el(decodeURIComponent(Array.isArray(S.query.context)?S.query.context[0]:S.query.context))},[S.isReady,S.query.context]);let ey=e=>{el(e),S.push("/infra/".concat(encodeURIComponent(e)))},ej=t=>{let s=eu[t]||[],r=ef[t]||[];if(e&&!j)return(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(l.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]});if(t.startsWith("ssh-")){let e=t.replace(/^ssh-/,"");return(0,a.jsx)(z,{poolName:e,gpusInContext:s,nodesInContext:r,handleDeploySSHPool:ed,handleEditSSHPool:ec,handleDeleteSSHPool:ei,poolConfig:J[e]})}return(0,a.jsx)(L,{contextName:t,gpusInContext:s,nodesInContext:r})},eb=()=>s||!w?(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold mb-4",children:"Cloud"}),(0,a.jsxs)("div",{className:"flex items-center justify-center py-6",children:[(0,a.jsx)(l.Z,{size:24,className:"mr-3"}),(0,a.jsx)("span",{className:"text-gray-500",children:"Loading Cloud..."})]})]})}):(0,a.jsx)("div",{className:"rounded-lg border bg-card text-card-foreground shadow-sm mb-6",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-semibold",children:"Cloud"}),(0,a.jsxs)("span",{className:"ml-2 px-2 py-0.5 bg-blue-100 text-blue-800 rounded-full text-xs font-medium",children:[$," of ",M," enabled"]})]}),R&&0!==R.length?(0,a.jsx)("div",{className:"overflow-x-auto rounded-md border border-gray-200 shadow-sm bg-white",children:(0,a.jsxs)("table",{className:"min-w-full text-sm",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-32",children:"Cloud"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Clusters"}),(0,a.jsx)("th",{className:"p-3 text-left font-medium text-gray-600 w-24",children:"Jobs"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:R.map(e=>(0,a.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,a.jsx)("td",{className:"p-3 font-medium text-gray-700",children:e.name}),(0,a.jsx)("td",{className:"p-3",children:e.clusters>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-blue-100 text-blue-800 rounded text-xs font-medium",children:e.clusters}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})}),(0,a.jsx)("td",{className:"p-3",children:e.jobs>0?(0,a.jsx)("span",{className:"px-2 py-0.5 bg-green-100 text-green-800 rounded text-xs font-medium",children:e.jobs}):(0,a.jsx)("span",{className:"px-2 py-0.5 bg-gray-100 text-gray-500 rounded text-xs font-medium",children:"0"})})]},e.name))})]})}):(0,a.jsx)("p",{className:"text-sm text-gray-500",children:"No enabled clouds available."})]})}),eN=()=>(0,a.jsx)(G,{title:"SSH Node Pool",isLoading:e,isDataLoaded:j,contexts:eh,gpus:ep,groupedPerContextGPUs:eu,groupedPerNodeGPUs:ef,handleContextClick:ey,contextStats:K,isSSH:!0,actionButton:null}),ew=()=>(0,a.jsx)(G,{title:"Kubernetes",isLoading:e,isDataLoaded:j,contexts:ex,gpus:eg,groupedPerContextGPUs:eu,groupedPerNodeGPUs:ef,handleContextClick:ey,contextStats:K,isSSH:!1}),ev=e||s,eS=j&&w&&!n;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(A(),{href:"/infra",className:"text-sky-blue hover:underline ".concat(er?"":"cursor-default"),children:"Infrastructure"}),er&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),er.startsWith("ssh-")?(0,a.jsx)(A(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"SSH Node Pool"}):(0,a.jsx)(A(),{href:"/infra",className:"text-sky-blue hover:underline cursor-pointer",children:"Kubernetes"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)("span",{className:"text-sky-blue",children:er.startsWith("ssh-")?er.replace(/^ssh-/,""):er})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[ev&&(0,a.jsxs)("div",{className:"flex items-center mr-2",children:[(0,a.jsx)(l.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsxs)("button",{onClick:()=>{H.default.invalidate(u.getClusters),H.default.invalidate(h.getManagedJobs,[{allUsers:!0}]),H.default.invalidate(m.l4),x.current&&x.current({showLoadingIndicators:!0})},disabled:ev,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1.5"}),!p&&"Refresh"]})]})]}),eS?(()=>{if(er)return e&&!j?(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center h-64",children:[(0,a.jsx)(l.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading Context..."})]}):ej(er);let t=[];t.push({name:"Kubernetes",render:ew,hasActivity:ex.length>0,priority:1}),t.push({name:"Cloud",render:eb,hasActivity:$>0,priority:2}),t.push({name:"SSH Node Pool",render:eN,hasActivity:eh.length>0&&function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.some(e=>{let s=K[t?"ssh/".concat(e.replace(/^ssh-/,"")):"kubernetes/".concat(e)]||{clusters:0,jobs:0};return s.clusters>0||s.jobs>0})}(eh,!0),priority:3});let s=t.sort((e,t)=>e.hasActivity!==t.hasActivity?e.hasActivity?-1:1:e.priority-t.priority);return(0,a.jsx)(a.Fragment,{children:s.map((e,t)=>(0,a.jsx)(r.Fragment,{children:e.render()},t))})})():(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center py-32",children:[(0,a.jsx)(l.Z,{size:32,className:"mb-4"}),(0,a.jsx)("span",{className:"text-gray-500 text-lg",children:"Loading infrastructure data..."})]}),(0,a.jsx)(E,{isOpen:Q,onClose:()=>Y(!1),onSave:em,poolData:ee,isLoading:es})]})}},2557:function(e,t,s){s.d(t,{I:function(){return o}});var a=s(5893),r=s(7294),l=s(2350);let o=r.forwardRef((e,t)=>{let{className:s,type:r,...o}=e;return(0,a.jsx)("input",{type:r,className:(0,l.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...o})});o.displayName="Input"},6185:function(e,t,s){s.d(t,{_:function(){return i}});var a=s(5893),r=s(7294),l=s(9102),o=s(2003),n=s(2350);let c=(0,o.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),i=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(l.f,{ref:t,className:(0,n.cn)(c(),s),...r})});i.displayName=l.f.displayName},9123:function(e,t,s){s.d(t,{g:function(){return o}});var a=s(5893),r=s(7294),l=s(2350);let o=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("textarea",{className:(0,l.cn)("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),ref:t,...r})});o.displayName="Textarea"},7853:function(e,t,s){s.d(t,{TO:function(){return l},ki:function(){return o}});let a=null,r=null,l=async()=>null!==a?a:r||(r=(async()=>{try{let e="".concat(window.location.origin,"/grafana"),t=await fetch("".concat(e,"/api/health"),{method:"GET",credentials:"include",headers:{Accept:"application/json"},signal:AbortSignal.timeout(5e3)});return 200==t.status}catch(e){return console.debug("Grafana availability check failed:",e),a=!1,!1}finally{r=null}})()),o=()=>"".concat(window.location.origin,"/grafana")}}]);
@@ -0,0 +1,11 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9826,2544],{4966:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/clusters/[cluster]/[job]",function(){return s(190)}])},8671:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
2
+ * @license lucide-react v0.407.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */let a=(0,s(998).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},3626:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});/**
7
+ * @license lucide-react v0.407.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */let a=(0,s(998).Z)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},9307:function(e,t,s){"use strict";s.d(t,{Cl:function(){return l},OE:function(){return d}});var a=s(5893);s(7294);var r=s(5739),n=s(6989),c=s(3850);let l=e=>{switch(e){case"LAUNCHING":return"bg-blue-100 text-sky-blue";case"RUNNING":case"IN_USE":return"bg-green-50 text-green-700";case"STOPPED":return"bg-yellow-100 text-yellow-800";case"TERMINATED":default:return"bg-gray-100 text-gray-800";case"PENDING":case"CANCELLED":case"CANCELLING":return"bg-yellow-50 text-yellow-700";case"SUCCEEDED":return"bg-blue-50 text-blue-700";case"FAILED":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":return"bg-red-50 text-red-700";case"RECOVERING":return"bg-orange-50 text-orange-700";case"SUBMITTED":case"READY":return"bg-indigo-50 text-indigo-700";case"STARTING":return"bg-cyan-50 text-cyan-700";case"FAILED_SETUP":return"bg-pink-50 text-pink-700"}},o=e=>{switch(e){case"LAUNCHING":case"STARTING":return(0,a.jsx)(r.Z,{size:12,className:"w-3 h-3 mr-1"});case"RUNNING":case"IN_USE":default:return(0,a.jsx)(c.W2,{className:"w-3 h-3 mr-1"});case"STOPPED":return(0,a.jsx)(c.fp,{className:"w-3 h-3 mr-1"});case"TERMINATED":case"FAILED":case"CANCELLED":return(0,a.jsx)(c.Ps,{className:"w-3 h-3 mr-1"});case"SUCCEEDED":return(0,a.jsx)(c.Ye,{className:"w-3 h-3 mr-1"});case"PENDING":case"RECOVERING":case"SUBMITTED":case"CANCELLING":case"FAILED_SETUP":case"FAILED_PRECHECKS":case"FAILED_NO_RESOURCE":case"FAILED_CONTROLLER":case"READY":return(0,a.jsx)(c.J$,{className:"w-3 h-3 mr-1"})}},i=e=>{let t=l(e),s=o(e);return(0,a.jsxs)("span",{className:"".concat("inline-flex items-center px-2 py-1 rounded-full text-sm"," ").concat(t),children:[s,e]})},d=e=>{let{status:t}=e;return(0,a.jsx)(n.WH,{content:t,className:"text-muted-foreground text-sm",children:(0,a.jsx)("span",{children:i(t)})})}},546:function(e,t,s){"use strict";s.d(t,{H:function(){return d}});var a=s(5893);s(7294);var r=s(1664),n=s.n(r),c=s(5697),l=s.n(c);function o(e){return!!e&&"string"==typeof e&&e.toLowerCase().startsWith("sa-")}let i=()=>(0,a.jsx)("span",{className:"px-2 py-0.5 text-xs bg-blue-100 text-blue-700 rounded font-medium ml-1",children:"SA"}),d=e=>{let{username:t,userHash:s,className:r="flex items-center gap-1",linkClassName:c="text-gray-700 hover:text-blue-600 hover:underline",showBadge:l=!0}=e,d=o(s),u=o(s)?"/users?tab=service-accounts":"/users";return(0,a.jsxs)("div",{className:r,children:[(0,a.jsx)(n(),{href:u,className:c,children:t}),l&&d&&(0,a.jsx)(i,{})]})};d.propTypes={username:l().string.isRequired,userHash:l().string,className:l().string,linkClassName:l().string,showBadge:l().bool}},7673:function(e,t,s){"use strict";s.d(t,{Ol:function(){return i},Zb:function(){return o},aY:function(){return h},ll:function(){return d}});var a=s(5893),r=s(7294),n=s(5697),c=s.n(n),l=s(2350);let o=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",s),...n,children:r})});o.displayName="Card",o.propTypes={className:c().string,children:c().node};let i=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("flex flex-col space-y-1.5 p-6",s),...n,children:r})});i.displayName="CardHeader",i.propTypes={className:c().string,children:c().node};let d=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("h3",{ref:t,className:(0,l.cn)("text-2xl font-semibold leading-none tracking-tight",s),...n,children:r})});d.displayName="CardTitle",d.propTypes={className:c().string,children:c().node};let u=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("p",{ref:t,className:(0,l.cn)("text-sm text-muted-foreground",s),...n,children:r})});u.displayName="CardDescription",u.propTypes={className:c().string,children:c().node};let h=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("p-6 pt-0",s),...n,children:r})});h.displayName="CardContent",h.propTypes={className:c().string,children:c().node};let m=r.forwardRef((e,t)=>{let{className:s,children:r,...n}=e;return(0,a.jsx)("div",{ref:t,className:(0,l.cn)("flex items-center p-6 pt-0",s),...n,children:r})});m.displayName="CardFooter",m.propTypes={className:c().string,children:c().node}},7145:function(e,t,s){"use strict";s.d(t,{x:function(){return r}});var a=s(3225);let r={fetch:async function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"POST",r=window.location.origin,n="".concat(r).concat(a.f4).concat(e),c=await fetch(n,{method:s,headers:"POST"===s?{"Content-Type":"application/json"}:{},body:"POST"===s?JSON.stringify(t):void 0}),l=c.headers.get("X-Skypilot-Request-ID")||c.headers.get("X-Request-ID"),o=await fetch("".concat(r).concat(a.f4,"/api/get?request_id=").concat(l)),i=await o.json();return i.return_value?JSON.parse(i.return_value):[]},post:async(e,t)=>{let s=window.location.origin,r="".concat(s).concat(a.f4).concat(e);return await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},stream:async(e,t,s)=>{let a=(await r.post(e,t)).body.getReader();try{for(;;){let{done:e,value:t}=await a.read();if(e)break;let r=new TextDecoder().decode(t);s(r)}}catch(e){throw console.error("Error in stream:",e),e}},get:async e=>{let t=window.location.origin,s="".concat(t).concat(a.f4).concat(e);return await fetch(s)}}},3266:function(e,t,s){"use strict";s.d(t,{QL:function(){return h},Sl:function(){return d},getClusters:function(){return o},uR:function(){return i}});var a=s(7294),r=s(5821),n=s(7145),c=s(6378);let l={UP:"RUNNING",STOPPED:"STOPPED",INIT:"LAUNCHING",null:"TERMINATED"};async function o(){let{clusterNames:e=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{return(await n.x.fetch("/status",{cluster_names:e,all_users:!0})).map(e=>{let t="",s=t=e.zone?e.zone:e.region;return t&&t.length>25&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15;if(!e||e.length<=t)return e;if(t<=3)return"...";let s=Math.floor((t-3)/2),a=s+(t-3)%2;return 0===s?e.substring(0,a)+"...":e.substring(0,a)+"..."+e.substring(e.length-s)}(t,25)),{status:l[e.status],cluster:e.name,user:e.user_name,user_hash:e.user_hash,cloud:e.cloud,region:e.region,infra:t?e.cloud+" ("+t+")":e.cloud,full_infra:s?"".concat(e.cloud," (").concat(s,")"):e.cloud,cpus:e.cpus,mem:e.memory,gpus:e.accelerators,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:new Date(1e3*e.launched_at),num_nodes:e.nodes,workspace:e.workspace,autostop:e.autostop,to_down:e.to_down,jobs:[],command:e.last_creation_command||e.last_use,task_yaml:e.last_creation_yaml||"{}",events:[{time:new Date(1e3*e.launched_at),event:"Cluster created."}]}})}catch(e){return console.error("Error fetching clusters:",e),[]}}async function i(){try{let e=await n.x.fetch("/cost_report",{days:30});console.log("Raw cluster history data:",e);let t=e.map(e=>{let t="Unknown";e.cloud?t=e.cloud:e.resources&&e.resources.cloud&&(t=e.resources.cloud);let s=e.user_name||"-";return{status:e.status?l[e.status]:"TERMINATED",cluster:e.name,user:s,user_hash:e.user_hash,cloud:t,region:"",infra:t,full_infra:t,resources_str:e.resources_str,resources_str_full:e.resources_str_full,time:e.launched_at?new Date(1e3*e.launched_at):null,num_nodes:e.num_nodes||1,duration:e.duration,total_cost:e.total_cost,workspace:e.workspace||"default",autostop:-1,to_down:!1,cluster_hash:e.cluster_hash,usage_intervals:e.usage_intervals,command:e.last_creation_command||"",task_yaml:e.last_creation_yaml||"{}",events:[{time:e.launched_at?new Date(1e3*e.launched_at):new Date,event:"Cluster created."}]}});return console.log("Processed cluster history data:",t),t}catch(e){return console.error("Error fetching cluster history:",e),[]}}async function d(e){let{clusterName:t,jobId:s,onNewLog:a,workspace:c}=e;try{await n.x.stream("/logs",{follow:!1,cluster_name:t,job_id:s,override_skypilot_config:{active_workspace:c||"default"}},a)}catch(e){console.error("Error in streamClusterJobLogs:",e),(0,r.C)("Error in streamClusterJobLogs: ".concat(e.message),"error")}}async function u(e){let{clusterName:t,workspace:s}=e;try{return(await n.x.fetch("/queue",{cluster_name:t,all_users:!0,override_skypilot_config:{active_workspace:s}})).map(e=>{var a;let r=e.end_at?e.end_at:Date.now()/1e3,n=0,c=0;return e.submitted_at&&(n=r-e.submitted_at),e.start_at&&(c=r-e.start_at),{id:e.job_id,status:e.status,job:e.job_name,user:e.username,user_hash:e.user_hash,gpus:e.accelerators||{},submitted_at:e.submitted_at?new Date(1e3*e.submitted_at):null,resources:e.resources,cluster:t,total_duration:n,job_duration:c,infra:"",logs:"",workspace:s||"default",git_commit:(null===(a=e.metadata)||void 0===a?void 0:a.git_commit)||"-"}})}catch(e){return console.error("Error fetching cluster jobs:",e),[]}}function h(e){let{cluster:t,job:s=null}=e,[r,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(null),[d,h]=(0,a.useState)(!0),[m,f]=(0,a.useState)(!0),x=(0,a.useCallback)(async()=>{if(t)try{h(!0);let e=await c.default.get(o,[{clusterNames:[t]}]);return n(e[0]),e[0]}catch(e){console.error("Error fetching cluster data:",e)}finally{h(!1)}return null},[t]),g=(0,a.useCallback)(async e=>{if(t)try{f(!0);let s=await c.default.get(u,[{clusterName:t,workspace:e||"default"}]);i(s)}catch(e){console.error("Error fetching cluster job data:",e)}finally{f(!1)}},[t]),b=(0,a.useCallback)(async()=>{c.default.invalidate(o,[{clusterNames:[t]}]);let e=await x();e&&(c.default.invalidate(u,[{clusterName:t,workspace:e.workspace||"default"}]),await g(e.workspace))},[x,g,t]),N=(0,a.useCallback)(async()=>{r&&(c.default.invalidate(u,[{clusterName:t,workspace:r.workspace||"default"}]),await g(r.workspace))},[g,r,t]);return(0,a.useEffect)(()=>{(async()=>{let e=await x();e&&g(e.workspace)})()},[t,s,x,g]),{clusterData:r,clusterJobData:l,loading:d,clusterDetailsLoading:d,clusterJobsLoading:m,refreshData:b,refreshClusterJobsOnly:N}}},5821:function(e,t,s){"use strict";function a(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3,a=document.getElementById("toast-container");a||((a=document.createElement("div")).id="toast-container",a.className="fixed top-0 right-0 p-4 z-[9999] flex flex-col items-end space-y-2",document.body.appendChild(a));let r=document.createElement("div");switch(r.className="rounded-md border-l-4 p-4 shadow-md flex items-center justify-between max-w-md w-full mb-2 pointer-events-auto",t){case"success":r.className+=" bg-green-100 border-green-500 text-green-800";break;case"error":r.className+=" bg-red-100 border-red-500 text-red-800";break;case"warning":r.className+=" bg-yellow-100 border-yellow-500 text-yellow-800";break;default:r.className+=" bg-blue-100 border-blue-500 text-blue-800"}return r.innerHTML='\n <div class="flex-1 mr-2">\n <p class="text-sm font-medium">'.concat(e,'</p>\n </div>\n <button class="text-gray-500 hover:text-gray-700 focus:outline-none" aria-label="Close toast">\n <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>\n </button>\n '),a.appendChild(r),r.querySelector("button").addEventListener("click",()=>{a.removeChild(r)}),setTimeout(()=>{a.contains(r)&&a.removeChild(r)},s),r}s.d(t,{C:function(){return a}})},6378:function(e,t,s){"use strict";s.r(t),s.d(t,{DashboardCache:function(){return r},dashboardCache:function(){return n}});let a=s(1214).ej.DEFAULT_TTL;class r{async get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=s.ttl||a,n=!1!==s.refreshOnAccess,c=this._generateKey(e,t),l=e.name||"anonymous",o=this.cache.get(c),i=Date.now();if(o&&i-o.lastUpdated<r){let s=Math.round((i-o.lastUpdated)/1e3);return this._debug("Cache HIT for ".concat(l," (age: ").concat(s,"s, TTL: ").concat(Math.round(r/1e3),"s)")),n&&(this.cache.set(c,{data:o.data,lastUpdated:i}),this._debug("Cache TTL refreshed for ".concat(l))),this.backgroundJobs.has(c)||this._refreshInBackground(e,t,c),o.data}try{let s=await e(...t);return this.cache.set(c,{data:s,lastUpdated:i}),s}catch(e){if(o)return console.warn("Failed to fetch fresh data for ".concat(c,", returning stale data:"),e),o.data;throw e}}invalidate(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],s=this._generateKey(e,t);this.cache.delete(s),this.backgroundJobs.delete(s)}invalidateFunction(e){let t=e.name||"anonymous",s=[];for(let e of this.cache.keys())e.startsWith("".concat(t,"_"))&&s.push(e);s.forEach(e=>{this.cache.delete(e),this.backgroundJobs.delete(e)})}clear(){this.cache.clear(),this.backgroundJobs.clear()}getStats(){return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,keys:Array.from(this.cache.keys())}}getDetailedStats(){let e=Date.now(),t=[];for(let[s,a]of this.cache.entries()){let r=e-a.lastUpdated;t.push({key:s,age:Math.round(r/1e3),lastUpdated:new Date(a.lastUpdated).toISOString(),hasBackgroundJob:this.backgroundJobs.has(s)})}return{cacheSize:this.cache.size,backgroundJobs:this.backgroundJobs.size,entries:t.sort((e,t)=>e.age-t.age)}}setDebugMode(e){this.debugMode=e}_debug(e){for(var t=arguments.length,s=Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];this.debugMode&&console.log("[DashboardCache] ".concat(e),...s)}_refreshInBackground(e,t,s){this.backgroundJobs.set(s,!0),e(...t).then(e=>{this.cache.set(s,{data:e,lastUpdated:Date.now()})}).catch(e=>{console.warn("Background refresh failed for ".concat(s,":"),e)}).finally(()=>{this.backgroundJobs.delete(s)})}_generateKey(e,t){let s=function(e){let t=5381;for(let s=0;s<e.length;s++)t=(t<<5)+t+e.charCodeAt(s);return t>>>0}(e.toString()),a=t.length>0?JSON.stringify(t):"";return"".concat(s,"_").concat(a)}constructor(){this.cache=new Map,this.backgroundJobs=new Map,this.debugMode=!1}}let n=new r;t.default=n},2350:function(e,t,s){"use strict";s.d(t,{cn:function(){return n}});var a=s(512),r=s(8388);function n(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.m6)((0,a.W)(t))}},190:function(e,t,s){"use strict";s.r(t),s.d(t,{JobDetailPage:function(){return j}});var a=s(5893),r=s(7294);s(9470);var n=s(7673),c=s(1664),l=s.n(c),o=s(1163),i=s(3266),d=s(6989),u=s(3626),h=s(5739),m=s(9307),f=s(3001),x=s(9008),g=s.n(x),b=s(546),N=s(282),p=s(8671);function y(e){let{cluster:t,job:s,jobData:r,onRefresh:n,isRefreshing:c,loading:o}=e,i=(0,f.X)();return(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4 h-5",children:[(0,a.jsxs)("div",{className:"text-base flex items-center",children:[(0,a.jsx)(l(),{href:"/clusters",className:"text-sky-blue hover:underline",children:"Sky Clusters"}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsx)(l(),{href:"/clusters/".concat(t),className:"text-sky-blue hover:underline",children:t}),(0,a.jsx)("span",{className:"mx-2 text-gray-500",children:"›"}),(0,a.jsxs)(l(),{href:"/clusters/".concat(t,"/").concat(s),className:"text-sky-blue hover:underline",children:[s,r.job&&"-"!=r.job?" (".concat(r.job,")"):""]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(o||c)&&(0,a.jsxs)("div",{className:"flex items-center mr-2",children:[(0,a.jsx)(h.Z,{size:15,className:"mt-0"}),(0,a.jsx)("span",{className:"text-sm ml-2 text-gray-500",children:"Loading..."})]}),(0,a.jsx)(d.WH,{content:"Refresh",className:"text-muted-foreground",children:(0,a.jsxs)("button",{onClick:n,disabled:o||c,className:"text-sm text-sky-blue hover:text-sky-blue-bright font-medium mx-2 flex items-center",children:[(0,a.jsx)(u.Z,{className:"w-4 h-4 mr-1.5"}),!i&&(0,a.jsx)("span",{children:"Refresh"})]})})]})]})}function j(){let e=(0,o.useRouter)(),{cluster:t,job:s}=e.query,{clusterData:c,clusterJobData:f,loading:x,refreshData:j}=(0,i.QL)({cluster:t}),[_,w]=(0,r.useState)(!1),[v,E]=(0,r.useState)(!0),[k,C]=(0,r.useState)(!1),[D,T]=(0,r.useState)([]),[S,I]=(0,r.useState)(!1),[R,L]=(0,r.useState)(!1),A=(0,r.useMemo)(()=>["INIT","PENDING","SETTING_UP"],[]),O=(0,r.useMemo)(()=>{if(!f||!s)return!0;let e=f.find(e=>e.id==s);return e&&A.includes(e.status)},[f,s,A]);r.useEffect(()=>{!x&&v&&E(!1)},[x,v]),(0,r.useEffect)(()=>{let e=!0;return t&&s&&!O?(C(!0),(0,i.Sl)({clusterName:t,jobId:s,onNewLog:t=>{if(e){let e=(0,d.q8)(t);T(t=>[...t,e])}},workspace:null==c?void 0:c.workspace}).then(()=>{e&&C(!1)}).catch(t=>{e&&(console.error("Error streaming logs:",t),C(!1))})):C(!1),()=>{e=!1}},[t,s,S,O,c]);let U=async()=>{w(!0),I(e=>!e),T([]);try{j&&await j()}catch(e){console.error("Error refreshing data:",e)}finally{w(!1)}};if(!e.isReady)return(0,a.jsx)("div",{children:"Loading..."});let P={id:s};if(c&&f){let e=f.find(e=>e.id==s);e&&(P={...e,infra:c.infra,cluster:c.cluster,user:c.user,user_hash:c.user_hash})}let J=t&&s?"Job: ".concat(s," @ ").concat(t," | SkyPilot Dashboard"):"Job Details | SkyPilot Dashboard";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g(),{children:(0,a.jsx)("title",{children:J})}),(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(y,{cluster:t,job:s,jobData:P,onRefresh:U,isRefreshing:_,loading:x}),x&&v?(0,a.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,a.jsx)(h.Z,{size:24,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]}):(0,a.jsxs)("div",{className:"space-y-8",children:[(0,a.jsx)("div",{id:"details",children:(0,a.jsxs)(n.Zb,{children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 pt-4",children:(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Details"})}),(0,a.jsx)("div",{className:"p-4",children:(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:"Job ID"}),(0,a.jsx)("div",{className:"text-base mt-1",children:P.id})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Job Name"}),(0,a.jsx)("div",{className:"text-base mt-1",children:P.job})]}),(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)(m.OE,{status:P.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)(b.H,{username:P.user,userHash:P.user_hash})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Submitted"}),(0,a.jsx)("div",{className:"text-base mt-1",children:P.submitted_at?(0,d.xn)(P.submitted_at):"N/A"})]}),P.resources&&(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:P.resources||"N/A"})]}),P.cluster&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Cluster"}),(0,a.jsx)("div",{className:"text-base mt-1",children:(0,a.jsx)(l(),{href:"/clusters/".concat(P.cluster),className:"text-sky-blue hover:underline",children:P.cluster})})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-gray-600 font-medium text-base",children:"Git Commit"}),(0,a.jsx)("div",{className:"text-base mt-1 flex items-center",children:P.git_commit&&"-"!==P.git_commit?(0,a.jsxs)("span",{className:"flex items-center mr-2",children:[P.git_commit,(0,a.jsx)(d.WH,{content:R?"Copied!":"Copy commit",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:async()=>{await navigator.clipboard.writeText(P.git_commit),L(!0),setTimeout(()=>L(!1),2e3)},className:"flex items-center text-gray-500 hover:text-gray-700 transition-colors duration-200 p-1 ml-2",children:R?(0,a.jsx)(N.Z,{className:"w-4 h-4 text-green-600"}):(0,a.jsx)(p.Z,{className:"w-4 h-4"})})})]}):(0,a.jsx)("span",{className:"text-gray-400",children:"-"})})]})]})})]})}),(0,a.jsx)("div",{id:"logs",className:"mt-6",children:(0,a.jsxs)(n.Zb,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between px-4 pt-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:"Logs"}),(0,a.jsx)("span",{className:"ml-2 text-xs text-gray-500",children:"(Logs are not streaming; click refresh to fetch the latest logs.)"})]}),(0,a.jsx)(d.WH,{content:"Refresh logs",className:"text-muted-foreground",children:(0,a.jsx)("button",{onClick:()=>{I(e=>!e),T([])},disabled:k,className:"text-sky-blue hover:text-sky-blue-bright flex items-center",children:(0,a.jsx)(u.Z,{className:"w-4 h-4 ".concat(k?"animate-spin":"")})})})]}),(0,a.jsx)("div",{className:"p-4",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 job to start; refresh in a few moments."})}):k?(0,a.jsxs)("div",{className:"flex items-center justify-center py-4",children:[(0,a.jsx)(h.Z,{size:20,className:"mr-2"}),(0,a.jsx)("span",{children:"Loading..."})]}):(0,a.jsx)("div",{className:"max-h-96 overflow-y-auto",children:(0,a.jsx)(d.$B,{logs:D.join("")})})})]})})]})]})]})}t.default=j},9008:function(e,t,s){e.exports=s(7219)},1163:function(e,t,s){e.exports=s(6036)}},function(e){e.O(0,[616,5230,5739,1664,804,6989,3698,9470,2888,9774,179],function(){return e(e.s=4966)}),_N_E=e.O()}]);