-
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?
Sorting on models page by Last Modified is reflecting changes in versions as well #3597
Conversation
2dadc96
to
72d36df
Compare
@@ -127,15 +135,16 @@ const ModelVersionsTableRow: React.FC<ModelVersionsTableRowProps> = ({ | |||
) : null} | |||
{isDeployModalOpen ? ( | |||
<DeployRegisteredModelModal | |||
onSubmit={() => | |||
onSubmit={async () => { | |||
await handleAfterDeploy(); |
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.
I think you also need to add this to where DeployRegisteredModelModal gets rendered in ModelVersionDetailsHeaderActions
frontend/src/pages/modelRegistry/screens/ModelVersionDetails/ModelVersionDetailsView.tsx
Outdated
Show resolved
Hide resolved
frontend/src/pages/modelRegistry/screens/ModelVersionDetails/ModelVersionDetailsView.tsx
Show resolved
Hide resolved
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.
A handful of things here that shouldn't be too bad to address - but this is already working nicely!
return; | ||
} | ||
|
||
await bumpBothTimestamps(apiState.api, mv.id, mv.registeredModelId); |
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.
Since the version was just updated, you only need to bump the model timestamp, not both 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.
I tried- It didn't work - need both of them .
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.
I don't understand though, the updatePromise you pass in is already calling patchModelVersion
with a description/labels, why do we need to patch it again to get the timestamp to change? Are you sure?
customProperties: { | ||
_lastModified: { | ||
metadataType: ModelRegistryMetadataType.STRING, | ||
// eslint-disable-next-line camelcase | ||
string_value: currentTime, | ||
}, | ||
}, |
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.
patchRegisteredModel: (apiOpts, patchData, id) => | ||
handleModelRegistryFailures( | ||
proxyPATCH( | ||
hostpath, | ||
`/api/model_registry/${MODEL_REGISTRY_API_VERSION}/registered_models/${id}`, | ||
patchData, | ||
apiOpts, | ||
), | ||
), | ||
}, | ||
registeredModelId, | ||
); |
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.
You might be able to just use the patchRegisteredModel
exported from this same file below (already in scope inside this function), it returns the same function you're writing here.
await bumpRegisteredModelTimestamp(
{ patchRegisteredModel: patchRegisteredModel(hostpath) },
registeredModelId,
);
frontend/src/concepts/modelRegistry/apiHooks/useModelVersionCreation.ts
Outdated
Show resolved
Hide resolved
@@ -75,5 +81,9 @@ export const useModelRegistryAPI = (): UseModelRegistryAPI => { | |||
return { | |||
refreshAllAPI, | |||
...apiState, | |||
patchModelVersion: (modelVersionId: string, updates: Partial<ModelVersion>) => | |||
apiState.api.patchModelVersion({}, updates, modelVersionId).then(() => undefined), |
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.
I'm not sure I understand the purpose of the changes in this file. Why add these patch functions to the root of the returned object when they're already returned under .api.*
which you use internally here? Why then
and then do nothing in the callback?
await Promise.all([ | ||
modelRegistryApi.patchModelVersion(modelVersionId, { state: ModelState.LIVE }), | ||
modelRegistryApi.patchRegisteredModel(registeredModelId, { state: ModelState.LIVE }), | ||
]); |
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.
If you remove the changes you made to ModelRegistryContext, you can just rewrite these calls using the stuff already returned by useModelRegistryAPI
. You just need an extra .api.*
and to rearrange your args a bit:
await Promise.all([
modelRegistryApi.api.patchModelVersion({}, { state: ModelState.LIVE }, modelVersionId),
modelRegistryApi.api.patchRegisteredModel(
{},
{ state: ModelState.LIVE },
registeredModelId,
),
]);
I wonder if the reason for these extra functions was because you didn't see them exposed on the root of the returned modelRegistryApi
object here? I think this is why in other places we name that variable apiState
and then call apiState.api.patch...
. It's structured that way so we can attach extra stuff like refreshAllAPI
to it but the core .api
object already included here should contain all you need.
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.
Also - as mentioned elsewhere, since you'll need this same behavior for both of the places where we can deploy (the <DeployRegisteredModelModal>
is also rendered in the ModelVersionDetailsHeaderActions
component) you may not want to pass down a handleAfterDeploy
from all the way up here (and have to duplicate it). Maybe you can just write this logic inside DeployRegisteredModelModal
itself? That component is only used for model registry (it's a wrapper around the stuff we reuse in model serving) so it should always be bumping these timestamps. You can call useModelRegistryAPI();
in there. Then you could remove some of the extra plumbing you added to make handleAfterDeploy
work.
Lastly, you can probably use your new util bumpBothTimestamps
instead of repeating the patches here.
@@ -52,11 +52,10 @@ const DeployRegisteredModelModal: React.FC<DeployRegisteredModelModalProps> = ({ | |||
} = useRegisteredModelDeployInfo(modelVersion); | |||
|
|||
const onClose = React.useCallback( | |||
(submit: boolean) => { | |||
async (submit: boolean) => { |
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.
I'm not sure I see why this was made async, I can't find anywhere it's awaited and it's not awaiting anything
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
One more thing to clean up, and something I realize is a problem that's probably outside the scope of this PR to solve.
const modelRegistryApi = useModelRegistryAPI(); | ||
|
||
const handleAfterDeploy = useCallback( | ||
async (modelVersionId: string) => { | ||
if (!registeredModelId) { | ||
return; | ||
} | ||
|
||
try { | ||
await Promise.all([ | ||
modelRegistryApi.api.patchModelVersion({}, { state: ModelState.LIVE }, modelVersionId), | ||
modelRegistryApi.api.patchRegisteredModel( | ||
{}, | ||
{ state: ModelState.LIVE }, | ||
registeredModelId, | ||
), | ||
]); | ||
} catch (error) { | ||
throw new Error('Failed to update timestamps after deployment'); | ||
} | ||
}, | ||
[registeredModelId, modelRegistryApi], | ||
); | ||
|
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.
I think now that you're doing this logic inside DeployRegisteredModelModal you can remove all this from ModelVersionsTable, and also remove all the onAfterDeploy
/ handleAfterDeploy
related code elsewhere right?
]); | ||
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 comment
The 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.
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 comment
The 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 bumpBothTimestamps
instead to make sure the _lastModified property workaround gets applied
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.
Code LGTM, we'll hold this for now until we have tests -- and I'll give it another review after the holidays to be safe because my brain is fried 🫠 but it looks to be in a good place.
RHOAIENG-16077
Description
When you go to the Models list page, the sorting by Last modified will now reflect any changes in the versions of that model. To test this got to some model that is not on top of the list and edit some version on it on any possible field( labels, description etc). Return to the models page and notice that the model is now on top of the list. In addition test similar scenario but we creating a new model Version.
Screen.Recording.2024-12-19.at.9.53.52.AM.mov
How Has This Been Tested?
This was tested on MR cluster
Test Impact
Updated and added tests to cover the new hooks und functionalities (WIP)
Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
main