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] Adding type for job summary state #131643

Merged

Conversation

jgowdyelastic
Copy link
Member

@jgowdyelastic jgowdyelastic commented May 5, 2022

Fixes a potential bug in Logs UI where jobs in a deleting, resetting and reverting state will cause an error.

Closes #130258

Also removes the translation of the jobState values deleting, resetting and reverting. These were being incorrectly combined with the job state from es, which is not translated.
So now deleting, resetting and reverting will always appear in english in the UI along with other job states, like closed opening etc

@jgowdyelastic jgowdyelastic self-assigned this May 5, 2022
@jgowdyelastic jgowdyelastic added bug Fixes for quality problems that affect the customer experience non-issue Indicates to automation that a pull request should not appear in the release notes release_note:fix :ml Feature:Anomaly Detection ML anomaly detection v8.3.0 labels May 5, 2022
@jgowdyelastic jgowdyelastic marked this pull request as ready for review May 5, 2022 19:51
@jgowdyelastic jgowdyelastic requested a review from a team as a code owner May 5, 2022 19:51
@elasticmachine
Copy link
Contributor

Pinging @elastic/ml-ui (:ml)

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.

Code LGTM

@jgowdyelastic jgowdyelastic removed the non-issue Indicates to automation that a pull request should not appear in the release notes label May 6, 2022
@jgowdyelastic jgowdyelastic requested a review from a team as a code owner May 6, 2022 14:24
Copy link
Contributor

@alvarezmelissa87 alvarezmelissa87 left a comment

Choose a reason for hiding this comment

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

LGTM ⚡

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
ml 79 81 +2

Any counts in public APIs

Total count of every any typed public API. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats any for more detailed information.

id before after diff
ml 8 10 +2

Async chunks

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

id before after diff
ml 3.3MB 3.3MB -5.0B
securitySolution 4.8MB 4.8MB +6.0B
total +1.0B

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
kibana 335 336 +1
ml 30 31 +1
total +2
Unknown metric groups

API count

id before after diff
ml 198 254 +56

History

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

cc @jgowdyelastic

Copy link
Contributor

@banderror banderror left a comment

Choose a reason for hiding this comment

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

Security Solution changes LGTM 👍

The only nitpicky thing I noticed that could be improved: the type of jobState could be adjusted in x-pack/plugins/security_solution/common/machine_learning/helpers.ts as well:

// Based on ML Job/Datafeed States from x-pack/legacy/plugins/ml/common/constants/states.js
const enabledStates = ['started', 'opened'];
const loadingStates = ['starting', 'stopping', 'opening', 'closing'];
const failureStates = ['deleted', 'failed'];

export const isJobStarted = (jobState: string, datafeedState: string): boolean => {
  return enabledStates.includes(jobState) && enabledStates.includes(datafeedState);
};

export const isJobLoading = (jobState: string, datafeedState: string): boolean => {
  return loadingStates.includes(jobState) || loadingStates.includes(datafeedState);
};

export const isJobFailed = (jobState: string, datafeedState: string): boolean => {
  return failureStates.includes(jobState) || failureStates.includes(datafeedState);
};

@banderror apologies, I hit merge before noticing this comment.
I think we need an audit of all plugins which are using our types and jobs to see how they are being used. The logs UI is in a similar situation where the code was written before we were doing a good job of exporting types.

@jgowdyelastic jgowdyelastic merged commit 1dc6216 into elastic:main May 11, 2022
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 11, 2022
academo pushed a commit to academo/kibana that referenced this pull request May 12, 2022
* [ML] Adding type for job summary state

* renaming type

* translations

* fixing jobState types in security

* fixing snapshots

* fixing test
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 bug Fixes for quality problems that affect the customer experience Feature:Anomaly Detection ML anomaly detection :ml release_note:fix v8.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML] Add type for job summary jobState
7 participants