Skip to content

Commit 33ad8dc

Browse files
authored
Create, edit, and delete MaaSModelRefs from the Wizard (opendatahub-io#6936)
* Create and Delete MaaSModelRefs * fixes * PR comments * adding dry runs * lint * pr comments 2 * Moving pre/post deploy into deploy method * rebase and test fixes
1 parent 6699327 commit 33ad8dc

File tree

25 files changed

+1130
-35
lines changed

25 files changed

+1130
-35
lines changed

frontend/src/__mocks__/mockLLMInferenceServiceK8sResource.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ type MockLLMInferenceServiceConfigType = {
2121
modelType?: ServingRuntimeModelType;
2222
isStopped?: boolean;
2323
baseRefs?: { name?: string }[];
24+
description?: string;
25+
isMaaS?: boolean;
26+
secretName?: string;
2427
};
2528

2629
export const mockLLMInferenceServiceK8sResource = ({
@@ -38,6 +41,9 @@ export const mockLLMInferenceServiceK8sResource = ({
3841
addresses,
3942
isStopped = false,
4043
baseRefs,
44+
description,
45+
isMaaS = false,
46+
secretName,
4147
}: MockLLMInferenceServiceConfigType): LLMInferenceServiceKind => ({
4248
apiVersion: 'serving.kserve.io/v1alpha1',
4349
kind: 'LLMInferenceService',
@@ -48,6 +54,8 @@ export const mockLLMInferenceServiceK8sResource = ({
4854
'opendatahub.io/hardware-profile-namespace': 'opendatahub',
4955
'opendatahub.io/model-type': ServingRuntimeModelType.GENERATIVE,
5056
...(isStopped ? { [ModelAnnotation.STOPPED_ANNOTATION]: 'true' } : {}),
57+
...(description && { 'openshift.io/description': description }),
58+
...(secretName && { 'opendatahub.io/connections': secretName }),
5159
},
5260
creationTimestamp,
5361
...(deleted ? { deletionTimestamp: new Date().toUTCString() } : {}),
@@ -68,7 +76,11 @@ export const mockLLMInferenceServiceK8sResource = ({
6876
},
6977
replicas,
7078
router: {
71-
gateway: {},
79+
gateway: {
80+
...(isMaaS
81+
? { refs: [{ name: 'maas-default-gateway', namespace: 'openshift-ingress' }] }
82+
: {}),
83+
},
7284
route: {},
7385
scheduler: {},
7486
},
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import type { MaaSModelRef } from '@odh-dashboard/maas/types/maas-model';
2+
3+
export const mockMaaSModelRef = ({
4+
name = 'test-maas-model-ref',
5+
namespace = 'test-project',
6+
modelRef = {
7+
name: 'test-llm-inference-service',
8+
kind: 'LLMInferenceService',
9+
},
10+
displayName = 'Test LLM Inference Service',
11+
description = 'Test LLM Inference Service Description',
12+
}: Partial<MaaSModelRef> = {}): MaaSModelRef => ({
13+
name,
14+
namespace,
15+
modelRef,
16+
displayName,
17+
description,
18+
});

frontend/src/api/models/kserve.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,10 @@ export const LLMInferenceServiceConfigModel: K8sModelCommon = {
2727
kind: 'LLMInferenceServiceConfig',
2828
plural: 'llminferenceserviceconfigs',
2929
};
30+
31+
export const MaaSModelRefResourceModel: K8sModelCommon = {
32+
apiVersion: 'v1alpha1',
33+
apiGroup: 'maas.opendatahub.io',
34+
kind: 'MaaSModelRef',
35+
plural: 'maasmodelrefs',
36+
};

packages/cypress/cypress/support/commands/odh.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import type {
102102
SubscriptionInfoResponse,
103103
UserSubscription,
104104
} from '@odh-dashboard/maas/types/subscriptions';
105+
import type { MaaSModelRef } from '@odh-dashboard/maas/types/maas-model';
105106

106107
type SuccessErrorResponse = {
107108
success: boolean;
@@ -1164,6 +1165,20 @@ declare global {
11641165
((
11651166
type: 'GET /maas/api/v1/subscriptions',
11661167
response: { data: UserSubscription[] },
1168+
) => Cypress.Chainable<null>) &
1169+
((
1170+
type: 'POST /maas/api/v1/maasmodel',
1171+
response: OdhResponse<MaaSModelRef>,
1172+
) => Cypress.Chainable<null>) &
1173+
((
1174+
type: 'DELETE /maas/api/v1/maasmodel/:namespace/:name',
1175+
options: { path: { namespace: string; name: string } },
1176+
response: OdhResponse<{ message: string }>,
1177+
) => Cypress.Chainable<null>) &
1178+
((
1179+
type: 'PUT /maas/api/v1/maasmodel/:namespace/:name',
1180+
options: { path: { namespace: string; name: string } },
1181+
response: OdhResponse<MaaSModelRef>,
11671182
) => Cypress.Chainable<null>);
11681183
}
11691184
}

packages/cypress/cypress/tests/mocked/modelServing/modelServingLlmd.cy.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ const initIntercepts = ({
143143
body: mockLLMInferenceServiceK8sResource({ name: 'test-llmd-model' }),
144144
},
145145
).as('createLLMInferenceService');
146+
// MaaS is enabled so we need to intercept this for edit scenarios
147+
cy.interceptOdh(
148+
'DELETE /maas/api/v1/maasmodel/:namespace/:name',
149+
{ path: { namespace: '*', name: '*' } },
150+
{ message: 'Deleted successfully' },
151+
).as('deleteMaaSModelRef');
146152
};
147153

148154
describe('Model Serving LLMD', () => {
@@ -774,6 +780,12 @@ describe('Model Serving LLMD', () => {
774780
cy.intercept('PUT', '**/llminferenceserviceconfigs/test-vllm-gpu*', (req) => {
775781
req.reply({ statusCode: 200, body: req.body });
776782
}).as('updateLLMInferenceServiceConfig');
783+
// MaaS is enabled so we need to intercept this for edit scenarios
784+
cy.interceptOdh(
785+
'DELETE /maas/api/v1/maasmodel/:namespace/:name',
786+
{ path: { namespace: '*', name: '*' } },
787+
{ message: 'Deleted successfully' },
788+
).as('deleteMaaSModelRef');
777789
};
778790

779791
it('should display serving runtime name and version, then pre-fill when editing', () => {

0 commit comments

Comments
 (0)