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

add initial MLInferenceSearchResponseProcessor #2688

Merged

Conversation

mingshl
Copy link
Collaborator

@mingshl mingshl commented Jul 20, 2024

Description

add initial MLInferenceSearchResponseProcessor

this PR only support collecting many document field in a list to add in one prediction call.

The one document to one prediction call will add incrementally in a next PR

Issues Resolved

#2173
#2444

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Mingshi Liu <[email protected]>
@mingshl mingshl force-pushed the main-search-response-mingshl-draft branch from 7438c2d to cc56fc4 Compare July 23, 2024 05:19
@mingshl mingshl had a problem deploying to ml-commons-cicd-env July 23, 2024 05:19 — with GitHub Actions Failure
@mingshl mingshl had a problem deploying to ml-commons-cicd-env July 23, 2024 05:20 — with GitHub Actions Failure
Signed-off-by: Mingshi Liu <[email protected]>
@mingshl mingshl had a problem deploying to ml-commons-cicd-env July 23, 2024 19:01 — with GitHub Actions Failure
@mingshl mingshl had a problem deploying to ml-commons-cicd-env July 23, 2024 19:01 — with GitHub Actions Failure
* @param responseListener the listener to be notified when the response is processed
* @throws IOException if an I/O error occurs during the rewriting process
*/
private void rewriteResponseDocuments(SearchResponse response, SearchHit[] hits, ActionListener<SearchResponse> responseListener)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we pass both response and hits? I think response already includes hits.

Copy link
Collaborator Author

@mingshl mingshl Jul 23, 2024

Choose a reason for hiding this comment

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

I need the response here when there is any failure in rewrite, it directly returns the original response

Copy link
Collaborator

Choose a reason for hiding this comment

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

So remove hits? The response has hits.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed!

try {
SearchHit[] hits = response.getHits().getHits();
// skip processing when there is no hit
if (hits.length == 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Check if hits is null first? According to my below comment, maybe
if (response.getHits().getHits() == null || response.getHits().getHits().length == 0),
then
rewriteResponseDocuments(response, responseListener) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

when the hits is null but not empty, it should throw exception and we catch it by ignoreFailure flag, if ignoreFailure is false, it will throw exception accordingly. A valid search response with not matching any document is like this

An empty hit when hits.length == 0, we skip processing the ml inference here.

{
  "took": 45,
  "timed_out": false,
  "_shards": {
    "total": 404,
    "successful": 404,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 0,
      "relation": "eq"
    },
    "max_score": null,
    "hits": []
  }
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

if ignoreFailure is false, it will throw exception accordingly.

So in this case we will show "Null pointer exception" to the customer? Does this sound reasonable to customer to get a null pointer exception and having no clue what exactly happened?

@mingshl
Copy link
Collaborator Author

mingshl commented Jul 24, 2024

resolved merge conflict

Signed-off-by: Mingshi Liu <[email protected]>
@mingshl mingshl temporarily deployed to ml-commons-cicd-env July 24, 2024 18:04 — with GitHub Actions Inactive
@mingshl mingshl had a problem deploying to ml-commons-cicd-env July 24, 2024 18:05 — with GitHub Actions Failure
Signed-off-by: Mingshi Liu <[email protected]>
@mingshl mingshl temporarily deployed to ml-commons-cicd-env July 24, 2024 18:56 — with GitHub Actions Inactive
@mingshl mingshl temporarily deployed to ml-commons-cicd-env July 24, 2024 18:59 — with GitHub Actions Inactive
@mingshl mingshl temporarily deployed to ml-commons-cicd-env July 24, 2024 20:05 — with GitHub Actions Inactive
@mingshl
Copy link
Collaborator Author

mingshl commented Jul 24, 2024

All Build and Test CI passed. can you please approve again? @b4sjoo @Zhangxunmt

@mingshl mingshl merged commit 01084b4 into opensearch-project:main Jul 24, 2024
5 of 6 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2688-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 01084b4a014e1cd355cee3d4f45a986b5001681f
# Push it to GitHub
git push --set-upstream origin backport/backport-2688-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-2688-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.16 failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.16 2.16
# Navigate to the new working tree
cd .worktrees/backport-2.16
# Create a new branch
git switch --create backport/backport-2688-to-2.16
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 01084b4a014e1cd355cee3d4f45a986b5001681f
# Push it to GitHub
git push --set-upstream origin backport/backport-2688-to-2.16
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.16

Then, create a pull request where the base branch is 2.16 and the compare/head branch is backport/backport-2688-to-2.16.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 24, 2024
* add MLInferenceSearchResponseProcessor

Signed-off-by: Mingshi Liu <[email protected]>

* add ITs

Signed-off-by: Mingshi Liu <[email protected]>

* add code coverage

Signed-off-by: Mingshi Liu <[email protected]>

* add many_to_one flag

Signed-off-by: Mingshi Liu <[email protected]>

* avoid import *

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra hits

Signed-off-by: Mingshi Liu <[email protected]>

* spotlessApply

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra brackets

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
(cherry picked from commit 01084b4)
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2688-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 01084b4a014e1cd355cee3d4f45a986b5001681f
# Push it to GitHub
git push --set-upstream origin backport/backport-2688-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-2688-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 24, 2024
* add MLInferenceSearchResponseProcessor

Signed-off-by: Mingshi Liu <[email protected]>

* add ITs

Signed-off-by: Mingshi Liu <[email protected]>

* add code coverage

Signed-off-by: Mingshi Liu <[email protected]>

* add many_to_one flag

Signed-off-by: Mingshi Liu <[email protected]>

* avoid import *

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra hits

Signed-off-by: Mingshi Liu <[email protected]>

* spotlessApply

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra brackets

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
(cherry picked from commit 01084b4)
mingshl added a commit that referenced this pull request Jul 24, 2024
* add initial MLInferenceSearchResponseProcessor (#2688)

* add MLInferenceSearchResponseProcessor

Signed-off-by: Mingshi Liu <[email protected]>

* add ITs

Signed-off-by: Mingshi Liu <[email protected]>

* add code coverage

Signed-off-by: Mingshi Liu <[email protected]>

* add many_to_one flag

Signed-off-by: Mingshi Liu <[email protected]>

* avoid import *

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra hits

Signed-off-by: Mingshi Liu <[email protected]>

* spotlessApply

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra brackets

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
(cherry picked from commit 01084b4)

* fix http package

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
Co-authored-by: Mingshi Liu <[email protected]>
@b4sjoo b4sjoo added the v2.16.0 Issues targeting release v2.16.0 label Jul 26, 2024
b4sjoo pushed a commit that referenced this pull request Jul 26, 2024
* add initial MLInferenceSearchResponseProcessor (#2688)

* add MLInferenceSearchResponseProcessor

Signed-off-by: Mingshi Liu <[email protected]>

* add ITs

Signed-off-by: Mingshi Liu <[email protected]>

* add code coverage

Signed-off-by: Mingshi Liu <[email protected]>

* add many_to_one flag

Signed-off-by: Mingshi Liu <[email protected]>

* avoid import *

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra hits

Signed-off-by: Mingshi Liu <[email protected]>

* spotlessApply

Signed-off-by: Mingshi Liu <[email protected]>

* remove extra brackets

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
(cherry picked from commit 01084b4)

* fix http package

Signed-off-by: Mingshi Liu <[email protected]>

---------

Signed-off-by: Mingshi Liu <[email protected]>
Co-authored-by: Mingshi Liu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport 2.16 v2.16.0 Issues targeting release v2.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants