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 UT and parser for ppl tool #57

Merged
merged 10 commits into from
Dec 26, 2023

Conversation

xinyual
Copy link
Collaborator

@xinyual xinyual commented Dec 25, 2023

Description

Add UT and output parser for PPL tool according to the suggestion from @joshuali925

Issues Resolved

Add UT and output parser for PPL tool

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: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Copy link

codecov bot commented Dec 25, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (7e0ea54) 44.41% compared to head (29deb8c) 82.21%.
Report is 2 commits behind head on main.

❗ Current head 29deb8c differs from pull request most recent head 9ecc0ce. Consider uploading reports for the commit 9ecc0ce to get more accurate results

Files Patch % Lines
.../main/java/org/opensearch/agent/tools/PPLTool.java 84.61% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##               main      #57       +/-   ##
=============================================
+ Coverage     44.41%   82.21%   +37.79%     
- Complexity       30       63       +33     
=============================================
  Files             6        6               
  Lines           358      371       +13     
  Branches         42       45        +3     
=============================================
+ Hits            159      305      +146     
+ Misses          178       37      -141     
- Partials         21       29        +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: xinyual <[email protected]>
// Joining the string back together
ppl = String.join("|", lists);
} else {
ppl = llmOutput;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the ppl still correct when it's missing source=xxx?

Copy link
Collaborator Author

@xinyual xinyual Dec 25, 2023

Choose a reason for hiding this comment

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

No. Should we raise error here? In the current logic, it will raise error when executing if we don't start with source=xxx.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing means invoking the ppl transport action, right? If so, I suggest to raise error here since it's not going to success and we can avoid network communication.

Signed-off-by: xinyual <[email protected]>

private String parseOutput(String llmOutput, String indexName) {
String ppl;
Pattern pattern = Pattern.compile("<ppl>((.|[\\r\\n])+?)</ppl>"); // For ppl like <ppl> source=a \n | fields b </ppl>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can the \\r\\n will match \n? Do we have UT to ensure this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The logic is directly from here: https://github.com/opensearch-project/dashboards-assistant/blob/e6359634ff6f532afa983ae0785bc0cd53aee425/server/olly/chains/ppl_generator.ts#L247

But you are right, I don't have UT to cover this line. Will add one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Already add. It works.

@zane-neo zane-neo merged commit 30e5255 into opensearch-project:main Dec 26, 2023
11 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

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

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/skills/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/skills/backport-2.x
# Create a new branch
git switch --create backport-57-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 30e52554d4f5a0b9c80ebcc93bed5091a221f6c9
# Push it to GitHub
git push --set-upstream origin backport-57-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/skills/backport-2.x

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants