-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring model registry folder structure
- Loading branch information
Showing
33 changed files
with
324 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { ModelArtifact } from '~/concepts/modelRegistry/types'; | ||
|
||
export const mockModelArtifact = (): ModelArtifact => ({ | ||
createTimeSinceEpoch: '1712234877179', | ||
id: '1', | ||
lastUpdateTimeSinceEpoch: '1712234877179', | ||
name: 'fraud detection model version 1', | ||
description: 'Description of model version', | ||
artifactType: 'model-artifact', | ||
customProperties: {}, | ||
storagePath: 'test path', | ||
uri: 'https://huggingface.io/mnist.onnx', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* eslint-disable camelcase */ | ||
import { ModelArtifactList } from '~/concepts/modelRegistry/types'; | ||
import { mockModelArtifact } from './mockModelArtifact'; | ||
|
||
export const mockModelArtifactList = (): ModelArtifactList => ({ | ||
items: [mockModelArtifact()], | ||
nextPageToken: '', | ||
pageSize: 0, | ||
size: 1, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,68 @@ | ||
/* eslint-disable camelcase */ | ||
import { ModelVersion, ModelVersionState } from '~/concepts/modelRegistry/types'; | ||
|
||
type MockModelVersionType = { | ||
name?: string; | ||
author?: string; | ||
registeredModelId?: string; | ||
id?: string; | ||
}; | ||
|
||
export const mockModelVersion = ({ | ||
name = 'Version 1', | ||
author = 'Test author', | ||
registeredModelId = '1', | ||
id = '1', | ||
}: MockModelVersionType): ModelVersion => ({ | ||
author, | ||
createTimeSinceEpoch: '1712234877179', | ||
customProperties: {}, | ||
id: '26', | ||
customProperties: { | ||
'Testing label': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
Financial: { | ||
metadataType: 'MetadataStringValue', | ||
string_value: 'non-empty', | ||
}, | ||
'Financial data': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Fraud detection': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Long label data to be truncated abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc': | ||
{ | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Machine learning': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Next data to be overflow': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Label x': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Label y': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
'Label z': { | ||
metadataType: 'MetadataStringValue', | ||
string_value: '', | ||
}, | ||
}, | ||
id, | ||
lastUpdateTimeSinceEpoch: '1712234877179', | ||
name: 'fraud detection model version 1', | ||
name, | ||
state: ModelVersionState.ARCHIVED, | ||
registeredModelId, | ||
description: 'Description of model version', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
frontend/src/__tests__/cypress/cypress/e2e/modelRegistry/ModelVersionDetails.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { | ||
mockDashboardConfig, | ||
mockK8sResourceList, | ||
mockRouteK8sResourceModelRegistry, | ||
} from '~/__mocks__'; | ||
import { mockComponents } from '~/__mocks__/mockComponents'; | ||
import { mockModelRegistry } from '~/__mocks__/mockModelRegistry'; | ||
import { ModelRegistryModel, RouteModel } from '~/__tests__/cypress/cypress/utils/models'; | ||
import { MODEL_REGISTRY_API_VERSION } from '~/concepts/modelRegistry/const'; | ||
import { modelVersionDetails } from '~/__tests__/cypress/cypress/pages/modelRegistry/modelVersionDetails'; | ||
import { mockRegisteredModel } from '~/__mocks__/mockRegisteredModel'; | ||
import { mockModelVersion } from '~/__mocks__/mockModelVersion'; | ||
import { mockModelVersionList } from '~/__mocks__/mockModelVersionList'; | ||
import { mockModelArtifactList } from '~/__mocks__/mockModelArtifactList'; | ||
import { verifyRelativeURL } from '~/__tests__/cypress/cypress/utils/url'; | ||
|
||
const initIntercepts = () => { | ||
cy.interceptOdh( | ||
'GET /api/config', | ||
mockDashboardConfig({ | ||
disableModelRegistry: false, | ||
}), | ||
); | ||
cy.interceptOdh('GET /api/components', { query: { installed: 'true' } }, mockComponents()); | ||
|
||
cy.interceptK8sList(ModelRegistryModel, mockK8sResourceList([mockModelRegistry({})])); | ||
|
||
cy.interceptK8s(ModelRegistryModel, mockModelRegistry({})); | ||
|
||
cy.interceptK8s( | ||
RouteModel, | ||
mockRouteK8sResourceModelRegistry({ | ||
name: 'modelregistry-sample-http', | ||
namespace: 'odh-model-registries', | ||
}), | ||
); | ||
|
||
cy.interceptOdh( | ||
`GET /api/service/modelregistry/modelregistry-sample/api/model_registry/${MODEL_REGISTRY_API_VERSION}/registered_models/1`, | ||
mockRegisteredModel({}), | ||
); | ||
|
||
cy.interceptOdh( | ||
`GET /api/service/modelregistry/modelregistry-sample/api/model_registry/${MODEL_REGISTRY_API_VERSION}/registered_models/1/versions`, | ||
mockModelVersionList(), | ||
); | ||
|
||
cy.interceptOdh( | ||
`GET /api/service/modelregistry/modelregistry-sample/api/model_registry/${MODEL_REGISTRY_API_VERSION}/model_versions/:id`, | ||
{ path: { id: '1' } }, | ||
mockModelVersion({}), | ||
); | ||
|
||
cy.interceptOdh( | ||
`GET /api/service/modelregistry/modelregistry-sample/api/model_registry/${MODEL_REGISTRY_API_VERSION}/model_versions/:id`, | ||
{ path: { id: '2' } }, | ||
mockModelVersion({ id: '2', name: 'Version 2' }), | ||
); | ||
|
||
cy.interceptOdh( | ||
`GET /api/service/modelregistry/modelregistry-sample/api/model_registry/${MODEL_REGISTRY_API_VERSION}/model_versions/1/artifacts`, | ||
mockModelArtifactList(), | ||
); | ||
}; | ||
|
||
describe('Model version details', () => { | ||
beforeEach(() => { | ||
initIntercepts(); | ||
modelVersionDetails.visit(); | ||
}); | ||
|
||
it('Model version details page header', () => { | ||
verifyRelativeURL('/modelRegistry/modelregistry-sample/registeredModels/1/versions/1/details'); | ||
cy.findByTestId('app-page-title').should('have.text', 'Version 1'); | ||
cy.findByTestId('breadcrumb-version-name').should('have.text', 'Version 1'); | ||
}); | ||
|
||
it('Model version details tab', () => { | ||
modelVersionDetails.findVersionId().contains('1'); | ||
modelVersionDetails.findDescription().should('have.text', 'Description of model version'); | ||
modelVersionDetails.findMoreLabelsButton().contains('6 more'); | ||
modelVersionDetails.findMoreLabelsButton().click(); | ||
modelVersionDetails.shouldContainsModalLabels([ | ||
'Testing label', | ||
'Financial', | ||
'Financial data', | ||
'Fraud detection', | ||
'Machine learning', | ||
'Next data to be overflow', | ||
'Label x', | ||
'Label y', | ||
'Label z', | ||
]); | ||
modelVersionDetails.findStorageLocation().contains('https://huggingface.io/mnist.onnx'); | ||
}); | ||
|
||
it('Switching model versions', () => { | ||
modelVersionDetails.findVersionId().contains('1'); | ||
modelVersionDetails.findModelVersionDropdownButton().click(); | ||
modelVersionDetails.findModelVersionDropdownSearch().fill('Version 2'); | ||
modelVersionDetails.findModelVersionDropdownItem('Version 2').click(); | ||
modelVersionDetails.findVersionId().contains('2'); | ||
}); | ||
}); |
48 changes: 48 additions & 0 deletions
48
frontend/src/__tests__/cypress/cypress/pages/modelRegistry/modelVersionDetails.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { modelVersionUrl } from '~/pages/modelRegistry/screens/routeUtils'; | ||
|
||
class ModelVersionDetails { | ||
visit() { | ||
cy.visit(modelVersionUrl('1', '1', 'modelregistry-sample')); | ||
this.wait(); | ||
} | ||
|
||
private wait() { | ||
cy.findByTestId('app-page-title').should('exist'); | ||
cy.testA11y(); | ||
} | ||
|
||
findVersionId() { | ||
return cy.findByTestId('model-version-id'); | ||
} | ||
|
||
findDescription() { | ||
return cy.findByTestId('model-version-description'); | ||
} | ||
|
||
findMoreLabelsButton() { | ||
return cy.findByTestId('label-group').find('button'); | ||
} | ||
|
||
findStorageLocation() { | ||
return cy.findByTestId('storage-location'); | ||
} | ||
|
||
shouldContainsModalLabels(labels: string[]) { | ||
cy.findByTestId('label-group').within(() => labels.map((label) => cy.contains(label))); | ||
return this; | ||
} | ||
|
||
findModelVersionDropdownButton() { | ||
return cy.findByTestId('model-version-toggle-button'); | ||
} | ||
|
||
findModelVersionDropdownSearch() { | ||
return cy.findByTestId('search-input'); | ||
} | ||
|
||
findModelVersionDropdownItem(name: string) { | ||
return cy.findByTestId('model-version-selector-list').find('li').contains(name); | ||
} | ||
} | ||
|
||
export const modelVersionDetails = new ModelVersionDetails(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.