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

[Automatic Import] Prepare to support more connectors #191278

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

P1llus
Copy link
Member

@P1llus P1llus commented Aug 26, 2024

This PR does not add any functionality, it adds interfaces to the expected parameters from get*Graph and its graph nodes.
This is so it will be much easier extend this later when we might need to add/switch types over a whole graph like we would have needed when adding more connectors.

The PR touches a lot of files, but does not add/remove/change any functionality at all, and the current expected function arguments are the same, just the format is a bit different to better align with how other plugins are doing it.

@P1llus P1llus added enhancement New value added to drive a business result release_note:skip Skip the PR/issue when compiling release notes Team:Security-Scalability Team label for Security Integrations Scalability Team backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Aug 26, 2024
@P1llus P1llus changed the title add param types to all graphs, preparing for supporting more connectors [Automatic Import] Prepare to support more connectors Aug 26, 2024
@P1llus P1llus marked this pull request as ready for review August 26, 2024 13:55
@P1llus P1llus requested a review from a team as a code owner August 26, 2024 13:55
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-scalability (Team:Security-Scalability)

Copy link
Contributor

@bhapas bhapas left a comment

Choose a reason for hiding this comment

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

Looks good. Just some questions

}

export interface CategorizationNodeParams extends CategorizationBaseNodeParams {
model: ChatModels;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not do it other way? Like

export interface BaseNodeParams {
  model: ChatModels;
}

export interface CategorizationNodeParams extends BaseNodeParams {
    state: CategorizationState;
}

And reuse BaseNodeParams in all graphs

Copy link
Member Author

Choose a reason for hiding this comment

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

We could yeah, however the issue with abstraction is that you would leave it very hard to perform changes on just one graph that might be model related etc.
At that point we start making a type that extends BaseNodeParams only for that graph, and later another one might appear etc.

I don't mind moving BaseNodeParams up to /server/types.ts, and reuse it for all the graphs, but we should be careful to not push the abstractions too wide, as it always makes changes later messier.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah... Just seen that state is being used alone and not model... So no point abstracting model.

Probably we leave it this way to be consistent and not make it complex

}

