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] Single Metric Viewer embeddable in dashboards: move all config to flyout #182756

Conversation

alvarezmelissa87
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 commented May 6, 2024

Summary

Part of #182042
This PR also fixes the issue in the swimlane embeddable that fails to close the flyout if navigating into the main dashboards page.

Related meta issue: #181272
Item: https://github.com/elastic/kibana/issues/181272

image

Checklist

Delete any items that are not applicable to this PR.

@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

}
}
},
[isMounted, jobIds, mlApiServices, panelTitle, initialValuesRef.current.isNewJob, job?.job_id]
Copy link
Contributor

Choose a reason for hiding this comment

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

Just realized, both here and in the anomaly swim lane initializer, we need to introduce a debounce on job IDs change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

🤔 I'm not sure we do in this case since we only do the fetch if a new job has been selected (that hasn't already been loaded). Also - are people rapidly clicking around a ton on job ids? I think the dropdown closes after each selection (at least on single selection) so it would be difficult for a user to be changing job ids extremely quickly.

Comment on lines 63 to 77
{
type: 'push',
ownFocus: true,
size: 's',
onClose: () => {
flyoutSession.close();
reject();
},
}
);
// Close the flyout when user navigates out of the current plugin
currentAppId$
.pipe(skip(1), takeUntil(from(flyoutSession.onClose)), distinctUntilChanged())
.subscribe(() => {
flyoutSession.close();
Copy link
Contributor

Choose a reason for hiding this comment

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

as this logic has been copied from the anomaly swim lane initializer, shall we consolidate it in a single function, e.g. initMlEmbeddalbeFlyout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed - this is going to be very similar boiler plate code for all the embeddables 👍
Though I'm okay leaving it until the rest of the embeddables are converted to make sure we account for all potential cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's definitely the case for every embeddable, i.e. for anomaly charts as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

@alvarezmelissa87 important update! we need to track overlay a bit differently, you can look up in the recent change point detection PR, where I also update the swim lane edit and add flow

it will automatically track if the user navigates away from the dashboard app and disables all controls on the active dashboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in 7603fd4 🙏

@peteharverson
Copy link
Contributor

Testing this I also found an issue when changing the selected job (also happens on main). I think this occurs when switching from a job with 1 detector to one with multiple detectors and selecting the detector at an index which doesn't exist in the first job. Here I select a job with 2 detectors and pick the second detector.

Looks like buildConfigFromDetector in chart_config_builder.ts is called several times, and at one point is passed the config for the previously selected job but the detector index from the new selection:

Screen.Recording.2024-05-09.at.11.22.06.mov

@alvarezmelissa87
Copy link
Contributor Author

Created a separate PR for the fix for the issue you found, @peteharverson so we can backport to 8.14. 👍

@alvarezmelissa87
Copy link
Contributor Author

alvarezmelissa87 commented May 9, 2024

This is ready for another look when you get a chance cc @darnautov, @peteharverson

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.

Latest changes LGTM

alvarezmelissa87 added a commit that referenced this pull request May 10, 2024
…fferent job works as expected (#183086)

## Summary

Fixes
#182756 (comment)

This PR ensures the loaded job and the selected job id are synced to
ensure the chart loads correctly.

After:



https://github.com/elastic/kibana/assets/6446462/4c80bdd6-54cd-4404-8fa4-8930aca1b3f9
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

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@alvarezmelissa87
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

merge conflict between base and head

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #44 / Lists plugin Lists API "before all" hook for "should return a 400 if an endpoint exception item with a list-based entry is provided"

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2013 2012 -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.2MB 4.2MB +519.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 77.0KB 77.0KB -2.0B
Unknown metric groups

async chunk count

id before after diff
ml 98 99 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @alvarezmelissa87

@alvarezmelissa87 alvarezmelissa87 merged commit f0f2ca0 into elastic:main May 14, 2024
19 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 14, 2024
@alvarezmelissa87 alvarezmelissa87 deleted the ml-smv-embeddable-dash-config-update branch May 14, 2024 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Anomaly Detection ML anomaly detection :ml release_note:enhancement v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants