Skip to content

Deploy a Model from a PVC #4449

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions frontend/src/__mocks__/mockPVCK8sResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type MockResourceConfigType = {
uid?: string;
status?: PersistentVolumeClaimKind['status'];
accessModes?: AccessMode[];
annotations?: Record<string, string>;
labels?: Record<string, string>;
};

export const mockPVCK8sResource = ({
Expand All @@ -28,18 +30,22 @@ export const mockPVCK8sResource = ({
},
},
accessModes = [AccessMode.RWO],
annotations = {},
labels = {},
}: MockResourceConfigType): PersistentVolumeClaimKind => ({
kind: 'PersistentVolumeClaim',
apiVersion: 'v1',
metadata: {
annotations: {
'openshift.io/description': '',
'openshift.io/display-name': displayName,
...annotations,
},
name,
namespace,
labels: {
[KnownLabels.DASHBOARD_RESOURCE]: 'true',
...labels,
},
uid,
},
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/__tests__/cypress/cypress/pages/modelServing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ class InferenceServiceModal extends ServingModal {
});
}

findPVCSelect() {
return this.find().findByTestId('pvc-connection-selector');
}

findHardProfileSelection(): Cypress.Chainable<JQuery<HTMLElement>> {
return cy.findByTestId('hardware-profile-select');
}
Expand Down Expand Up @@ -552,6 +556,10 @@ class KServeModal extends InferenceServiceModal {
findMemoryLimitButton(type: 'Plus' | 'Minus') {
return this.find().findByTestId('memory-limit-input').findByRole('button', { name: type });
}

findPVCConnectionOption() {
return this.find().findByTestId('pvc-serving-radio');
}
}
mixin(KServeModal, [ServingRuntimeModal, InferenceServiceModal]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ type HandlersProps = {
DscComponents?: DataScienceClusterKindStatus['components'];
disableProjectScoped?: boolean;
disableHardwareProfiles?: boolean;
disablePVCServing?: boolean;
};
import { STOP_MODAL_PREFERENCE_KEY } from '#~/pages/modelServing/useStopModalPreference';

Expand All @@ -110,6 +111,7 @@ const initIntercepts = ({
projectEnableModelMesh,
disableProjectScoped = true,
disableHardwareProfiles = true,
disablePVCServing = true,
servingRuntimes = [
mockServingRuntimeK8sResourceLegacy({ tolerations: [], nodeSelector: {} }),
mockServingRuntimeK8sResource({
Expand Down Expand Up @@ -169,6 +171,7 @@ const initIntercepts = ({
disableKServeRaw,
disableProjectScoped,
disableHardwareProfiles,
disablePVCServing,
}),
);
cy.interceptK8sList(PodModel, mockK8sResourceList([mockPodK8sResource({})]));
Expand Down Expand Up @@ -2356,6 +2359,122 @@ describe('Serving Runtime List', () => {
});
});
});

it('Deploy model with PVC', () => {
initIntercepts({
disableModelMeshConfig: false,
disableKServeConfig: false,
disableServingRuntimeParams: false,
disablePVCServing: false,
requiredCapabilities: [StackCapability.SERVICE_MESH, StackCapability.SERVICE_MESH_AUTHZ],
projectEnableModelMesh: false,
});
cy.intercept(
'GET',
'**/namespaces/test-project/persistentvolumeclaims?labelSelector=opendatahub.io%2Fdashboard%3Dtrue',
mockK8sResourceList([
mockPVCK8sResource({
name: 'test-pvc',
namespace: 'test-project',
displayName: 'Test PVC',
storageClassName: 'openshift-default-sc',
annotations: {
'dashboard.opendatahub.io/model-name': 'test-model',
'dashboard.opendatahub.io/model-path': 'test-path',
},
labels: {
'opendatahub.io/dashboard': 'true',
},
}),
]),
);

projectDetails.visitSection('test-project', 'model-server');
modelServingSection.findDeployModelButton().click();

kserveModal.shouldBeOpen();

kserveModal.findModelNameInput().type('Test Name');
kserveModal.findServingRuntimeTemplateSearchSelector().click();
kserveModal.findGlobalScopedTemplateOption('Caikit').click();
kserveModal.findModelFrameworkSelect().findSelectOption('onnx - 1').click();
// Auto-selects the only pvc
kserveModal.findPVCConnectionOption().should('be.visible').click();
kserveModal.findLocationPathInput().should('have.value', 'test-path');
kserveModal.findSubmitButton().should('be.enabled');
kserveModal.findSubmitButton().click();
kserveModal.shouldBeOpen(false);

// dry run request
cy.wait('@createServingRuntime').then((interception) => {
expect(interception.request.url).to.include('?dryRun=All');
expect(interception.request.body).to.containSubset({
metadata: {
name: 'test-name',
annotations: {
'openshift.io/display-name': 'test-name',
'opendatahub.io/apiProtocol': 'REST',
'opendatahub.io/template-display-name': 'Caikit',
'opendatahub.io/template-name': 'template-2',
},
namespace: 'test-project',
},
spec: {
protocolVersions: ['grpc-v1'],
supportedModelFormats: [
{ autoSelect: true, name: 'openvino_ir', version: 'opset1' },
{ autoSelect: true, name: 'onnx', version: '1' },
],
},
});
});
// Actual request
cy.wait('@createServingRuntime').then((interception) => {
expect(interception.request.url).not.to.include('?dryRun=All');
});

// the serving runtime should have been created
cy.get('@createServingRuntime.all').then((interceptions) => {
expect(interceptions).to.have.length(2); // 1 dry-run request and 1 actual request
});
cy.wait('@createInferenceService').then((interception) => {
expect(interception.request.url).to.include('?dryRun=All');
expect(interception.request.body).to.containSubset({
apiVersion: 'serving.kserve.io/v1beta1',
kind: 'InferenceService',
metadata: {
annotations: {
'openshift.io/display-name': 'Test Name',
'serving.knative.openshift.io/enablePassthrough': 'true',
'serving.kserve.io/deploymentMode': DeploymentMode.Serverless,
'sidecar.istio.io/inject': 'true',
'sidecar.istio.io/rewriteAppHTTPProbers': 'true',
},
labels: {
'opendatahub.io/dashboard': 'true',
'networking.knative.dev/visibility': 'cluster-local',
},
name: 'test-name',
namespace: 'test-project',
},
spec: {
predictor: {
minReplicas: 1,
maxReplicas: 1,
model: {
modelFormat: { name: 'onnx', version: '1' },
resources: {
requests: { cpu: '1', memory: '4Gi' },
limits: { cpu: '2', memory: '8Gi' },
},
runtime: 'test-name',
storageUri: 'pvc://test-pvc/test-path',
},
},
},
});
});
});
});

