-
Notifications
You must be signed in to change notification settings - Fork 178
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
Sorting on models page by Last Modified is reflecting changes in versions as well #3597
base: main
Are you sure you want to change the base?
Changes from 11 commits
537f7c2
52a8b05
4583fc8
7277c59
72d36df
3df03c7
82c76d0
0105b6f
db0a896
c01978e
419ab6d
bb185fd
1d7aba9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { | ||
ModelRegistryAPIs, | ||
ModelState, | ||
ModelRegistryMetadataType, | ||
} from '~/concepts/modelRegistry/types'; | ||
|
||
type MinimalModelRegistryAPI = Pick<ModelRegistryAPIs, 'patchRegisteredModel'>; | ||
|
||
export const bumpModelVersionTimestamp = async ( | ||
api: ModelRegistryAPIs, | ||
modelVersionId: string, | ||
): Promise<void> => { | ||
if (!modelVersionId) { | ||
throw new Error('Model version ID is required'); | ||
} | ||
|
||
try { | ||
await api.patchModelVersion({}, { state: ModelState.LIVE }, modelVersionId); | ||
} catch (error) { | ||
throw new Error( | ||
`Failed to update model version timestamp: ${ | ||
error instanceof Error ? error.message : String(error) | ||
}`, | ||
); | ||
} | ||
}; | ||
|
||
export const bumpRegisteredModelTimestamp = async ( | ||
api: MinimalModelRegistryAPI, | ||
registeredModelId: string, | ||
): Promise<void> => { | ||
if (!registeredModelId) { | ||
throw new Error('Registered model ID is required'); | ||
} | ||
|
||
try { | ||
const currentTime = new Date().toISOString(); | ||
await api.patchRegisteredModel( | ||
{}, | ||
{ | ||
state: ModelState.LIVE, | ||
customProperties: { | ||
_lastModified: { | ||
metadataType: ModelRegistryMetadataType.STRING, | ||
// eslint-disable-next-line camelcase | ||
string_value: currentTime, | ||
}, | ||
}, | ||
}, | ||
registeredModelId, | ||
); | ||
} catch (error) { | ||
throw new Error( | ||
`Failed to update registered model timestamp: ${ | ||
error instanceof Error ? error.message : String(error) | ||
}`, | ||
); | ||
} | ||
}; | ||
|
||
export const bumpBothTimestamps = async ( | ||
api: ModelRegistryAPIs, | ||
modelVersionId: string, | ||
registeredModelId: string, | ||
): Promise<void> => { | ||
await Promise.all([ | ||
bumpModelVersionTimestamp(api, modelVersionId), | ||
bumpRegisteredModelTimestamp(api, registeredModelId), | ||
]); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import React from 'react'; | ||
import { Alert, Button, Form, FormSection, Spinner } from '@patternfly/react-core'; | ||
import { Modal } from '@patternfly/react-core/deprecated'; | ||
import { ModelVersion } from '~/concepts/modelRegistry/types'; | ||
import { ModelVersion, ModelState } from '~/concepts/modelRegistry/types'; | ||
import { ProjectKind } from '~/k8sTypes'; | ||
import useProjectErrorForRegisteredModel from '~/pages/modelRegistry/screens/RegisteredModels/useProjectErrorForRegisteredModel'; | ||
import ProjectSelector from '~/pages/modelServing/screens/projects/InferenceServiceModal/ProjectSelector'; | ||
|
@@ -11,7 +11,10 @@ import { getProjectModelServingPlatform } from '~/pages/modelServing/screens/pro | |
import { ServingRuntimePlatform } from '~/types'; | ||
import ManageInferenceServiceModal from '~/pages/modelServing/screens/projects/InferenceServiceModal/ManageInferenceServiceModal'; | ||
import useRegisteredModelDeployInfo from '~/pages/modelRegistry/screens/RegisteredModels/useRegisteredModelDeployInfo'; | ||
import { ModelRegistryContext } from '~/concepts/modelRegistry/context/ModelRegistryContext'; | ||
import { | ||
ModelRegistryContext, | ||
useModelRegistryAPI, | ||
} from '~/concepts/modelRegistry/context/ModelRegistryContext'; | ||
import { ModelRegistrySelectorContext } from '~/concepts/modelRegistry/context/ModelRegistrySelectorContext'; | ||
import { getKServeTemplates } from '~/pages/modelServing/customServingRuntimes/utils'; | ||
import useDataConnections from '~/pages/projects/screens/detail/data-connections/useDataConnections'; | ||
|
@@ -33,6 +36,7 @@ const DeployRegisteredModelModal: React.FC<DeployRegisteredModelModalProps> = ({ | |
servingRuntimeTemplateDisablement: { data: templateDisablement }, | ||
} = React.useContext(ModelRegistryContext); | ||
const { preferredModelRegistry } = React.useContext(ModelRegistrySelectorContext); | ||
const modelRegistryApi = useModelRegistryAPI(); | ||
|
||
const [selectedProject, setSelectedProject] = React.useState<ProjectKind | null>(null); | ||
const servingPlatformStatuses = useServingPlatformStatuses(); | ||
|
@@ -51,16 +55,35 @@ const DeployRegisteredModelModal: React.FC<DeployRegisteredModelModalProps> = ({ | |
error: deployInfoError, | ||
} = useRegisteredModelDeployInfo(modelVersion); | ||
|
||
const handleSubmit = React.useCallback(async () => { | ||
if (!modelVersion.registeredModelId) { | ||
return; | ||
} | ||
|
||
try { | ||
await Promise.all([ | ||
modelRegistryApi.api.patchModelVersion({}, { state: ModelState.LIVE }, modelVersion.id), | ||
modelRegistryApi.api.patchRegisteredModel( | ||
{}, | ||
{ state: ModelState.LIVE }, | ||
modelVersion.registeredModelId, | ||
), | ||
]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You still have direct patch calls here where I think you need to be using |
||
onSubmit?.(); | ||
} catch (submitError) { | ||
throw new Error('Failed to update timestamps after deployment'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have missed this before - throwing an error here doesn't show it to the user, it just ends up in the browser console since there's nothing catching it that renders it (like in some places where we have errors stored in state and use them to render an Alert). That might be okay for now... we actually aren't catching errors with a lot of the patches the MR edit controls do...... 🤦 that's probably worth a tech debt issue. I'll make a note of it. |
||
} | ||
}, [modelRegistryApi, modelVersion.id, modelVersion.registeredModelId, onSubmit]); | ||
|
||
const onClose = React.useCallback( | ||
(submit: boolean) => { | ||
if (submit) { | ||
onSubmit?.(); | ||
handleSubmit(); | ||
} | ||
|
||
setSelectedProject(null); | ||
onCancel(); | ||
}, | ||
[onCancel, onSubmit], | ||
[handleSubmit, onCancel], | ||
); | ||
|
||
const projectSection = ( | ||
|
@@ -101,7 +124,7 @@ const DeployRegisteredModelModal: React.FC<DeployRegisteredModelModalProps> = ({ | |
isOpen | ||
onClose={() => onClose(false)} | ||
actions={[ | ||
<Button key="deploy" variant="primary" isDisabled> | ||
<Button key="deploy" variant="primary" onClick={handleSubmit}> | ||
Deploy | ||
</Button>, | ||
<Button key="cancel" variant="link" onClick={() => onClose(false)}> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's up with this customProperties piece? I don't think it should be necessary, and it'll show up in the properties table in the UI
I think all we need is the
{ state }
part.Also... and this part is more annoying... I wonder if it's ok to just pass
ModelState.LIVE
here, technically if you called this on an archived model it would un-archive it. but since the UI also prevents editing archived stuff I think we're ok. We may just want a comment explaining that here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more - if the
_lastModified
addition here was because the { state } alone wasn't enough to automatically bump the version, that's an issue we should raise again with the backend team. If we get blocked on this and it looks like it won't make 2.17 we could remove it from the strat scope. Or if we want a temporary workaround we can leave this, but we should maybe filter it out of the properties list so it doesn't look confusing, and open a followup issue we link in comments here and where that filter is added.