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

[8.6][ML Inference] Add ML inference failure handler #142488

Merged

Conversation

demjened
Copy link
Contributor

@demjened demjened commented Oct 3, 2022

Summary

Parent issue: https://github.com/elastic/enterprise-search-team/issues/2680

This PR adds a default failure handler to Machine Learning Inference pipelines, specifically the inference processor. As a result, any errors occurring during ML inference are caught and appended to the _ingest.inference_errors array as a rich object. This will help surface issues to the UI.

Sample:

"_ingest": {
    "inference_errors": [
        {
            "pipeline": "ml-inference-my-ner-inference-pipeline",
            "message": "Processor 'inference' in pipeline 'ml-inference-my-ner-inference-pipeline' failed with message 'Trained model [philschmid__distilroberta-base-ner-conll2003] is not deployed.'",
            "timestamp": "2022-10-03T14:58:13.757978680Z"
        },
        {
            "pipeline": "ml-inference-my-text-embedding-pipeline",
            "message": "Processor 'inference' in pipeline 'ml-inference-my-text-embedding-pipeline' failed with message 'Input field [text_field] does not exist in the source document'",
            "timestamp": "2022-10-03T14:58:13.757978680Z"
        }
    ],
    (...)
}

Checklist

Delete any items that are not applicable to this PR.

demjened and others added 30 commits September 13, 2022 13:47
Comment on lines 176 to 188
expect(actualResult).toEqual(
expect.objectContaining({
processors: expect.arrayContaining([
{
inference: expect.objectContaining({
field_map: {
[sourceField]: modelInputField,
},
}),
},
]),
})
);
Copy link
Contributor Author

@demjened demjened Oct 3, 2022

Choose a reason for hiding this comment

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

I think it's unnecessary code duplication that we check the entire result object here - this is already covered in the "should return the pipeline body" test case. I modified the test to only look for the field that is different under the actual conditions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Good to know about these expcet.*Containing functions 👍

Copy link
Member

Choose a reason for hiding this comment

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

While it is quite easy to do unwanted side effects, we usually do a full object checks especially for the Redux/Kea states to make sure we only change the part where we want to change. I am curious if that would be useful here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, good point Efe. I'll update the code to work with full objects and assign() the modified part that the test is focusing on.

Copy link
Member

Choose a reason for hiding this comment

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

You can use destructuring as well.

i.e.

{
  ...EXPECTED_DEFAULTS,
  only: {
    the_changed: "parts"
  }
}

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 ended up using lodash merge() since destructuring didn't work for changing a single array element's specific property while leaving everything else untouched. (Or maybe I just don't know how to do it 🙂)

@demjened demjened changed the title Demjened/add ml inference failure handler [8.6][ML Inference] Add ML inference failure handler Oct 3, 2022
value: [
{
pipeline: pipelineName,
message: `Processor 'inference' in pipeline '${pipelineName}' failed with message '{{ _ingest.on_failure_message }}'`,
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 named this property message instead of error to make it semantically more extensible (e.g. for warnings).

@demjened demjened requested a review from tsclausing October 3, 2022 17:53
@demjened demjened marked this pull request as ready for review October 3, 2022 17:53
@demjened demjened requested a review from a team October 3, 2022 17:53
@brianmcgue brianmcgue added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Oct 3, 2022
Comment on lines 176 to 188
expect(actualResult).toEqual(
expect.objectContaining({
processors: expect.arrayContaining([
{
inference: expect.objectContaining({
field_map: {
[sourceField]: modelInputField,
},
}),
},
]),
})
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. Good to know about these expcet.*Containing functions 👍

@demjened demjened force-pushed the demjened/add-ml-inference-failure-handler branch from 17f3132 to 4e7f645 Compare October 4, 2022 14:29
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
enterpriseSearch 1.7MB 1.7MB +230.0B

History

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

@demjened demjened merged commit 524363d into elastic:main Oct 4, 2022
@demjened demjened deleted the demjened/add-ml-inference-failure-handler branch October 4, 2022 15:48
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this pull request Oct 11, 2022
WafaaNasr pushed a commit to WafaaNasr/kibana that referenced this pull request Oct 14, 2022
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 release_note:skip Skip the PR/issue when compiling release notes Team:EnterpriseSearch v8.6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants