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] AIOps: Cleanup context/embeddingOrigin #194442

Merged
merged 8 commits into from
Oct 7, 2024

Conversation

walterra
Copy link
Contributor

@walterra walterra commented Sep 30, 2024

Summary

Part of #187772.

We had a mix of passing around embeddingOrigin via props and context. This PR cleans this up, embeddingOrigin is now be required to be passed in on the outer most component and will then be used internally via context only.

The PR also renames references to AppDependencies to AiopsAppContextValue. Originally, this context was used only to pass in dependencies to be used via useKibana. Over time this changed a bit and we started passing in other non-changing values, the naming change now reflects that more properly and brings the name in line with the other context related vars like AiopsAppContext.Provider and useAiopsAppContext.

Checklist

@walterra walterra self-assigned this Sep 30, 2024
@walterra walterra force-pushed the ml-aiops-context-refactor branch from a4b46a3 to d3a7e1e Compare September 30, 2024 14:51
@walterra walterra marked this pull request as ready for review October 1, 2024 09:34
@walterra walterra requested review from a team as code owners October 1, 2024 09:34
@walterra walterra added :ml v9.0.0 Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis v8.16.0 backport:version Backport to applied version labels labels Oct 1, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

@walterra walterra added the release_note:skip Skip the PR/issue when compiling release notes label Oct 1, 2024
Comment on lines +24 to +30
export const AIOPS_EMBEDDABLE_ORIGIN = {
CASES: 'cases',
DASHBOARD: 'dashboard',
DEFAULT: 'embeddable',
DISCOVER: 'discover',
ML_AIOPS_LABS: 'ml_aiops_labs',
} as const;
Copy link
Contributor Author

@walterra walterra Oct 1, 2024

Choose a reason for hiding this comment

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

Originally I wanted to use this to enforce this as a union type when adding embeddingOrigin on the context value. However, this turned out to be tricky for example in Discover where we pass on another value from Discover that's just typed as string. I left this in to be reusable within our own code even when the type is not enforced, it might help with tracking of what kinds of origins we expect to be passed on. Let me know what you think about it.

@botelastic botelastic bot added ci:project-deploy-observability Create an Observability project Team:obs-ux-management Observability Management User Experience Team labels Oct 1, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

Copy link
Member

@jgowdyelastic jgowdyelastic left a comment

Choose a reason for hiding this comment

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

Over all LGTM.
We've discussed offline that we're getting close to needing separate contexts for each AIOps feature as they each have slightly different dependencies.
This can be something we look into in the future.

