-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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 dependency cache. #189729
[ML] Remove dependency cache. #189729
Conversation
ebcb88c
to
17aa860
Compare
4114a27
to
17d4928
Compare
ml
and other services away from dependency cache.@@ -43,6 +42,7 @@ export const DetailsStepForm: FC<CreateAnalyticsStepProps> = ({ | |||
const { | |||
services: { docLinks, notifications }, | |||
} = useMlKibana(); | |||
const ml = useMlApiContext(); |
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.
Same here
Awesome work getting rid of the dependency cache finally! Functionality for DFA looks good - just added a few comments to the code. |
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 after latest edits for the areas I tested:
- Embeddables
- Single Metric Viewer
- Overview page
- Notifications
- Memory Usage
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 ⚡
), | ||
|
||
[dashboardService, data, mlApiServices, uiSettings] | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
from my testing this comment isn't needed and the dependency list can be correct.
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.
Updated in 393abda.
/** | ||
* ML Http Service | ||
*/ | ||
export class HttpService { | ||
public getLoadingCount$: Observable<number>; | ||
|
||
constructor(private httpStart: HttpStart) { | ||
this.getLoadingCount$ = httpStart.getLoadingCount$(); | ||
constructor(private httpSetup: HttpSetup) { |
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 could stay as HttpStart
, they are the same it seems, but we use the one from coreStart
which is HttpStart
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.
Updated in Updated in 393abda.
@@ -90,7 +100,13 @@ export class MultiMetricJobCreator extends JobCreator { | |||
this._overrideConfigs(job, datafeed); | |||
this.createdBy = CREATED_BY_LABEL.MULTI_METRIC; | |||
this._sparseData = isSparseDataJob(job, datafeed); | |||
const detectors = getRichDetectors(job, datafeed, this.additionalFields, false); | |||
const detectors = getRichDetectors( |
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.
I think getRichDetectors
(and getFieldByIdFactory
) could be moved to be a member of the base class. It then wouldn't need newJobCapsService
to be passed to it.
I can do this in a follow up, if you don't want to complicate this PR any further.
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.
Yes, let's do this in follow ups please 😅 .
This a great bit of refactoring, thanks for doing it. I'm going to follow it up with some further changes to move |
…into ml-rip-dependency-cache
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
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Module Count
Async chunks
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @walterra |
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
Addresses the comment from the description of this [PR](#189729): `We have a bit of a mix of naming: ml, mlApiServices, useMlApiContext() for the same thing` Renames: `useMlApiContext` -> `useMlApi` `ml` -> `mlApi` `mlApiServices` -> `mlApi` `MlApiServices ` -> `MlApi` E.g. we can now use `const mlApi = useMlApi();` Rather than: `const ml = useMlApiContext();` or `const mlServices = useMlApiContext();` or ``` const { services: { mlServices: { mlApiServices }, }, } = useMlKibana(); ```
…asts table fix (#192000) ## Summary Fix for: [#191936](#191936) Fixes navigation from the Forecasts & Annotations table to the Single Metric Viewer. Added functional tests. Tested on 8.15 - issue doesn't exist, it was probably introduced in [#189729](#189729) ### Checklist - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
## Summary Upgrades `@testing-library/user-event` to `^14.5.2`. See the release notes for `v14` for breaking changes: https://github.com/testing-library/user-event/releases/tag/v14.0.0 I was facing an [issue](testing-library/user-event#662) with `v13.5.0` with `userEvent.click()` in a PR (#189729) and was able to verify that `v14.4.3` onwards fixes it so I decided to update that package. What a rabbit hole 😅 ! - In `user-event` `v14` events return a promise, so this PR updates usage of the likes of `userEvent.click` with `await userEvent.click`. Regex to search for `userEvent` calls that miss `await` except `.setup`: `(?<!await\s)userEvent\.(?!setup\b)` - The way to handle pointer events needed changing from `, undefined, { skipPointerEventsCheck: true });` to `, { pointerEventsCheck: 0 });`. - I tried a bit to do the refactor with codemods, but there were quite some edge cases so it ended up being done manually. - I looked into all failing tests and tried my best to update them, but for some of them I lacked the context to make them work again. If you're a code owner and find a skipped test in this PR please give it a try to fix and push in this PR or let me know if it's fine for you to fix in follow ups. List of files where I had to skip tests (`git diff main...HEAD -G'\.skip' --name-only`): ### `packages/kbn-dom-drag-drop` - `packages/kbn-dom-drag-drop/src/droppable.test.tsx` ### `x-pack/plugins/cases` - `x-pack/plugins/cases/public/components/templates/form.test.tsx` - `x-pack/plugins/cases/public/components/user_actions/user_actions_list.test.tsx` ### `x-pack/plugins/cloud_security_posture` - `x-pack/plugins/cloud_security_posture/public/components/fleet_extensions/policy_template_form.test.tsx` ### `x-pack/plugins/lens` - `x-pack/plugins/lens/public/datasources/form_based/dimension_panel/format_selector.test.tsx` ### `x-pack/plugins/observability_solution` - `x-pack/plugins/observability_solution/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/request_body_field.test.tsx` ### `x-pack/plugins/security_solution` - `x-pack/plugins/security_solution/public/management/components/console/components/command_input/integration_tests/command_input.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/kill_process_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/release_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/status_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_responder/command_render_components/integration_tests/upload_action.test.tsx` - `x-pack/plugins/security_solution/public/management/components/endpoint_response_actions_list/integration_tests/response_actions_log.test.tsx` - `x-pack/plugins/security_solution/public/management/pages/event_filters/view/components/event_filters_flyout.test.tsx` - `x-pack/plugins/security_solution/public/management/pages/response_actions/view/response_actions_list_page.test.tsx` ---- I plan to do a talk on Kibana Demo Days to walk through some of the breaking changes and learnings. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Follow on from dependancy cache removal #189729 Moving and removing as much as possible out of the `JobService` class. - Moving the job cloning functions to a separate class as they do not require the same dependancies as `JobService` - Removing api basic wrapper functions like `saveNewJob`, `openJob`, `forceStartDatafeeds` etc - Removes toast dependency. This might be controversial, but I think it is unnecessary for these basic job/datafeed loading functions to show a toast if they fail. If we cannot load the basic list of jobs then there is something else very wrong with the system. We also throw the errors, so they will not be lost. It should be up to the calling function to display a toast. Removing this dependency cleans up the code quite a lot. - The `JobCreator` classes no longer use `JobService`
Summary
Fixes #153477.
Fixes #153476.
Part of #187772 (technical debt).
Part of #153288 (migrate enzyme tests to react-testing-lib).
Removes dependency cache. The major culprit making this PR large and not easy to split is that
getHttp()
from the dependency cache was used throughout the code base for services likemlJobService
andml/mlApiServices
which then themselves were directly imported and not part of React component lifecycles.withKibana
andcontext
for class based React components. This was not consolidated in this PR, I took what's there and adjusted how services get used. These components access services viathis.props.kibana.services.*
orthis.context.services.*
.mlJobService
are exposed now via a factory that makes sure the service gets instantiated only once.react-testing-lib
. They no longer make use of snapshots or call component methods which should be considered implementation details.toasts
viauseMlKibana
and our owntoastNotificationServices
that wrapstoasts
. I didn't consolidate this in this PR but used what's available for the given code.componentDidMount()
toconstructor()
where I spotted it.ml
,mlApiServices
,useMlApiContext()
for the same thing. I didn't consolidate the naming in this PR, to avoid making this PR even larger. This can be done in a follow up, once this PR is in this should be more straightforward and less risky.explorer_chart_config_builder.js
is no longer used anywhere so I deleted it.jobs/jobs_list/components/utils.d.ts
was missing some definitions, tried to fix them.stashJobForCloning
to be a method ofmlJobService
.MetricSelector
component was an exact copy besides the i18n label, consolidated that so anomaly detection wizards use the same component.Checklist