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] Sync ML saved objects to all spaces #202175

Merged

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented Nov 28, 2024

When manually syncing ML saved objects using the sync flyout, the saved objects are now tagged to the * space. This now matches the behaviour of the server side auto sync and the sync which happens when the trained models page is loaded.
The trained models page load sync has been extended to the AD and DA jobs lists and the overview page.

If the user does not have write permission for ML in every space they cannot sync jobs to the * space.
In this situation a warning is shown in the flyout and when they sync, the jobs/models will only be added to the current space.

image

@jgowdyelastic jgowdyelastic added release_note:enhancement :ml Feature:Anomaly Detection ML anomaly detection Feature:Data Frame Analytics ML data frame analytics features v9.0.0 Feature:3rd Party Models ML 3rd party models backport:version Backport to applied version labels v8.18.0 labels Dec 16, 2024
@jgowdyelastic jgowdyelastic marked this pull request as ready for review December 16, 2024 13:21
@jgowdyelastic jgowdyelastic requested a review from a team as a code owner December 16, 2024 13:21
@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 LGTM


router.versioned
.get({
path: `${ML_INTERNAL_BASE_PATH}/saved_objects/can_sync_to_all_spaces/{mlSavedObjectType?}`,
Copy link
Contributor

@peteharverson peteharverson Dec 18, 2024

Choose a reason for hiding this comment

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

Is it straightforward to add a dedicated test for this new endpoint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in 20343a3

@@ -37,17 +38,22 @@ export const JobSpacesSyncFlyout: FC<Props> = ({ onClose }) => {
const { displayErrorToast, displaySuccessToast } = useToastNotificationService();
const [loading, setLoading] = useState(false);
const [canSync, setCanSync] = useState(false);
const [canSyncToAllSpaces, setCanSyncToAllSpaces] = useState(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

should it be false by default?

Copy link
Member Author

@jgowdyelastic jgowdyelastic Jan 2, 2025

Choose a reason for hiding this comment

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

The warning callout is shown when canSyncToAllSpaces is false. So by having it false by default it'd mean the warning would appear briefly while loading.

Copy link
Contributor

Choose a reason for hiding this comment

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

shall we check for canSyncToAllSpaces && !loading?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the initial value for canSyncToAllSpaces is fine as true. When the value is first used for the sync check, the check is in "simulate" mode where canSyncToAllSpaces is ignored.
When the user then runs the sync for real, canSyncToAllSpaces will have its correct value.

Also by adding a check for loading, it'd mean the warning will disappear when the user then clicks sync and reappear when the sync is complete.

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.

One small question regarding checking the loading state, the rest LGTM

@elasticmachine
Copy link
Contributor

💔 Build Failed

Failed CI Steps

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2125 2126 +1

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 +1.1KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
ml 104 105 +1

Page load bundle

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

id before after diff
ml 77.7KB 77.6KB -101.0B

History

cc @jgowdyelastic

@jgowdyelastic jgowdyelastic merged commit 3d65e89 into elastic:main Jan 7, 2025
9 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 7, 2025
When manually syncing ML saved objects using the sync flyout, the saved
objects are now tagged to the `*` space. This now matches the behaviour
of the server side auto sync and the sync which happens when the trained
models page is loaded.
The trained models page load sync has been extended to the AD and DA
jobs lists and the overview page.

If the user does not have write permission for ML in every space they
cannot sync jobs to the `*` space.
In this situation a warning is shown in the flyout and when they sync,
the jobs/models will only be added to the current space.

![image](https://github.com/user-attachments/assets/9e6ede10-d7aa-4724-9b1c-adabe96593a8)

(cherry picked from commit 3d65e89)
@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 Jan 7, 2025
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Sync ML saved objects to all spaces
(#202175)](#202175)

<!--- 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":"2025-01-07T09:56:00Z","message":"[ML]
Sync ML saved objects to all spaces (#202175)\n\nWhen manually syncing
ML saved objects using the sync flyout, the saved\r\nobjects are now
tagged to the `*` space. This now matches the behaviour\r\nof the server
side auto sync and the sync which happens when the trained\r\nmodels
page is loaded.\r\nThe trained models page load sync has been extended
to the AD and DA\r\njobs lists and the overview page.\r\n\r\nIf the user
does not have write permission for ML in every space they\r\ncannot sync
jobs to the `*` space.\r\nIn this situation a warning is shown in the
flyout and when they sync,\r\nthe jobs/models will only be added to the
current
space.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/9e6ede10-d7aa-4724-9b1c-adabe96593a8)","sha":"3d65e892a014aa5a027d82caa9d92392a515390b","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement",":ml","Feature:Anomaly
Detection","Feature:Data Frame Analytics","v9.0.0","Feature:3rd Party
Models","backport:version","v8.18.0"],"title":"[ML] Sync ML saved
objects to all
spaces","number":202175,"url":"https://github.com/elastic/kibana/pull/202175","mergeCommit":{"message":"[ML]
Sync ML saved objects to all spaces (#202175)\n\nWhen manually syncing
ML saved objects using the sync flyout, the saved\r\nobjects are now
tagged to the `*` space. This now matches the behaviour\r\nof the server
side auto sync and the sync which happens when the trained\r\nmodels
page is loaded.\r\nThe trained models page load sync has been extended
to the AD and DA\r\njobs lists and the overview page.\r\n\r\nIf the user
does not have write permission for ML in every space they\r\ncannot sync
jobs to the `*` space.\r\nIn this situation a warning is shown in the
flyout and when they sync,\r\nthe jobs/models will only be added to the
current
space.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/9e6ede10-d7aa-4724-9b1c-adabe96593a8)","sha":"3d65e892a014aa5a027d82caa9d92392a515390b"}},"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/202175","number":202175,"mergeCommit":{"message":"[ML]
Sync ML saved objects to all spaces (#202175)\n\nWhen manually syncing
ML saved objects using the sync flyout, the saved\r\nobjects are now
tagged to the `*` space. This now matches the behaviour\r\nof the server
side auto sync and the sync which happens when the trained\r\nmodels
page is loaded.\r\nThe trained models page load sync has been extended
to the AD and DA\r\njobs lists and the overview page.\r\n\r\nIf the user
does not have write permission for ML in every space they\r\ncannot sync
jobs to the `*` space.\r\nIn this situation a warning is shown in the
flyout and when they sync,\r\nthe jobs/models will only be added to the
current
space.\r\n\r\n\r\n![image](https://github.com/user-attachments/assets/9e6ede10-d7aa-4724-9b1c-adabe96593a8)","sha":"3d65e892a014aa5a027d82caa9d92392a515390b"}},{"branch":"8.x","label":"v8.18.0","branchLabelMappingKey":"^v8.18.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: James Gowdy <[email protected]>
kowalczyk-krzysztof pushed a commit to kowalczyk-krzysztof/kibana that referenced this pull request Jan 7, 2025
When manually syncing ML saved objects using the sync flyout, the saved
objects are now tagged to the `*` space. This now matches the behaviour
of the server side auto sync and the sync which happens when the trained
models page is loaded.
The trained models page load sync has been extended to the AD and DA
jobs lists and the overview page.

If the user does not have write permission for ML in every space they
cannot sync jobs to the `*` space.
In this situation a warning is shown in the flyout and when they sync,
the jobs/models will only be added to the current space.


![image](https://github.com/user-attachments/assets/9e6ede10-d7aa-4724-9b1c-adabe96593a8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:version Backport to applied version labels Feature:Anomaly Detection ML anomaly detection Feature:Data Frame Analytics ML data frame analytics features Feature:3rd Party Models ML 3rd party models :ml release_note:enhancement v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants