Skip to content

Commit 9feb01a

Browse files
authored
Update OCI Model URI onChange to not to reset the connection type (opendatahub-io#3919)
1 parent d618e4c commit 9feb01a

File tree

13 files changed

+1059
-183
lines changed

13 files changed

+1059
-183
lines changed

frontend/src/__tests__/cypress/cypress/pages/modelRegistry/modelVersionDeployModal.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class ModelVersionDeployModal extends Modal {
1010
}
1111

1212
selectProjectByName(name: string) {
13-
this.findProjectSelector().findSelectOption(name).click();
13+
this.findProjectSelector().click();
14+
cy.findByRole('option', { name, hidden: true }).click();
1415
}
1516
}
1617

frontend/src/__tests__/cypress/cypress/pages/modelServing.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class InferenceServiceModal extends Modal {
101101
super(`${edit ? 'Edit' : 'Deploy'} model`);
102102
}
103103

104+
findConnectionType(name: string | RegExp) {
105+
return this.findExistingConnectionSelect()
106+
.findByRole('button', { name: 'Typeahead menu toggle' })
107+
.findSelectOption(name);
108+
}
109+
104110
findSubmitButton() {
105111
return this.findFooter().findByTestId('modal-submit-button');
106112
}
@@ -191,10 +197,9 @@ class InferenceServiceModal extends Modal {
191197
return this.find().findByTestId('model-uri');
192198
}
193199

194-
findConnectionType(name: string | RegExp) {
195-
return this.findExistingConnectionSelect()
196-
.findByRole('button', { name: 'Typeahead menu toggle' })
197-
.findSelectOption(name);
200+
selectConnectionType(name: string) {
201+
this.findExistingConnectionSelect().click();
202+
cy.findByRole('option', { name, hidden: true }).click();
198203
}
199204

200205
selectExistingConnectionSelectOptionByResourceName() {
@@ -233,6 +238,10 @@ class InferenceServiceModal extends Modal {
233238
return this.find().findByTestId('field AWS_S3_BUCKET');
234239
}
235240

241+
findBaseURL() {
242+
return this.find().findByTestId('field OCI_HOST');
243+
}
244+
236245
findLocationRegionInput() {
237246
return this.find().findByTestId('field AWS_DEFAULT_REGION');
238247
}

frontend/src/__tests__/cypress/cypress/tests/mocked/modelRegistry/modelVersion/modelVersionDeploy.cy.ts

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,17 +499,25 @@ describe('Deploy model version', () => {
499499
kserveModal.findLocationAccessKeyInput().type('test-access-key');
500500
kserveModal.findLocationSecretKeyInput().type('test-secret-key');
501501

502-
kserveModal
503-
.findConnectionType('URI - v1 Connection type description Category: existing-category')
504-
.click();
502+
kserveModal.selectConnectionType(
503+
'URI - v1 Connection type description Category: existing-category',
504+
);
505+
505506
kserveModal.findConnectionFieldInput('URI').type('http://test-uri');
506507

508+
// switch the connection type to OCI and fill data
509+
kserveModal.selectConnectionType(
510+
'OCI compliant registry - v1 Connection type description Category: Database, Testing',
511+
);
512+
513+
kserveModal.findBaseURL().type('oci://test');
514+
kserveModal.findModelURITextBox().type('test.io/test/private:test');
515+
507516
// switch the connection type to s3 to check whether all the data is still persistent
508-
kserveModal
509-
.findConnectionType(
510-
'S3 compatible object storage - v1 description 2 Category: existing-category',
511-
)
512-
.click();
517+
kserveModal.selectConnectionType(
518+
'S3 compatible object storage - v1 description 2 Category: existing-category',
519+
);
520+
513521
kserveModal.findLocationBucketInput().should('have.value', 'test-bucket');
514522
kserveModal.findLocationEndpointInput().should('have.value', 'test-endpoint');
515523
kserveModal.findLocationRegionInput().should('have.value', 'test-region');
@@ -518,10 +526,18 @@ describe('Deploy model version', () => {
518526
kserveModal.findLocationSecretKeyInput().should('have.value', 'test-secret-key');
519527

520528
//switch it back to uri
521-
kserveModal
522-
.findConnectionType('URI - v1 Connection type description Category: existing-category')
523-
.click();
529+
kserveModal.selectConnectionType(
530+
'URI - v1 Connection type description Category: existing-category',
531+
);
532+
524533
kserveModal.findConnectionFieldInput('URI').should('have.value', 'http://test-uri');
534+
// oci-connection
535+
kserveModal.selectConnectionType(
536+
'OCI compliant registry - v1 Connection type description Category: Database, Testing',
537+
);
538+
539+
kserveModal.findModelURITextBox().should('have.value', 'test.io/test/private:test');
540+
kserveModal.findBaseURL().should('have.value', 'oci://test');
525541
});
526542

527543
it('Prefills when there is one s3 matching connection', () => {

frontend/src/concepts/modelRegistry/apiHooks/__tests__/usePrefillDeployModalFromModelRegistry.spec.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

frontend/src/concepts/modelRegistry/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import { LabeledConnection } from '~/pages/modelServing/screens/types';
2+
import {
3+
ConnectionTypeConfigMapObj,
4+
ConnectionTypeValueType,
5+
} from '~/concepts/connectionTypes/types';
16
import { ModelVersion, ModelState, RegisteredModel } from './types';
27

38
export type ObjectStorageFields = {
@@ -13,6 +18,14 @@ export type RegisteredModelLocation = {
1318
ociUri: string | null;
1419
} | null;
1520

21+
export type PrefilledConnection = {
22+
initialNewConnectionType: ConnectionTypeConfigMapObj | undefined;
23+
initialNewConnectionValues: { [key: string]: ConnectionTypeValueType };
24+
connections: LabeledConnection[];
25+
connectionsLoaded: boolean;
26+
connectionsLoadError: Error | undefined;
27+
};
28+
1629
export const objectStorageFieldsToUri = (fields: ObjectStorageFields): string | null => {
1730
const { endpoint, bucket, region, path } = fields;
1831
if (!endpoint || !bucket || !path) {

0 commit comments

Comments
 (0)