-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[ML] Initialize saved objects on trained model page load #201426
[ML] Initialize saved objects on trained model page load #201426
Conversation
Pinging @elastic/ml-ui (:ml) |
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.
Tested and looks good when logged in as an admin user. Will wait for fix for non-admin user.
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.
LGTM
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.
LGTM
const { initSavedObjects } = useSavedObjectsApiService(); | ||
|
||
const initSavedObjectsWrapper = useCallback(async () => { | ||
try { | ||
await initSavedObjects(); | ||
} catch (error) { | ||
// ignore error as user may not have permission to sync | ||
} | ||
}, [initSavedObjects]); | ||
|
||
const { context } = useRouteResolver('full', ['canGetTrainedModels'], { | ||
...basicResolvers(), | ||
initSavedObjectsWrapper, | ||
}); |
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.
nit: useRouteResolver
takes care of preserving refs for provided callbacks:
const { initSavedObjects } = useSavedObjectsApiService(); | |
const initSavedObjectsWrapper = useCallback(async () => { | |
try { | |
await initSavedObjects(); | |
} catch (error) { | |
// ignore error as user may not have permission to sync | |
} | |
}, [initSavedObjects]); | |
const { context } = useRouteResolver('full', ['canGetTrainedModels'], { | |
...basicResolvers(), | |
initSavedObjectsWrapper, | |
}); | |
const { initSavedObjects } = useSavedObjectsApiService(); | |
const { context } = useRouteResolver('full', ['canGetTrainedModels'], { | |
...basicResolvers(), | |
initSavedObjects: () => initSavedObjects().catch(() => {}) | |
}); |
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.
This change is neater. I'm currently working on a related change which will do something similar on all ML pages. So for the sake of not having to retest this PR I'm going to merge as is and apply this refactor to the follow up PR
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Page load bundle
History
|
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/12054469470 |
) Fixes elastic#201410 On page load, we now call the saved object initialization api which creates any missing saved objects. (cherry picked from commit 6a649b2)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…) (#202027) # Backport This will backport the following commits from `main` to `8.x`: - [[ML] Initialize saved objects on trained model page load (#201426)](#201426) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"James Gowdy","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-27T16:28:22Z","message":"[ML] Initialize saved objects on trained model page load (#201426)\n\nFixes https://github.com/elastic/kibana/issues/201410\r\n\r\nOn page load, we now call the saved object initialization api which\r\ncreates any missing saved objects.","sha":"6a649b2e3c8a9a084a19b48f9f1e7de5ca3c4604","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix",":ml","v9.0.0","Feature:3rd Party Models","backport:version","v8.18.0"],"title":"[ML] Initialize saved objects on trained model page load","number":201426,"url":"https://github.com/elastic/kibana/pull/201426","mergeCommit":{"message":"[ML] Initialize saved objects on trained model page load (#201426)\n\nFixes https://github.com/elastic/kibana/issues/201410\r\n\r\nOn page load, we now call the saved object initialization api which\r\ncreates any missing saved objects.","sha":"6a649b2e3c8a9a084a19b48f9f1e7de5ca3c4604"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201426","number":201426,"mergeCommit":{"message":"[ML] Initialize saved objects on trained model page load (#201426)\n\nFixes https://github.com/elastic/kibana/issues/201410\r\n\r\nOn page load, we now call the saved object initialization api which\r\ncreates any missing saved objects.","sha":"6a649b2e3c8a9a084a19b48f9f1e7de5ca3c4604"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: James Gowdy <[email protected]>
Fixes #201410
On page load, we now call the saved object initialization api which creates any missing saved objects.