Skip to content

Conversation

joshpalis
Copy link
Member

Description

  • Adds field validation for QueryPlanningTool field search_templates to require both template_id and template_description
  • Adds null check for StoredScript response, defaults to default search template if script response is null
  • Adds integration tests for Search template field

Additionally includes changes from #4176, will rebase once its merged

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • [] API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

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.

@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:00 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:00 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:00 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:00 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:02 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:02 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:02 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:02 — with GitHub Actions Waiting
private static final String DEFAULT_SYSTEM_PROMPT =
"You are an OpenSearch Query DSL generation assistant, translating natural language questions to OpenSeach DSL Queries";

private static final Logger logger = LogManager.getLogger(QueryPlanningTool.class);
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you use the same logger like the rest of the repo?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ill remove the logger, left over from debugging

private void validateTemplateFields(Map<String, String> template) {
// Validate templateId
String templateId = template.get(TEMPLATE_ID_FIELD);
if (templateId == null || templateId.trim().isEmpty()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it the same validation of search template or similar to opensearch core?

Copy link
Member Author

Choose a reason for hiding this comment

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

This validation is specifically for the query planning tool configuration, it ensures that each entry of the search_templates field contains both template_id and template_description

@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:13 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:13 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:13 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 17, 2025 21:13 — with GitHub Actions Waiting

// Validate templateDescription
String templateDescription = template.get(TEMPLATE_DESCRIPTION_FIELD);
if (templateDescription == null || templateDescription.trim().isEmpty()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we use .isBlank() instead of .trim().isEmpty()
isBalnk() is more efficient

Comment on lines 71 to 73
zipArchive("org.opensearch.plugin:opensearch-job-scheduler:${opensearch_build}")
zipArchive("org.opensearch.plugin:opensearch-knn:${opensearch_build}")
zipArchive("org.opensearch.plugin:neural-search:${opensearch_build}")
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 remove these?

Copy link
Member Author

Choose a reason for hiding this comment

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

ah yeah, left over from debugging, Ill remove in the next commit

Comment on lines 264 to 285
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return configurations.zipArchive.asFileTree.matching{include "**/opensearch-knn-${opensearch_build}.zip"}.getSingleFile()
}
}
}
}))
plugin(provider(new Callable<RegularFile>(){
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return configurations.zipArchive.asFileTree.matching{include "**/neural-search-${opensearch_build}.zip"}.getSingleFile()
}
}
}
}))
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 remove these too

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to have these plugins in the integTest setup?

Copy link
Member Author

Choose a reason for hiding this comment

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

will do

… tests

Signed-off-by: Joshua Palis <jpalis@amazon.com>
@joshpalis joshpalis temporarily deployed to ml-commons-cicd-env-require-approval September 17, 2025 23:58 — with GitHub Actions Inactive
@joshpalis joshpalis temporarily deployed to ml-commons-cicd-env-require-approval September 17, 2025 23:58 — with GitHub Actions Inactive
@joshpalis joshpalis temporarily deployed to ml-commons-cicd-env-require-approval September 17, 2025 23:58 — with GitHub Actions Inactive
@joshpalis joshpalis temporarily deployed to ml-commons-cicd-env-require-approval September 17, 2025 23:58 — with GitHub Actions Inactive
Copy link
Contributor

@rithin-pullela-aws rithin-pullela-aws left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 47.36842% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.00%. Comparing base (7bf4b54) to head (c32fbe4).

Files with missing lines Patch % Lines
.../opensearch/ml/engine/tools/QueryPlanningTool.java 47.36% 6 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #4177      +/-   ##
============================================
- Coverage     82.02%   82.00%   -0.03%     
+ Complexity     9195     9193       -2     
============================================
  Files           789      789              
  Lines         39541    39557      +16     
  Branches       4387     4390       +3     
============================================
+ Hits          32432    32437       +5     
- Misses         5219     5228       +9     
- Partials       1890     1892       +2     
Flag Coverage Δ
ml-commons 82.00% <47.36%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 18, 2025 18:05 — with GitHub Actions Waiting
@joshpalis joshpalis requested a deployment to ml-commons-cicd-env-require-approval September 18, 2025 18:05 — with GitHub Actions Waiting
mingshl
mingshl previously approved these changes Sep 18, 2025
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 18, 2025 23:21 — with GitHub Actions Error
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 18, 2025 23:21 — with GitHub Actions Failure
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 18, 2025 23:21 — with GitHub Actions Error
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 18, 2025 23:21 — with GitHub Actions Failure
ylwu-amzn
ylwu-amzn previously approved these changes Sep 18, 2025
Signed-off-by: Joshua Palis <jpalis@amazon.com>
@joshpalis joshpalis dismissed stale reviews from ylwu-amzn and mingshl via e33813a September 19, 2025 00:42
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 00:43 — with GitHub Actions Error
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 00:43 — with GitHub Actions Error
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 00:43 — with GitHub Actions Failure
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 00:43 — with GitHub Actions Failure
@joshpalis joshpalis deployed to ml-commons-cicd-env-require-approval September 19, 2025 17:32 — with GitHub Actions Active
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 17:32 — with GitHub Actions Error
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 17:32 — with GitHub Actions Failure
@joshpalis joshpalis had a problem deploying to ml-commons-cicd-env-require-approval September 19, 2025 17:32 — with GitHub Actions Failure
@mingshl
Copy link
Collaborator

mingshl commented Sep 19, 2025

you need to meet the codecov for your if else condition

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

Successfully merging this pull request may close these issues.

5 participants