describe('ModelMesh model server', () => {
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/pages/modelServing/__tests__/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import {
isOciModelUri,
getInferenceServiceStoppedStatus,
getServingRuntimeVersionStatus,
getModelServingPVCAnnotations,
} from '#~/pages/modelServing/utils';
import { mockServingRuntimeK8sResource } from '#~/__mocks__/mockServingRuntimeK8sResource';
import { mockPVCK8sResource } from '#~/__mocks__/mockPVCK8sResource';
import { ContainerResources } from '#~/types';
import { mockServiceAccountK8sResource } from '#~/__mocks__/mockServiceAccountK8sResource';
import { mockRoleBindingK8sResource } from '#~/__mocks__/mockRoleBindingK8sResource';
Expand Down Expand Up @@ -353,3 +355,26 @@ describe('getServingRuntimeVersionStatus', () => {
);
});
});

describe('getModelServingPVCAnnotations', () => {
it('should return the right annotations', () => {
const pvc = mockPVCK8sResource({
annotations: {
'dashboard.opendatahub.io/model-name': 'test-model',
'dashboard.opendatahub.io/model-path': 'test-path',
},
});
expect(getModelServingPVCAnnotations(pvc)).toEqual({
modelName: 'test-model',
modelPath: 'test-path',
});
});

it('should return null if annotations are not present', () => {
const pvc = mockPVCK8sResource({});
expect(getModelServingPVCAnnotations(pvc)).toEqual({
modelName: null,
modelPath: null,
});
});
});
Loading