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] Remove legacy scss overwrites Single Metric Viewer #195259

Merged

Conversation

rbrtj
Copy link
Contributor

@rbrtj rbrtj commented Oct 7, 2024

Summary

Removes SCSS files for the Single Metric Viewer and adds BEM classes for annotations.
Affects the Single Metric Viewer in ML and the embeddable.
Part of #140695

@kibana-ci
Copy link
Collaborator

kibana-ci commented Oct 7, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #21 / machine learning - anomaly detection annotations creating creates annotation
  • [job] [logs] FTR Configs #21 / machine learning - anomaly detection annotations creating creates annotation
  • [job] [logs] Jest Tests #11 / Policy form Detect Prevent Protection level component should allow detect mode to be selected

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2041 2038 -3

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.6MB 5.0MB ⚠️ +371.3KB

Page load bundle

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

id before after diff
ml 74.4KB 74.4KB +1.0B
Unknown metric groups

async chunk count

id before after diff
ml 109 108 -1

History

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

cc @rbrtj

@rbrtj rbrtj changed the title Replace legacy scss overwrites single metric viewer [ML] Remove legacy scss overwrites Single Metric Viewer Oct 8, 2024
@rbrtj rbrtj marked this pull request as ready for review October 8, 2024 21:52
@rbrtj rbrtj requested review from a team as code owners October 8, 2024 21:52
@rbrtj rbrtj requested review from walterra and darnautov October 8, 2024 21:53
@rbrtj rbrtj added :ml release_note:skip Skip the PR/issue when compiling release notes Team:ML Team label for ML (also use :ml) v8.16.0 backport:version Backport to applied version labels labels Oct 8, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

// Annotations styles

'.ml-annotation': {
'&__brush': {
Copy link
Contributor

Choose a reason for hiding this comment

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

This &__... syntax here and down below unfortunately isn't working after the migration. SCSS will use & to produce class names like .ml-annotation__brush, that's no longer happening so the correct styles are not getting applied to annotations.

This is how it looks on main:

image

This PR:

image

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 believe the syntax is correct and it works!
What happened is (I'm guessing) that I deleted the @import 'timeseriesexplorer/index'; in
x-pack/plugins/ml/public/application/_index.scss
So the styles for annotations in the Anomaly Explorer were removed.
In 0d5af5f I split the styles into two separate functions and applied them where needed. It seems to be working correctly now. I've also updated the embeddables

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh nice, great to see that's supported, so I was just misinterpreting why it was broken. I checked the latest state and it's working for me now too 👍

@@ -38,13 +39,11 @@ export const TimeSeriesExplorerPage: FC<PropsWithChildren<TimeSeriesExplorerPage
const CasesContext = cases?.ui.getCasesContext() ?? React.Fragment;
const casesPermissions = cases?.helpers.canUseCases();
const helpLink = docLinks.links.ml.anomalyDetection;

const timeseriesExplorerStyles = getTimeseriesExplorerStyles();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be done once outside the component instead of during every render?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 0d5af5f

@@ -204,6 +204,8 @@ const SingleMetricViewerWrapper: FC<SingleMetricViewerPropsWithDeps> = ({
}
};

const timeseriesExplorerStyles = getTimeseriesExplorerStyles();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be done once outside the component instead of during every render?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 0d5af5f

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

It's unfortunate that this change causes such an increase in async bundle sizes. Do you want to investigate a bit? You can do so by running this command:

node scripts/build_kibana_platform_plugins.js --dist --profile --focus=ml --no-cache

This will build optimized/minified bundles in x-pack/plugins/ml/target/public. In the directory you'll find some HTML files created by utilities to investigate the bundle sizes. You could compare main and this PR and investigate what's going on.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2033 2030 -3

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.5MB 4.8MB ⚠️ +332.1KB

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.0KB 75.0KB +1.0B
Unknown metric groups

async chunk count

id before after diff
ml 109 107 -2

History

cc @rbrtj

@rbrtj
Copy link
Contributor Author

rbrtj commented Oct 11, 2024

It's unfortunate that this change causes such an increase in async bundle sizes. Do you want to investigate a bit? You can do so by running this command:

node scripts/build_kibana_platform_plugins.js --dist --profile --focus=ml --no-cache

This will build optimized/minified bundles in x-pack/plugins/ml/target/public. In the directory you'll find some HTML files created by utilities to investigate the bundle sizes. You could compare main and this PR and investigate what's going on.

It seems that the bundle size is good now. The problem was caused by importing styles into embeddable via index.ts instead of using a direct import, which caused some time-series-explorer components to appear twice in the bundle.

Copy link
Contributor

@walterra walterra 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 including bundle size LGTM, great you were able to fix it!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2035 2032 -3

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.5MB 4.5MB -24.6KB
Unknown metric groups

async chunk count

id before after diff
ml 109 110 +1

History

cc @rbrtj

},

'.tick line': {
stroke: euiThemeVars.euiColorLightShade,
Copy link
Contributor

Choose a reason for hiding this comment

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

does it look ok with the dark theme 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.

ah yes, I see it automatically adjust

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

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2035 2032 -3

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.5MB 4.5MB -24.6KB
Unknown metric groups

async chunk count

id before after diff
ml 109 110 +1

History

cc @rbrtj

@rbrtj rbrtj merged commit 87c91f4 into elastic:main Oct 14, 2024
21 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Oct 14, 2024
## Summary

Removes SCSS files for the Single Metric Viewer and adds BEM classes for
`annotations`.
Affects the Single Metric Viewer in ML and the embeddable.
Part of [elastic#140695](elastic#140695)

(cherry picked from commit 87c91f4)
@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 Oct 14, 2024
… (#196085)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] Remove legacy scss overwrites Single Metric Viewer
(#195259)](#195259)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Robert
Jaszczurek","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-14T10:14:37Z","message":"[ML]
Remove legacy scss overwrites Single Metric Viewer (#195259)\n\n##
Summary\r\n\r\nRemoves SCSS files for the Single Metric Viewer and adds
BEM classes for\r\n`annotations`.\r\nAffects the Single Metric Viewer in
ML and the embeddable.\r\nPart of
[#140695](https://github.com/elastic/kibana/issues/140695)","sha":"87c91f4e258db1910e13daec7e8267d1110735dd","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","v9.0.0","Team:ML","v8.16.0","backport:version"],"title":"[ML]
Remove legacy scss overwrites Single Metric
Viewer","number":195259,"url":"https://github.com/elastic/kibana/pull/195259","mergeCommit":{"message":"[ML]
Remove legacy scss overwrites Single Metric Viewer (#195259)\n\n##
Summary\r\n\r\nRemoves SCSS files for the Single Metric Viewer and adds
BEM classes for\r\n`annotations`.\r\nAffects the Single Metric Viewer in
ML and the embeddable.\r\nPart of
[#140695](https://github.com/elastic/kibana/issues/140695)","sha":"87c91f4e258db1910e13daec7e8267d1110735dd"}},"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/195259","number":195259,"mergeCommit":{"message":"[ML]
Remove legacy scss overwrites Single Metric Viewer (#195259)\n\n##
Summary\r\n\r\nRemoves SCSS files for the Single Metric Viewer and adds
BEM classes for\r\n`annotations`.\r\nAffects the Single Metric Viewer in
ML and the embeddable.\r\nPart of
[#140695](https://github.com/elastic/kibana/issues/140695)","sha":"87c91f4e258db1910e13daec7e8267d1110735dd"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Robert Jaszczurek <[email protected]>
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 :ml release_note:skip Skip the PR/issue when compiling release notes Team:ML Team label for ML (also use :ml) v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants