Skip to content
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

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Nov 22, 2024

Fixes #201410

On page load, we now call the saved object initialization api which creates any missing saved objects.

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

Copy link
Contributor

@peteharverson peteharverson left a 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.

@jgowdyelastic jgowdyelastic added the backport:version Backport to applied version labels label Nov 25, 2024
Copy link
Contributor

@peteharverson peteharverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@darnautov darnautov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +52 to +65
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,
});
Copy link
Contributor

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:

Suggested change
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(() => {})
});

Copy link
Member Author

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

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #12 / FilterPopover renders empty label correctly
  • [job] [logs] Jest Tests #15 / StepDefinePackagePolicy default API response should display vars coming from package policy

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
ml 4.7MB 4.7MB +154.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
ml 75.5KB 75.8KB +252.0B

History

cc @jgowdyelastic

@jgowdyelastic jgowdyelastic merged commit 6a649b2 into elastic:main Nov 27, 2024
9 checks passed
@jgowdyelastic jgowdyelastic deleted the initialize-saved-objects-on-trained-model-page-load branch November 27, 2024 16:28
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12054469470

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 27, 2024
)

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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 27, 2024
…) (#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Trained Models: Spaces sync missing after creating an inference endpoint
5 participants