import{aw as O,j as e,D as I,b$ as c,p as K,bn as F,aW as z,a0 as X,f as l,T as je,a1 as ge,fw as fe,cH as ne,a as i,cN as y,c5 as te,r as f,cI as W,cJ as k,c as _,bV as S,a3 as q,a5 as M,fH as be,b9 as J,t as A,eh as Ee,L as U,cC as Ce,bP as ie,aJ as $,cM as E,bQ as ae,bU as oe,k as ce,u as le,fI as ve,m as G,f5 as De,fJ as H,fK as Ne,cD as ke,bd as Te,aH as Le,bs as Se,ao as Ie,ap as we,d as _e,aI as Re,fL as Z,ax as Pe,dO as Me,fM as Ae,fN as Oe,fE as Ve,W as L}from"./index-_eM6l4Nf.js";import{A as ye,a as D}from"./Anchor-JEsUSbQH.js";import{C as N}from"./CardBoundary-Cynv84oW.js";import{M as $e}from"./ModelSchema-CvBXl9fG.js";import{u as de}from"./useProjectId-BzgWWAl7.js";import{d as Fe}from"./index-BXwHI1zk.js";import{s as g}from"./styles-BK4Eh60z.js";import{u as Ge,a as He}from"./index-Dow74AVU.js";import{I as Be,K as ue,a as xe,b as he,N as pe,h as ee,g as re,c as Ke}from"./utils-CSOjPL09.js";import{P as qe}from"./Panel-BNKhRIJO.js";import{u as Ue,a as We,D as me}from"./useDeploymentKibanaLink-BavouVgj.js";import{S as Je}from"./StatusBadge-DaepizUt.js";import{G as Qe}from"./GrafanaDashboard-C8RHXN8Z.js";import{K as Ye}from"./KubernetesProjectView-XdEEUXJt.js";import{K as ze}from"./KeywordsEditor-CUXwN9GI.js";import"./Deprecated-Cn0z8EIY.js";import"./CardLabels-DXqh0OoW.js";const Xe=({deployment:r})=>{const{isLoading:s,project:n}=O(),t=()=>{const a=["Serving tool","API protocol","Inference logging","Kafka topic","Request batching"];return K(F(()=>r.batchingConfiguration.batchingEnabled,z(X,["Maximum batch size","Maximum latency (ms)","Timeout (s)"])))(a)},o=()=>{var u,b,p,m;const a=[e.jsx(c.Cell,{children:e.jsx(l,{children:r.servingTool})},"ac.servingTool"),e.jsx(c.Cell,{children:e.jsx(l,{children:je(r.apiProtocol,ge(fe))})},"ac.apiProtocol"),e.jsx(c.Cell,{children:e.jsx(l,{color:(u=r.inferenceLogging)!=null&&u.toLowerCase()?"black":"gray",children:((b=r.inferenceLogging)==null?void 0:b.toLowerCase())??"disabled"})},"ac.inferenceLogging"),e.jsx(c.Cell,{children:e.jsx(l,{sx:{userSelect:"all"},color:(p=r.kafkaTopicDTO)!=null&&p.name?"black":"gray",children:((m=r.kafkaTopicDTO)==null?void 0:m.name)??"disabled"})},"ac.kafkaTopic"),e.jsx(c.Cell,{children:e.jsx(l,{color:r.batchingConfiguration.batchingEnabled?"black":"gray",children:r.batchingConfiguration.batchingEnabled?"enabled":"disabled"})},"ac.batchingEnabled")],d=[e.jsx(c.Cell,{children:e.jsx(l,{children:r.batchingConfiguration.maxBatchSize})},"ac.maxBatchSize"),e.jsx(c.Cell,{children:e.jsx(l,{children:r.batchingConfiguration.maxLatency})},"ac.maxLatency"),e.jsx(c.Cell,{children:e.jsx(l,{children:r.batchingConfiguration.timeout})},"ac.timeout")];return K(F(()=>r.batchingConfiguration.batchingEnabled,z(X,d)))(a)};return s||!n?e.jsx(I,{}):e.jsx(c,{bordered:!1,padded:!1,hoverable:!1,middleColumn:r.batchingConfiguration.batchingEnabled?7:4,legend:t(),children:e.jsx(c.Row,{children:o()})})},Ze=({deployment:r,model:s})=>{const{isLoading:n,project:t}=O(),{data:o,isLoading:a}=ne("kube_knative_domain_name");return n||a||!t?e.jsx(I,{}):e.jsxs(i,{flexDirection:"column",sx:{gap:"20px"},p:"20px",children:[e.jsxs(i,{sx:{gap:"20px"},children:[e.jsx(y,{copyButton:!0,title:"Get deployment",language:"python",content:er({projectName:t==null?void 0:t.projectName,deploymentName:r.name})}),e.jsx(y,{copyButton:!0,title:"Start or stop deployment",language:"python",content:rr({projectName:t==null?void 0:t.projectName,deploymentName:r.name})})]}),s?e.jsx(y,{copyButton:!0,title:"Make predictions with model input example",language:"python",content:sr({projectName:t==null?void 0:t.projectName,deploymentName:r.name})}):e.jsx(y,{copyButton:!0,title:`Send requests to your ${r.name} deployment`,language:"python",content:nr({projectName:t==null?void 0:t.projectName,deploymentName:r.name,domainName:o})})]})},er=r=>`import hopsworks

# connect with Hopsworks.
# NOTE: to connect from an external environment, see ${te("/user_guides/projects/api_key/create_api_key")} 
project = hopsworks.login()

# get Hopsworks Model Serving
ms = project.get_model_serving()

# get deployment object
deployment = ms.get_deployment("${r.deploymentName}")
`,rr=r=>`# print deployment info
deployment.describe()

# start or stop the deployment
deployment.start()  # .stop()

# check deployment status
state = deployment.get_state()
state.describe()
  `,sr=r=>`# get Hopsworks Model Registry
mr = project.get_model_registry()
  
# get model
model = mr.get_model(deployment.model_name, deployment.model_version)

# make predictions
predictions = deployment.predict({"instances": [model.input_example]})
print(predictions)
`,nr=r=>`import requests

# Get the Istio load balancer endpoint from deployment page in the Hopsworks UI.
istio_endpoint = "<ISTIO_ENDPOINT>" # with format "http://<ip-address>"
endpoint_uri = "<insert_URI>" # e.g., /activity
istio_url = istio_endpoint + endpoint_uri

host_header = "${`${r.deploymentName}.${r.projectName.replace(/_/g,"-")}.${r.domainName}`.toLowerCase()}"

# Set up headers with API key authentication
# Create an API KEY using the Hopsworks UI and place the value below
# To create an API Key, see ${te("/user_guides/projects/api_key/create_api_key")}
headers = {
    "Host": host_header,
    "Authorization": "ApiKey <API-KEY>",
    "Content-Type": "application/json"
}

# Prepare your request payload
data = {
    # your request data here
}

# Send the request
response = requests.post(istio_url, headers=headers, json=data)
print(response.json())
`,tr=({deployment:r})=>{const{project:s,isLoading:n}=O(),{data:t,isLoading:o}=ne("kube_knative_domain_name"),{currentData:a,isLoading:d}=Ge(),u=f.useMemo(()=>a==null?void 0:a.find(p=>p.type===Be.LOAD_BALANCER),[a]),b=f.useMemo(()=>r.servingTool===W.KSERVE?r.modelServer===k.VLLM?r.predictor?xe:ue:he:pe,[r]);return n||o||d||!s?e.jsx(I,{}):e.jsxs(i,{flexDirection:"column",p:20,sx:g.defaultGap,children:[e.jsxs(i,{flexDirection:"column",children:[e.jsx(_,{mb:"0px",bold:!0,gray:!0,children:"Hopsworks REST API"}),e.jsx("hr",{style:{borderBottom:"none",borderLeft:"none",borderRight:"none",borderTop:"1px solid lightgray",width:"100%"}})]}),b.map(({label:p,value:m})=>e.jsxs(i,{flexDirection:"column",children:[e.jsx(S,{mb:"3px",gray:!0,children:p}),e.jsx(l,{primary:!0,fontFamily:"IBM Plex Mono",sx:{userSelect:"all"},children:r.modelName?ee(r,p):ee(r,p).replace(":predict",":<insert_URI>")})]},m)),u&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{flexDirection:"column",mt:"10px",children:[e.jsx(_,{mb:"0px",bold:!0,gray:!0,children:"Istio Ingress"}),e.jsx("hr",{style:{borderBottom:"none",borderLeft:"none",borderRight:"none",borderTop:"1px solid lightgray",width:"100%"}})]}),b.map(({label:p,value:m})=>e.jsxs(i,{flexDirection:"column",children:[e.jsx(S,{mb:"3px",gray:!0,children:p}),e.jsx(l,{primary:!0,fontFamily:"IBM Plex Mono",sx:{userSelect:"all"},children:r.modelName?re(r,p,u):re(r,p,u).replace(":predict","<insert_URI>")})]},m)),e.jsxs(i,{flexDirection:"column",children:[e.jsx(S,{mb:"3px",gray:!0,children:"Host header"}),e.jsx(l,{fontFamily:"IBM Plex Mono",sx:{userSelect:"all"},children:Ke(s.projectName,r.name,t)})]},"HostHeader")]})]})},ir=r=>r.status===void 0?M.neutral:r.status?r.type===be.READY?M.valid:M.neutral:M.error,ar=({deployment:r})=>r.condition?e.jsx(i,{flexDirection:"column",children:e.jsx(q,{mb:"2px",content:r.condition.reason,type:ir(r.condition)})}):null,{DATE_TIME_FULL:or}=ae.DATE_TIME,cr=({deployment:r,onRefresh:s})=>{var R,x;const n=J(),t=Ue(),o=We(),d=(()=>{let h;switch(r.status){case E.RUNNING:case E.IDLE:h="green";break;case E.STOPPING:case E.STOPPED:h="black";break;case E.CREATING:case E.CREATED:case E.STARTING:h="white";break;default:h=void 0}return E.RUNNING===r.status?{text:r.status,variant:"green"}:{text:r.status,variant:h}})(),u=f.useCallback(()=>{n(A.project.settings.fileBrowserWithPath,{"*":`Deployments/${r.modelName}/${r.modelVersion}`})},[r,n]),b=f.useCallback(()=>{window.open(t(r.name),"_blank")},[t,r.name]),p=f.useCallback(()=>{window.open(o(r.name),"_blank")},[o,r.name]),[m,T]=r.creator.split(" "),C=()=>{n(A.project.deployments.edit,{dId:r.id})},w=()=>{var h;n(A.project.settings.pythonWithEnvironment,{version:(h=r.environmentDTO)==null?void 0:h.name})},v=h=>{var j;return h.modelServer===k.TENSORFLOW_SERVING?"tensorflow/serving":h.modelServer===k.PYTHON?"kserve/sklearnserver":h.modelServer===k.VLLM?"vllm/vllm-openai":(j=h.environmentDTO)==null?void 0:j.name};return e.jsxs(e.Fragment,{children:[e.jsx(qe,{type:Ee.deployment,data:r,title:r.name,onClickEdit:C,idColor:"labels.blueShade1",status:d,onClickRefresh:s}),e.jsxs(i,{mt:"10px",flexDirection:"column",sx:{gap:"20px"},children:[e.jsxs(i,{justifyContent:"space-between",children:[e.jsxs(i,{sx:{gap:"30px"},children:[e.jsx(U,{children:e.jsx(Ce,{firstName:m,lastName:T})}),e.jsx(lr,{ml:"-5px",label:"Created at",date:new Date(r.created)}),e.jsxs(i,{flexDirection:"column",sx:{gap:"4px"},children:[e.jsx(S,{gray:!0,children:"Model server"}),e.jsx(l,{color:"black",children:r.modelServer})]}),!!r.environmentDTO&&!!r.predictor&&e.jsxs(i,{flexDirection:"column",sx:{gap:"4px"},children:[e.jsx(S,{gray:!0,children:"Predictor environment"}),e.jsx(se,{onClick:w,children:`${(R=r.environmentDTO)==null?void 0:R.name} ->`})]}),!r.predictor&&e.jsxs(i,{flexDirection:"column",sx:{gap:"4px"},children:[e.jsx(S,{gray:!0,children:"Predictor environment"}),e.jsx(l,{color:"black",children:v(r)})]}),!!r.environmentDTO&&!!r.transformer&&e.jsxs(i,{flexDirection:"column",sx:{gap:"4px"},children:[e.jsx(S,{gray:!0,children:"Transformer environment"}),e.jsx(se,{onClick:w,children:`${(x=r.environmentDTO)==null?void 0:x.name} ->`})]}),r.deployed&&e.jsxs(i,{flexDirection:"column",sx:{gap:"4px"},children:[e.jsx(S,{gray:!0,children:"Deployed at"}),e.jsx(l,{color:"black",children:ie(new Date(r.deployed),or)})]})]}),e.jsxs(i,{sx:{gap:"20px"},children:[e.jsx(Je,{ml:"10px",mt:"6px",status:r.status}),e.jsx(me,{deployment:r})]})]}),r.description&&e.jsx(i,{children:e.jsx(_,{children:r.description})}),e.jsx(ar,{deployment:r}),e.jsxs(i,{justifyContent:"space-between",children:[e.jsxs(i,{sx:{gap:"8px"},children:[e.jsx($,{onClick:p,variant:"secondary",children:"See Metrics ↗"}),e.jsx($,{onClick:b,variant:"secondary",children:"See Logs ↗"})]}),r.artifactVersion!=null&&e.jsx($,{onClick:u,intent:"secondary",children:"Browse artifact files ->"})]})]})]})},lr=({label:r,date:s,primary:n,...t})=>{const{DATE_TIME_FULL:o}=ae.DATE_TIME;return e.jsxs(i,{flexDirection:"column",...t,children:[e.jsx(S,{mb:"3px",gray:!0,children:r}),e.jsx(l,{primary:n,children:ie(s,o)})]})},se=({shouldFallback:r,children:s,onClick:n})=>r?e.jsx(l,{color:"gray",children:"not provided"}):e.jsx(l,{primary:!0,sx:{...oe,textDecoration:"underline",cursor:"pointer",maxWidth:"300px"},onClick:n,children:s}),dr=({deployment:r})=>{const{project:s,isLoading:n}=O(),t="grafana/d-solo/kserve/deployment-metrics",o=[{name:"configuration",value:`${r.name}-.*`},{name:"revision",value:"All"},{name:"namespace",value:s==null?void 0:s.namespace}],a=[{title:"End to end Latencies",linkParams:{urlPath:t,variables:o,panelId:20}},{title:"Number of requests per second by Response Code Class",linkParams:{urlPath:t,variables:o,panelId:18}}];return n||!s?e.jsx(I,{}):r.status===E.CREATING||r.status===E.CREATED?e.jsx(i,{p:"20px",py:"40px",alignItems:"center",flexDirection:"column",sx:g.defaultGap,children:e.jsx(ce,{color:"grey",fontWeight:"100",children:"Metrics will be shown when the deployment is started"})}):e.jsx(Qe,{panels:a})},B=(r,s)=>{const n=r[s];return["Deployments",r.modelName||r.name,r.modelVersion||r.version,`${s.toLowerCase()}-${n}`].join("/")},ur=({model:r,deployment:s})=>{const{id:n}=le(),t=J(),o=()=>{t(A.project.models.overview,{mId:r==null?void 0:r.name})},a=()=>{t(A.project.models.versionView,{mId:r==null?void 0:r.name,vId:r==null?void 0:r.version})},d=ve(),u=()=>{const C=B(s,"predictor");d(Number(n),C,H.DATASET)},b=()=>{const C=B(s,"transformer");d(Number(n),C,H.DATASET)},p=()=>{const C=B(s,"configFile");d(Number(n),C,H.DATASET)},m=!!s.configFile||s.modelServer===k.VLLM,T=K(F(G(m),De("Server config file")),F(G(!s.modelName),G(["Entrypoint"])))(["Model","Version","Predictor script","Transformer script"]);return e.jsx(c,{bordered:!1,padded:!1,hoverable:!1,middleColumn:T.length-1,legend:T,children:e.jsxs(c.Row,{children:[r&&e.jsxs(e.Fragment,{children:[e.jsx(c.Cell,{children:e.jsx(V,{onClick:o,children:`${r.name} ->`})}),e.jsx(c.Cell,{children:e.jsx(V,{onClick:a,children:`${r.version} ->`})})]}),e.jsx(c.Cell,{children:e.jsx(V,{shouldFallback:!s.predictor,onClick:u,children:`${s.predictor} ↓`})}),r&&e.jsx(c.Cell,{children:e.jsx(V,{shouldFallback:!s.transformer,onClick:b,children:`${s.transformer} ↓`})}),m&&e.jsx(c.Cell,{children:e.jsx(V,{shouldFallback:!s.configFile,onClick:p,children:`${s.configFile} ↓`})})]})})},V=({shouldFallback:r,children:s,onClick:n})=>r?e.jsx(l,{color:"gray",children:"not provided"}):e.jsx(l,{primary:!0,sx:{...oe,textDecoration:"underline",cursor:"pointer",maxWidth:"300px"},onClick:n,children:s}),xr=({deployment:r})=>{const{isLoading:s,project:n}=O();return s||!n?e.jsx(I,{}):e.jsxs(e.Fragment,{children:[e.jsx(c,{bordered:!1,padded:!1,hoverable:!1,middleColumn:3,legend:["Predictor instances","CPUs","Memory (MB)","GPUs"],children:e.jsxs(c.Row,{children:[e.jsxs(c.Cell,{children:[e.jsx(l,{minWidth:"135px",children:`${r.availableInstances} running out of ${r.requestedInstances}`}),r.requestedInstances===0&&e.jsx(_,{mt:"4px",bold:!0,gray:!0,children:"scale-to-zero"})]}),e.jsx(c.Cell,{children:e.jsx(l,{children:`${r.predictorResources.requests.cores??"-"} -> ${r.predictorResources.limits.cores??"-"}`})}),e.jsx(c.Cell,{children:e.jsx(l,{children:`${r.predictorResources.requests.memory??"-"} -> ${r.predictorResources.limits.memory??"-"}`})}),e.jsx(c.Cell,{children:e.jsx(l,{children:`${r.predictorResources.requests.gpus??"-"} -> ${r.predictorResources.limits.gpus??"-"}`})})]})}),r.transformer&&e.jsxs(e.Fragment,{children:[e.jsx("hr",{style:{borderBottom:"none",borderLeft:"none",borderRight:"none",borderTop:"1px solid lightgray",width:"100%",marginTop:"10px",marginBottom:"10px"}}),e.jsx(c,{bordered:!1,padded:!1,hoverable:!1,middleColumn:3,legend:["Transformer instances","CPUs","Memory (MB)","GPUs"],children:e.jsxs(c.Row,{children:[e.jsxs(c.Cell,{children:[e.jsx(l,{minWidth:"135px",children:r.transformer&&r.requestedTransformerInstances!==void 0?`${r.availableTransformerInstances} running out of ${r.requestedTransformerInstances}`:"-"}),r.transformer&&r.requestedTransformerInstances===0&&e.jsx(_,{mt:"4px",bold:!0,gray:!0,children:"scale-to-zero"})]}),e.jsx(c.Cell,{children:e.jsx(l,{children:`${r.transformerResources.requests.cores??"-"} -> ${r.transformerResources.limits.cores??"-"}`})}),e.jsx(c.Cell,{children:e.jsx(l,{children:`${r.transformerResources.requests.memory??"-"} -> ${r.transformerResources.limits.memory??"-"}`})}),e.jsx(c.Cell,{children:e.jsx(l,{children:`${r.transformerResources.requests.gpus??"-"} -> ${r.transformerResources.limits.gpus??"-"}`})})]})})]})]})},hr=({deployment:r})=>{const s=de(),n=J(),{data:t,isLoading:o}=Ne({projectId:s,model:r.modelName,status:"Running"},{refetchOnMountOrArgChange:!0,skip:!r.modelName});if(!r.modelName)return null;if(o||!t)return e.jsx(I,{});const a=u=>()=>{n(A.project.deployments.overview,{dId:u})},d=t.all.filter(u=>u.id!==r.id);return o||d.length===0?null:e.jsxs(i,{flexDirection:"column",sx:{gap:"8px"},children:[e.jsx(ke,{sx:g.divider}),e.jsx(l,{color:"gray",children:"Deploying the same model"}),e.jsx(i,{width:"100%",children:d.map(u=>e.jsx($,{intent:"secondary",height:"31px",onClick:a(u.id),children:`${u.name} ->`},u.id))})]})},pr=({deployment:r,model:s})=>{const n=f.useMemo(()=>r.servingTool===W.KSERVE?r.modelServer===k.VLLM?r.predictor?xe:ue:he:pe,[r]),[t,o]=f.useState(n[0].value),[a,d]=f.useState({input:"",output:"",error:""}),u=f.useMemo(()=>{var h,j,P,Q,Y;if(((h=s==null?void 0:s.inputExample)==null?void 0:h.preview)===void 0||!((P=(j=s==null?void 0:s.inputExample)==null?void 0:j.preview)!=null&&P.content))return"";const x=JSON.parse((Y=(Q=s==null?void 0:s.inputExample)==null?void 0:Q.preview)==null?void 0:Y.content);return r.modelServer===k.TENSORFLOW_SERVING?JSON.stringify({signature_name:"serving_default",instances:x}):r.modelServer===k.VLLM?JSON.stringify(x):JSON.stringify({instances:x})},[r,s]);f.useEffect(()=>{d({input:u,output:"",error:""})},[u]);const b=f.useMemo(()=>r.modelServer===k.TENSORFLOW_SERVING?'{"signature_name": "serving_default", "instances": [[1.0, 2.0, 3.0]]}':r.modelServer===k.VLLM?`{"model": "${r.name}", "messages": [{"role": "user", "content": "Hi there!"}]}`:s?'{"instances": [[1.0, 2.0, 3.0]]}':'{"user_id": 1234}',[r.modelServer,r.name,s]),[p,{isLoading:m}]=He(),T=x=>{Array.isArray(x)||o(x)},C=x=>{m||d({...a,input:x})},w=x=>{let h="";try{h=Z(x.replaceAll(`
`,""))}catch(j){console.warn(j),h=x}d({...a,input:h})},v=(x,h)=>{let j="";if(x)try{j=Z(JSON.stringify(x))}catch(P){console.warn(P),j=(x==null?void 0:x.toString())||""}d(P=>({...P,output:j,error:h}))},R=async()=>{if(!a.input&&r.modelName)return;w(a.input);let x=null,h="";try{x=await p({host:"",deployment:r,verb:t,content:a.input}).unwrap()}catch(j){console.warn(j),h=(j==null?void 0:j.response.data.usrMsg)||"An error occurred"}v(x,h)};return r.status!==E.RUNNING&&r.status!==E.IDLE?e.jsxs(i,{p:"20px",py:"40px",alignItems:"center",flexDirection:"column",sx:g.defaultGap,children:[e.jsx(ce,{color:"grey",fontWeight:"100",children:"Deployment needs to be running to be tested"}),e.jsx(me,{title:"Run deployment",deployment:r})]}):e.jsxs(i,{flexDirection:"column",sx:g.defaultGap,p:"20px",children:[e.jsxs(i,{flexDirection:"row",alignItems:"end",gap:"20px",children:[s?e.jsx(Te,{label:"verb",labelPosition:"inline",placeholder:"pick a verb",value:t,isDisabled:m,options:n,onChange:T,width:"auto"}):e.jsx(Le,{label:"Path",labelPosition:"inline",placeholder:"path URI",value:t,onChange:x=>T(x.target.value),isDisabled:m}),e.jsx(Se,{type:"submit",intent:"primary",isLoading:m,onClick:R,children:"Run test"})]}),a.error&&e.jsxs(U,{children:[e.jsx(q,{content:a.error,type:M.error}),e.jsx(q,{mt:"2px",content:"For more details, please check the deployment logs",type:M.neutral})]}),e.jsxs(i,{flexDirection:"column",children:[e.jsxs(i,{alignItems:"center",mb:"6px",children:[e.jsx(_,{bold:!0,children:"Request data"}),e.jsx(Ie,{mainText:`For example: ${b}`,children:e.jsx(we,{ml:"5px",size:"xs",icon:_e.info_block})})]}),e.jsx(Re,{mode:"json",readOnly:!1,value:a.input,onChange:C,codeMirrorProps:{maxHeight:"300px"}})]}),a.output&&e.jsxs(U,{children:[e.jsx(_,{bold:!0,mb:"6px",children:"Response"}),e.jsx(y,{width:"100%",height:"auto !important",css:{maxHeight:"300px",minHeight:"50px"},language:"json",wrapLongLines:!0,copyButton:!0,downloadButton:!0,showLineNumbers:!0,title:"Content",content:a.output})]})]})},mr=({deployment:r})=>{const{schedulingConfig:s}=r;return e.jsx(Ye,{schedulingConfig:s})},jr=({deployment:r})=>{var w;const{id:s,project:n,isLoading:t}=O(),{data:o,isLoading:a}=Pe(),d=(w=n==null?void 0:n.projectTeam)==null?void 0:w.find(({user:v})=>v.username===(o==null?void 0:o.username)),u=(d==null?void 0:d.teamRole)===Me.DATA_OWNER,b=f.useMemo(()=>{var v;return((v=r.remoteAccessDTOs)==null?void 0:v.map(R=>R.remoteUserGroupName))||[]},[r]),{currentData:p=[]}=Ae(String(s)),[m,{isLoading:T}]=Oe(),C=f.useCallback(v=>m({projectId:s,deploymentId:r.id,remoteUserGroups:v}),[m,s,r]);return t||a||!n?e.jsx(I,{}):e.jsx(ze,{isDisabled:!u||t||a,onSave:C,value:b,options:p,isSaving:T,itemName:"external user groups",isCaseSensitive:!0})},Ar=()=>{const{dId:r}=le(),s=de(),{currentData:n,refetch:t}=Ve({projectId:s,id:+r},{pollingInterval:5e3,refetchOnFocus:!0}),o=n&&(!n.modelName||!(n!=null&&n.modelVersion)),{currentData:a,refetch:d}=Fe({projectId:s,modelName:(n==null?void 0:n.modelName)??"",modelVersion:(n==null?void 0:n.modelVersion)??0},{skip:!n||o}),u=f.useCallback(()=>{t(),d()},[t,d]);return!o&&!a||!n?e.jsx(I,{}):e.jsx(gr,{deployment:n,model:a,onRefresh:u})},gr=({deployment:r,onRefresh:s,model:n})=>{var t,o;return e.jsxs(i,{flexDirection:"column",pb:"20px",sx:g.defaultGap,children:[e.jsx(cr,{deployment:r,onRefresh:s}),e.jsx(hr,{deployment:r}),e.jsxs(ye,{children:[e.jsx(D,{name:"models",children:e.jsx(N,{children:e.jsx(i,{sx:g.overflowX,children:e.jsx(L,{title:"Artifact files",maxHeight:"400px",width:"100%",children:e.jsx(ur,{deployment:r,model:n})})})})}),r.servingTool===W.KSERVE&&e.jsx(D,{name:"metrics",children:e.jsx(N,{children:e.jsx(L,{title:"Metrics",contentProps:g.card,children:e.jsx(dr,{deployment:r})})})}),e.jsx(D,{name:"test-deployment",children:e.jsx(N,{children:e.jsx(L,{title:"Test deployment",contentProps:g.card,children:e.jsx(pr,{deployment:r,model:n})})})}),e.jsx(D,{name:"endpoints",children:e.jsx(N,{children:e.jsx(L,{title:"Endpoints",contentProps:g.card,children:e.jsx(tr,{deployment:r})})})}),n&&e.jsx(D,{name:"schema",children:e.jsx(N,{children:e.jsx(L,{title:"Deployment schema",contentProps:g.card,children:e.jsx($e,{schema:(o=(t=n==null?void 0:n.modelSchema)==null?void 0:t.preview)==null?void 0:o.content})})})}),e.jsx(D,{name:"snippets",children:e.jsx(N,{children:e.jsx(L,{title:"Code snippets",contentProps:g.card,children:e.jsx(Ze,{deployment:r,model:n})})})}),e.jsx(D,{name:"configuration",children:e.jsx(N,{children:e.jsx(i,{sx:g.overflowX,children:e.jsx(L,{title:"Configuration",width:"100%",children:e.jsx(Xe,{deployment:r})})})})}),e.jsx(D,{name:"resource-allocation",children:e.jsx(N,{children:e.jsx(i,{sx:g.overflowX,children:e.jsx(L,{title:"Resource allocation",width:"100%",children:e.jsx(xr,{deployment:r})})})})}),e.jsx(D,{name:"kube-schedule-config",children:e.jsx(N,{children:e.jsx(i,{sx:g.overflowX,children:e.jsx(mr,{deployment:r})})})}),e.jsx(D,{name:"external-access",children:e.jsx(N,{children:e.jsx(i,{sx:g.overflowX,children:e.jsx(L,{title:"External access",width:"100%",children:e.jsx(jr,{deployment:r})})})})})]})]})};export{Ar as Overview,Ar as default};
