-
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.
Merge pull request #2774 from dpanshug/model-version-view
Model version view
- Loading branch information
Showing
20 changed files
with
584 additions
and
84 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
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
29 changes: 29 additions & 0 deletions
29
frontend/src/concepts/modelRegistry/apiHooks/useModelArtifactsByVersionId.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,29 @@ | ||
import * as React from 'react'; | ||
import useFetchState, { | ||
FetchState, | ||
FetchStateCallbackPromise, | ||
NotReadyError, | ||
} from '~/utilities/useFetchState'; | ||
import { ModelArtifactList } from '~/concepts/modelRegistry/types'; | ||
import { useModelRegistryAPI } from '~/concepts/modelRegistry/context/ModelRegistryContext'; | ||
|
||
const useModelArtifactsByVersionId = (modelVersionId?: string): FetchState<ModelArtifactList> => { | ||
const { api } = useModelRegistryAPI(); | ||
const callback = React.useCallback<FetchStateCallbackPromise<ModelArtifactList>>( | ||
(opts) => { | ||
if (!modelVersionId) { | ||
return Promise.reject(new NotReadyError('No model registeredModel id')); | ||
} | ||
return api.getModelArtifactsByModelVersion(opts, modelVersionId); | ||
}, | ||
[api, modelVersionId], | ||
); | ||
|
||
return useFetchState( | ||
callback, | ||
{ items: [], size: 0, pageSize: 0, nextPageToken: '' }, | ||
{ initialPromisePurity: true }, | ||
); | ||
}; | ||
|
||
export default useModelArtifactsByVersionId; |
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
88 changes: 88 additions & 0 deletions
88
frontend/src/pages/modelRegistry/screens/ModelVersionDetails/ModelVersionDetails.tsx
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,88 @@ | ||
import React from 'react'; | ||
import { useNavigate, useParams } from 'react-router'; | ||
import { Breadcrumb, BreadcrumbItem, Flex, FlexItem } from '@patternfly/react-core'; | ||
import { Link } from 'react-router-dom'; | ||
import ApplicationsPage from '~/pages/ApplicationsPage'; | ||
import useModelVersionById from '~/concepts/modelRegistry/apiHooks/useModelVersionById'; | ||
import { ModelRegistrySelectorContext } from '~/concepts/modelRegistry/context/ModelRegistrySelectorContext'; | ||
import { modelVersionUrl, registeredModelUrl } from '~/pages/modelRegistry/screens/routeUtils'; | ||
import useRegisteredModelById from '~/concepts/modelRegistry/apiHooks/useRegisteredModelById'; | ||
import { ModelVersionDetailsTab } from './const'; | ||
import ModelVersionsDetailsHeaderActions from './ModelVersionDetailsHeaderActions'; | ||
import ModelVersionDetailsTabs from './ModelVersionDetailsTabs'; | ||
import ModelVersionSelector from './ModelVersionSelector'; | ||
|
||
type ModelVersionsDetailProps = { | ||
tab: ModelVersionDetailsTab; | ||
} & Omit< | ||
React.ComponentProps<typeof ApplicationsPage>, | ||
'breadcrumb' | 'title' | 'description' | 'loadError' | 'loaded' | 'provideChildrenPadding' | ||
>; | ||
|
||
const ModelVersionsDetails: React.FC<ModelVersionsDetailProps> = ({ tab, ...pageProps }) => { | ||
const navigate = useNavigate(); | ||
|
||
const { preferredModelRegistry } = React.useContext(ModelRegistrySelectorContext); | ||
|
||
const { modelVersionId: mvId, registeredModelId: rmId } = useParams(); | ||
const [rm] = useRegisteredModelById(rmId); | ||
const [mv, mvLoaded, mvLoadError] = useModelVersionById(mvId); | ||
|
||
return ( | ||
<ApplicationsPage | ||
{...pageProps} | ||
breadcrumb={ | ||
<Breadcrumb> | ||
<BreadcrumbItem | ||
render={() => ( | ||
<Link to="/modelRegistry"> | ||
Registered models - {preferredModelRegistry?.metadata.name} | ||
</Link> | ||
)} | ||
/> | ||
<BreadcrumbItem | ||
render={() => ( | ||
<Link to={registeredModelUrl(rmId, preferredModelRegistry?.metadata.name)}> | ||
{rm?.name} | ||
</Link> | ||
)} | ||
/> | ||
<BreadcrumbItem isActive>{mv?.name}</BreadcrumbItem> | ||
</Breadcrumb> | ||
} | ||
title={mv?.name} | ||
headerAction={ | ||
mvLoaded && | ||
mv && ( | ||
<Flex | ||
spaceItems={{ default: 'spaceItemsMd' }} | ||
alignItems={{ default: 'alignItemsFlexStart' }} | ||
> | ||
<FlexItem style={{ width: '300px' }}> | ||
<ModelVersionSelector | ||
rmId={rmId} | ||
selection={mv} | ||
onSelect={(modelVersionId) => | ||
navigate( | ||
modelVersionUrl(modelVersionId, rmId, preferredModelRegistry?.metadata.name), | ||
) | ||
} | ||
/> | ||
</FlexItem> | ||
<FlexItem> | ||
<ModelVersionsDetailsHeaderActions /> | ||
</FlexItem> | ||
</Flex> | ||
) | ||
} | ||
description={mv?.description} | ||
loadError={mvLoadError} | ||
loaded={mvLoaded} | ||
provideChildrenPadding | ||
> | ||
{mv !== null && <ModelVersionDetailsTabs tab={tab} modelVersion={mv} />} | ||
</ApplicationsPage> | ||
); | ||
}; | ||
|
||
export default ModelVersionsDetails; |
Oops, something went wrong.