From d1ee01b181c4ff360eefaacbb88d60599161d2c8 Mon Sep 17 00:00:00 2001 From: Manaswini Das Date: Fri, 1 Nov 2024 01:52:51 +0530 Subject: [PATCH] Submit additional configuration parameters (#3405) * Submit additional configuration parameters * remove hardcoded debug string * Fix tests Signed-off-by: Mike Turley * Fix tests in projects/modelServingNim.cy.ts --------- Signed-off-by: Mike Turley Co-authored-by: Mike Turley --- .../mockInferenceServiceK8sResource.ts | 2 + .../modelServing/modelServingGlobal.cy.ts | 8 +- frontend/src/api/k8s/inferenceServices.ts | 6 ++ frontend/src/k8sTypes.ts | 2 + .../EnvironmentVariablesSection.tsx | 41 ++++++---- .../kServeModal/ServingRuntimeArgsSection.tsx | 75 +++++++++---------- .../modelServing/screens/projects/utils.ts | 10 +++ .../src/pages/modelServing/screens/types.ts | 4 +- 8 files changed, 91 insertions(+), 57 deletions(-) diff --git a/frontend/src/__mocks__/mockInferenceServiceK8sResource.ts b/frontend/src/__mocks__/mockInferenceServiceK8sResource.ts index fd91008a1a..3ee4d513d4 100644 --- a/frontend/src/__mocks__/mockInferenceServiceK8sResource.ts +++ b/frontend/src/__mocks__/mockInferenceServiceK8sResource.ts @@ -137,6 +137,8 @@ export const mockInferenceServiceK8sResource = ({ key: secretName, path, }, + args: [''], + env: [], }, }, }, diff --git a/frontend/src/__tests__/cypress/cypress/tests/mocked/modelServing/modelServingGlobal.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/mocked/modelServing/modelServingGlobal.cy.ts index bf1308f081..56e6b606f1 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/mocked/modelServing/modelServingGlobal.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/mocked/modelServing/modelServingGlobal.cy.ts @@ -408,10 +408,12 @@ describe('Model Serving Global', () => { modelFormat: { name: 'onnx', version: '1' }, runtime: 'test-model', storage: { key: 'test-secret', path: 'test-model/' }, + args: [''], + env: [], }, }, }, - }); + } satisfies InferenceServiceKind); }); // Actaul request @@ -471,10 +473,12 @@ describe('Model Serving Global', () => { modelFormat: { name: 'onnx', version: '1' }, runtime: 'test-model', storage: { key: 'test-secret', path: 'test-model/test-model/' }, + args: [''], + env: [], }, }, }, - }); + } satisfies InferenceServiceKind); }); cy.findByText('Error creating model server'); diff --git a/frontend/src/api/k8s/inferenceServices.ts b/frontend/src/api/k8s/inferenceServices.ts index 327dfea239..405d57fc1c 100644 --- a/frontend/src/api/k8s/inferenceServices.ts +++ b/frontend/src/api/k8s/inferenceServices.ts @@ -38,6 +38,8 @@ export const assembleInferenceService = ( minReplicas, tokenAuth, externalRoute, + servingRuntimeArgs, + servingRuntimeEnvVars, } = data; const name = editName || translateDisplayNameForK8s(data.name); const { path, dataConnection } = storage; @@ -79,6 +81,8 @@ export const assembleInferenceService = ( key: dataConnectionKey, path, }, + args: servingRuntimeArgs, + env: servingRuntimeEnvVars, }, }, }, @@ -121,6 +125,8 @@ export const assembleInferenceService = ( key: dataConnectionKey, path, }, + args: servingRuntimeArgs, + env: servingRuntimeEnvVars, }, }, }, diff --git a/frontend/src/k8sTypes.ts b/frontend/src/k8sTypes.ts index 55e6cd5457..b50b48058e 100644 --- a/frontend/src/k8sTypes.ts +++ b/frontend/src/k8sTypes.ts @@ -492,6 +492,8 @@ export type InferenceServiceKind = K8sResourceCommon & { path?: string; schemaPath?: string; }; + args?: ServingContainer['args']; + env?: ServingContainer['env']; }; maxReplicas?: number; minReplicas?: number; diff --git a/frontend/src/pages/modelServing/screens/projects/kServeModal/EnvironmentVariablesSection.tsx b/frontend/src/pages/modelServing/screens/projects/kServeModal/EnvironmentVariablesSection.tsx index ba6e5db830..4973517da4 100644 --- a/frontend/src/pages/modelServing/screens/projects/kServeModal/EnvironmentVariablesSection.tsx +++ b/frontend/src/pages/modelServing/screens/projects/kServeModal/EnvironmentVariablesSection.tsx @@ -16,31 +16,44 @@ import { } from '@patternfly/react-icons'; import { UpdateObjectAtPropAndValue } from '~/pages/projects/types'; import { CreatingInferenceServiceObject } from '~/pages/modelServing/screens/types'; +import { ServingContainer } from '~/k8sTypes'; type EnvironmentVariablesSectionType = { - data?: CreatingInferenceServiceObject; + data: CreatingInferenceServiceObject; setData: UpdateObjectAtPropAndValue; }; -const EnvironmentVariablesSection: React.FC = () => { - const [additionalEnvVars, setAdditionalEnvVars] = React.useState< - Array<{ name: string; value: string }> - >([]); +const EnvironmentVariablesSection: React.FC = ({ + data, + setData, +}) => { + const [additionalEnvVars, setAdditionalEnvVars] = React.useState( + data.servingRuntimeEnvVars, + ); const addEnvVar = () => { - setAdditionalEnvVars((prevVars) => [...prevVars, { name: '', value: '' }]); + if (additionalEnvVars) { + const newVars = [...additionalEnvVars, { name: '', value: '' }]; + setAdditionalEnvVars(newVars); + setData('servingRuntimeEnvVars', newVars); + } }; const removeEnvVar = (indexToRemove: number) => { - setAdditionalEnvVars((prevVars) => prevVars.filter((_, i) => i !== indexToRemove)); + if (additionalEnvVars) { + const newVars = additionalEnvVars.filter((_, i) => i !== indexToRemove); + setAdditionalEnvVars(newVars); + setData('servingRuntimeEnvVars', newVars); + } }; const updateEnvVar = (indexToUpdate: number, updates: { name?: string; value?: string }) => { - setAdditionalEnvVars((prevVars) => { - const newVars = [...prevVars]; - newVars[indexToUpdate] = { ...prevVars[indexToUpdate], ...updates }; - return newVars; - }); + if (additionalEnvVars) { + const newVars = [...additionalEnvVars]; + newVars[indexToUpdate] = { ...additionalEnvVars[indexToUpdate], ...updates }; + setAdditionalEnvVars(newVars); + setData('servingRuntimeEnvVars', newVars); + } }; return ( @@ -60,10 +73,10 @@ const EnvironmentVariablesSection: React.FC = ( } - fieldId="model-server-replicas" + fieldId="environment-variables" > - {additionalEnvVars.map((envVar, index) => ( + {additionalEnvVars?.map((envVar, index) => ( ; }; -const ServingRuntimeArgsSection: React.FC = () => { - const [args, setArgs] = React.useState(''); - - return ( - - Serving runtime arguments define how the deployed model behaves. Overwriting - predefined arguments only affects this model deployment. - - } - > - - - - - } - fieldId="model-server-replicas" - > -