export interface CategorizationGraphParams {
model: ChatModels;
Copy link
Contributor

Choose a reason for hiding this comment

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

And model can be reused from BaseNodeParams

Copy link
Member Author

Choose a reason for hiding this comment

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

As long as we do not want to separate graph compilation parameters we could reuse that yes, I don't have a strong opinion on this one.

@@ -19,7 +16,7 @@ import { handleMissingKeys } from './missing';
import { handleValidateMappings } from './validate';
import { graphState } from './state';

const handleCreateMappingChunks = async (state: EcsMappingState) => {
const handleCreateMappingChunks = async ({ state }: EcsBaseNodeParams) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we plan to extend the Params apart from state? Else we dan directly use EcsMappingState right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we not want to keep that consistent over all the nodes for now? It is in theory using EcsMapping state right now, just with the interface name?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah , we do want to have it consistent. But was thinking did we miss anything to pass in other nodes?

Copy link
Contributor

@ilyannn ilyannn left a comment

Choose a reason for hiding this comment

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

LGTM

try {
response = await ecsGraph.invoke(mockedRequest);
} catch (error) {
throw Error(`getEcsGraph threw an error: ${error}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really benefit from catching an error if we immediately rethrow?

Copy link
Member Author

@P1llus P1llus Aug 26, 2024

Choose a reason for hiding this comment

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

Tbh this one was a bit weird, because we had some references to the fail function rather than throwing, however jest does not recognise fail anymore, and if I ignore the catch and just //noop, then it sometimes ignores or hides the errors I am looking for (so I end up having to log the error by making a similar change each time I want to debug), so this time I just kept it in, I can remove it though if it did not make sense.

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

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

Copy link
Contributor

@bhapas bhapas left a comment

Choose a reason for hiding this comment

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

LGTM

@P1llus P1llus merged commit 791f638 into elastic:main Aug 26, 2024
32 checks passed
@P1llus P1llus added backport:skip This commit does not require backporting and removed backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.16.0 labels Aug 26, 2024
@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
8.15 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 191278

Questions ?

Please refer to the Backport tool documentation

@P1llus P1llus added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.15.1 and removed backport:skip This commit does not require backporting labels Aug 27, 2024
P1llus added a commit to P1llus/kibana that referenced this pull request Aug 27, 2024
This PR does not add any functionality, it adds interfaces to the
expected parameters from get*Graph and its graph nodes.
This is so it will be much easier extend this later when we might need
to add/switch types over a whole graph like we would have needed when
adding more connectors.

The PR touches a lot of files, but does not add/remove/change any
functionality at all, and the current expected function arguments are
the same, just the format is a bit different to better align with how
other plugins are doing it.

- [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.

(cherry picked from commit 791f638)
@P1llus
Copy link
Member Author

P1llus commented Aug 27, 2024

💚 All backports created successfully

Status Branch Result
8.15

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 27, 2024
This PR does not add any functionality, it adds interfaces to the
expected parameters from get*Graph and its graph nodes.
This is so it will be much easier extend this later when we might need
to add/switch types over a whole graph like we would have needed when
adding more connectors.

The PR touches a lot of files, but does not add/remove/change any
functionality at all, and the current expected function arguments are
the same, just the format is a bit different to better align with how
other plugins are doing it.

- [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.

(cherry picked from commit 791f638)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.15

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

P1llus added a commit that referenced this pull request Aug 27, 2024
#191525)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Automatic Import] Prepare to support more connectors
(#191278)](#191278)

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

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

<!--BACKPORT [{"author":{"name":"Marius
Iversen","email":"marius.iversen@elastic.co"},"sourceCommit":{"committedDate":"2024-08-26T17:29:30Z","message":"[Automatic
Import] Prepare to support more connectors (#191278)\n\nThis PR does not
add any functionality, it adds interfaces to the\nexpected parameters
from get*Graph and its graph nodes.\nThis is so it will be much easier
extend this later when we might need\nto add/switch types over a whole
graph like we would have needed when\nadding more connectors.\n\nThe PR
touches a lot of files, but does not add/remove/change
any\nfunctionality at all, and the current expected function arguments
are\nthe same, just the format is a bit different to better align with
how\nother plugins are doing it.\n\n\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios.","sha":"791f638823820e8c8cc5af31e56a4f0875356dc9","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["enhancement","release_note:skip","backport:prev-minor","v8.16.0","Team:Security-Scalability","v8.15.1"],"title":"[Automatic
Import] Prepare to support more
connectors","number":191278,"url":"https://github.com/elastic/kibana/pull/191278","mergeCommit":{"message":"[Automatic
Import] Prepare to support more connectors (#191278)\n\nThis PR does not
add any functionality, it adds interfaces to the\nexpected parameters
from get*Graph and its graph nodes.\nThis is so it will be much easier
extend this later when we might need\nto add/switch types over a whole
graph like we would have needed when\nadding more connectors.\n\nThe PR
touches a lot of files, but does not add/remove/change
any\nfunctionality at all, and the current expected function arguments
are\nthe same, just the format is a bit different to better align with
how\nother plugins are doing it.\n\n\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios.","sha":"791f638823820e8c8cc5af31e56a4f0875356dc9"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191278","number":191278,"mergeCommit":{"message":"[Automatic
Import] Prepare to support more connectors (#191278)\n\nThis PR does not
add any functionality, it adds interfaces to the\nexpected parameters
from get*Graph and its graph nodes.\nThis is so it will be much easier
extend this later when we might need\nto add/switch types over a whole
graph like we would have needed when\nadding more connectors.\n\nThe PR
touches a lot of files, but does not add/remove/change
any\nfunctionality at all, and the current expected function arguments
are\nthe same, just the format is a bit different to better align with
how\nother plugins are doing it.\n\n\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios.","sha":"791f638823820e8c8cc5af31e56a4f0875356dc9"}},{"branch":"8.15","label":"v8.15.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Marius Iversen <marius.iversen@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) enhancement New value added to drive a business result release_note:skip Skip the PR/issue when compiling release notes Team:Security-Scalability Team label for Security Integrations Scalability Team v8.15.1 v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants