-
Notifications
You must be signed in to change notification settings - Fork 149
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
[Enhancement] Enhance validation for create connector API #3579
base: main
Are you sure you want to change the base?
[Enhancement] Enhance validation for create connector API #3579
Conversation
common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java
Outdated
Show resolved
Hide resolved
common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java
Outdated
Show resolved
Hide resolved
common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java
Show resolved
Hide resolved
common/src/main/java/org/opensearch/ml/common/connector/HttpConnector.java
Show resolved
Hide resolved
Can anyone trigger the failed test suite once more, failure doesn't have any relation with changes. |
This change will address the second part of validation "pre and post processing function validation". Partially resolves opensearch-project#2993 Signed-off-by: Abdul Muneer Kolarkunnu <[email protected]>
@zane-neo Can you please look in o these two failures, my changes around prepostProcessFunctions:
I am not able to reproduce and debug these failures locally because of below dependencies: The AWS credentials are not set. Skipping test.COHERE_KEY is null, skipping the test! |
Please rebase the latest code on main branch, this has been fixed. |
linux (23) - Known flaky org.opensearch.ml.rest.RestMLRemoteInferenceIT.testPredictWithAutoDeployAndTTL_RemoteModel #3544 linux (21) - There are no real failures Windows (21) - org.opensearch.ml.rest.RestMLRAGSearchProcessorIT.testBM25WithBedrockConverse - not related the code changes |
Hi Maintainers, Please help to move forward this task. |
Hi @akolarkunnu, let me review this PR and test out some of the changes. In the meanwhile, the maintainers can help re-trigger the CI and we can check if it goes through? Thanks for the fix and sharing the test details! |
...ithms/src/test/java/org/opensearch/ml/engine/algorithms/remote/AwsConnectorExecutorTest.java
Show resolved
Hide resolved
common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java
Outdated
Show resolved
Hide resolved
common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java
Outdated
Show resolved
Hide resolved
common/src/main/java/org/opensearch/ml/common/connector/ConnectorAction.java
Outdated
Show resolved
Hide resolved
This change will address the second part of validation "pre and post processing function validation". Partially resolves opensearch-project#2993 Signed-off-by: Abdul Muneer Kolarkunnu <[email protected]>
Please approve for CI - "Waiting for review: ml-commons-cicd-env-require-approval needs approval to start deploying changes." |
Hi Maintainers, @pyek-bot Please approve to run CI. |
} | ||
switch (remoteServer) { | ||
case OPENAI: | ||
if (!preProcessFunction.contains(OPENAI)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit confused with the latest change, so now the only validation is if the preProcessFunction contains "openai" as opposed to "connector.post_process.default.embedding"? so this in theory a more lenient validation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I did that change based on your previous comment - "thinking if for these constants we can create the string using the INBUILT_FUNC_PREFIX? and maybe even have preprocessprefix and postprocessprefix? this can avoid any accidental changes "
I can see only that's the only(eg: openai, bedrock, cohere) unique text in the function names which we can defer for different llm services.
Or you meant something differently ? Creating different constant arrays for each llm service post and pre Process Functions ? So in this case we will have 8 arrays, 4 (openai, bedrock, cohere, sagemaker) for pre process functions and 4 for post process functions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there has been a confusion: #3579 (comment)
In this comment, I meant that we should create the constants as such:
MLPostProcessFunction.OPENAI_EMBEDDING = INBUILT_FUNC_PREFIX + "openai.embedding" + ACTION_POST_PROCESS_FUNCTION*
*just an example may not be fully code accurate
This way if either of these constants change, we don't have to change the code. With respect to whether the check should be lenient or not we can wait on more comments.
@@ -185,6 +198,90 @@ public static ConnectorAction parse(XContentParser parser) throws IOException { | |||
.build(); | |||
} | |||
|
|||
public void validatePrePostProcessFunctions(Map<String, String> parameters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we please add java doc with more detailed explanations.
validatePostProcessFunctions(remoteServer); | ||
} | ||
|
||
private void validatePreProcessFunctions(String remoteServer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's organize the private methods in the order it was being invoked.getRemoteServerFromURL
and then validatePreProcessFunctions
. Its easy to read for reviewers.
StringSubstitutor substitutor = new StringSubstitutor(parameters, "${parameters.", "}"); | ||
String endPoint = substitutor.replace(url); | ||
String remoteServer = getRemoteServerFromURL(endPoint); | ||
validatePreProcessFunctions(remoteServer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isInBuiltProcessFunction(preProcessFunction)) then we can invoke validatePreProcessFunctions?
@@ -62,6 +85,257 @@ public void constructor_NullMethod() { | |||
assertEquals("method can't be null", exception.getMessage()); | |||
} | |||
|
|||
@Test | |||
public void connectorWithNullPreProcessFunction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's rename the unit tests. The name doesn't quite reflect the intent of the test. Same applies for other methods as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more clear Your test name should answer three things:
What is being tested? (method or scenario)
Under what conditions? (input or setup)
What is the expected outcome?
Description
This change will address the second part of validation "pre and post processing function validation".
Moved the method getRemoteServerFromURL() from ConnectorUtils.java to ConnectorAction.java, to avoid the cyclic dependency
Related Issues
Partially resolves #2993
Check List
--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.