deps={services}
embeddingOrigin="discover"
appContextValue={
{ embeddingOrigin: 'discover', ...services } as unknown as AiopsAppContextValue
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This casting to unknown was previously done inside the component. I was able to remove one layer of adjusting dependencies but it made this necessary on the consuming code. We plan to get rid of the unknown in a follow up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be done as an immediate followup? If not, could you leave a comment above the line indicating that it will soon be updated with a link to the followup issue or this PR?

Copy link
Contributor

@dominiqueclarke dominiqueclarke 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

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

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

Code-only review, Data Discovery changes LGTM 👍

deps={services}
embeddingOrigin="discover"
appContextValue={
{ embeddingOrigin: 'discover', ...services } as unknown as AiopsAppContextValue
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this be done as an immediate followup? If not, could you leave a comment above the line indicating that it will soon be updated with a link to the followup issue or this PR?

@kibana-ci
Copy link
Collaborator

kibana-ci commented Oct 7, 2024

💚 Build Succeeded

  • Buildkite Build
  • Commit: 42e2591
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-194442-42e25919b845

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
ml 2041 2042 +1

Async chunks

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

id before after diff
aiops 552.7KB 552.5KB -215.0B
discover 820.0KB 820.0KB +16.0B
infra 1.6MB 1.6MB +5.0B
ml 4.6MB 4.6MB +743.0B
observability 467.6KB 467.6KB +8.0B
slo 855.4KB 855.4KB +5.0B
total +562.0B
Unknown metric groups

API count

id before after diff
aiops 73 72 -1

History

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

cc @walterra

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

@walterra walterra merged commit ae36dd5 into elastic:main Oct 7, 2024
23 checks passed
@walterra walterra deleted the ml-aiops-context-refactor branch October 7, 2024 15:32
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

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

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

Part of elastic#187772.

We had a mix of passing around `embeddingOrigin` via props and context.
This PR cleans this up, `embeddingOrigin` is now be required to be
passed in on the outer most component and will then be used internally
via context only.

The PR also renames references to `AppDependencies` to
`AiopsAppContextValue`. Originally, this context was used only to pass
in dependencies to be used via `useKibana`. Over time this changed a bit
and we started passing in other non-changing values, the naming change
now reflects that more properly and brings the name in line with the
other context related vars like `AiopsAppContext.Provider` and
`useAiopsAppContext`.

### Checklist

- [ ] [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)

(cherry picked from commit ae36dd5)
@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 7, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] AIOps: Cleanup context/embeddingOrigin
(#194442)](#194442)

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

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

<!--BACKPORT [{"author":{"name":"Walter
Rafelsberger","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-07T15:32:18Z","message":"[ML]
AIOps: Cleanup context/embeddingOrigin (#194442)\n\n##
Summary\r\n\r\nPart of #187772.\r\n\r\nWe had a mix of passing around
`embeddingOrigin` via props and context.\r\nThis PR cleans this up,
`embeddingOrigin` is now be required to be\r\npassed in on the outer
most component and will then be used internally\r\nvia context
only.\r\n\r\nThe PR also renames references to `AppDependencies`
to\r\n`AiopsAppContextValue`. Originally, this context was used only to
pass\r\nin dependencies to be used via `useKibana`. Over time this
changed a bit\r\nand we started passing in other non-changing values,
the naming change\r\nnow reflects that more properly and brings the name
in line with the\r\nother context related vars like
`AiopsAppContext.Provider` and\r\n`useAiopsAppContext`.\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ae36dd5bf2713cafc2e5eaa73629612686842c1a","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","Feature:ML/AIOps","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0","backport:version"],"title":"[ML]
AIOps: Cleanup
context/embeddingOrigin","number":194442,"url":"https://github.com/elastic/kibana/pull/194442","mergeCommit":{"message":"[ML]
AIOps: Cleanup context/embeddingOrigin (#194442)\n\n##
Summary\r\n\r\nPart of #187772.\r\n\r\nWe had a mix of passing around
`embeddingOrigin` via props and context.\r\nThis PR cleans this up,
`embeddingOrigin` is now be required to be\r\npassed in on the outer
most component and will then be used internally\r\nvia context
only.\r\n\r\nThe PR also renames references to `AppDependencies`
to\r\n`AiopsAppContextValue`. Originally, this context was used only to
pass\r\nin dependencies to be used via `useKibana`. Over time this
changed a bit\r\nand we started passing in other non-changing values,
the naming change\r\nnow reflects that more properly and brings the name
in line with the\r\nother context related vars like
`AiopsAppContext.Provider` and\r\n`useAiopsAppContext`.\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ae36dd5bf2713cafc2e5eaa73629612686842c1a"}},"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/194442","number":194442,"mergeCommit":{"message":"[ML]
AIOps: Cleanup context/embeddingOrigin (#194442)\n\n##
Summary\r\n\r\nPart of #187772.\r\n\r\nWe had a mix of passing around
`embeddingOrigin` via props and context.\r\nThis PR cleans this up,
`embeddingOrigin` is now be required to be\r\npassed in on the outer
most component and will then be used internally\r\nvia context
only.\r\n\r\nThe PR also renames references to `AppDependencies`
to\r\n`AiopsAppContextValue`. Originally, this context was used only to
pass\r\nin dependencies to be used via `useKibana`. Over time this
changed a bit\r\nand we started passing in other non-changing values,
the naming change\r\nnow reflects that more properly and brings the name
in line with the\r\nother context related vars like
`AiopsAppContext.Provider` and\r\n`useAiopsAppContext`.\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ae36dd5bf2713cafc2e5eaa73629612686842c1a"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Walter Rafelsberger <[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 ci:project-deploy-observability Create an Observability project Feature:ML/AIOps ML AIOps features: Change Point Detection, Log Pattern Analysis, Log Rate Analysis :ml release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants