-
Notifications
You must be signed in to change notification settings - Fork 131
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
Enhance batch job task management by adding default action types #3080
Enhance batch job task management by adding default action types #3080
Conversation
Signed-off-by: Bhavana Ramaram <[email protected]>
LGTM overall. Please apply spotLess and add UT coverages to pass CI. Also please define createConnectorAction() in the Util class so it can be shared across multiple classes. |
@@ -36,6 +37,7 @@ public class ConnectorAction implements ToXContentObject, Writeable { | |||
public static final String ACTION_PRE_PROCESS_FUNCTION = "pre_process_function"; | |||
public static final String ACTION_POST_PROCESS_FUNCTION = "post_process_function"; | |||
|
|||
|
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.
No need to add this empty line.
@@ -65,6 +65,8 @@ public interface Connector extends ToXContentObject, Writeable { | |||
|
|||
List<ConnectorAction> getActions(); | |||
|
|||
void setAction(ConnectorAction action); |
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.
Using addAction as the name is more accurate?
@@ -29,9 +30,11 @@ public class MLPredictionOutput extends MLOutput { | |||
public static final String TASK_ID_FIELD = "task_id"; | |||
public static final String STATUS_FIELD = "status"; | |||
public static final String PREDICTION_RESULT_FIELD = "prediction_result"; | |||
public static final String REMOTE_JOB_FIELD = "remote_job"; |
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 add a comment about this field.
} | ||
|
||
private String getEndpointType(String url) { | ||
if (url.contains("sagemaker")) |
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 make static variables for all these values and then re-use?
|
||
} | ||
|
||
private String getEndpointType(String url) { |
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.
why do we need same method 2 times?
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 will be moving the common methods to ConnectorUtils class
Signed-off-by: Bhavana Ramaram <[email protected]>
Signed-off-by: Bhavana Ramaram <[email protected]>
case "sagemaker": | ||
url = isCancelAction | ||
? predictEndpoint.replace("CreateTransformJob", "StopTransformJob") | ||
: predictEndpoint.replace("CreateTransformJob", "DescribeTransformJob"); | ||
requestBody = "{ \"TransformJobName\" : \"${parameters.TransformJobName}\"}"; | ||
break; | ||
case "openai": | ||
case "cohere": | ||
url = isCancelAction ? predictEndpoint + "/${parameters.id}/cancel" : predictEndpoint + "/${parameters.id}"; | ||
method = isCancelAction ? "POST" : "GET"; | ||
break; | ||
case "bedrock": | ||
url = isCancelAction | ||
? predictEndpoint + "/${parameters.processedJobArn}/stop" | ||
: predictEndpoint + "/${parameters.processedJobArn}"; | ||
method = isCancelAction ? "POST" : "GET"; | ||
break; |
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.
We should add the default branch for this switch statement to return null. In the GetTask and CancelTask, if the ConnectorAction is null, throw an exception with meaning logs like "please provide GetTask/CancelTask action in the connector".
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.
oh sorry I added it but I guess it got missed during refactoring. Let me add it
public static final List<String> SUPPORTED_REMOTE_SERVERS_FOR_DEFAULT_ACTION_TYPES = List | ||
.of("sagemaker", "openai", "bedrock", "cohere"); | ||
|
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.
Ideally if a new platform is used but not listed here, CX should still be able to GetTask and CancelTask by manually adding the actions in the connector. But seems this is not the case in this PR?
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 if the connector already has the actions configured, then they can get/cancel task for any platform. Only if no action is provided, they we perform this check
Signed-off-by: Bhavana Ramaram <[email protected]>
The backport to
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-3080-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ff6fe67b6b913b8c746faac04fc7e2f2b5d184e7
# Push it to GitHub
git push --set-upstream origin backport/backport-3080-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 |
The backport to
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.17 2.17
# Navigate to the new working tree
cd .worktrees/backport-2.17
# Create a new branch
git switch --create backport/backport-3080-to-2.17
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 ff6fe67b6b913b8c746faac04fc7e2f2b5d184e7
# Push it to GitHub
git push --set-upstream origin backport/backport-3080-to-2.17
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.17 Then, create a pull request where the |
…nsearch-project#3080) * enhance batch job task management by adding default action types Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit ff6fe67)
…nsearch-project#3080) * enhance batch job task management by adding default action types Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit ff6fe67)
…) (#3086) * enhance batch job task management by adding default action types Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit ff6fe67)
…) (#3085) * enhance batch job task management by adding default action types Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit ff6fe67)
Description
Enhance batch job task management by adding default action types
TODO: add test coverage to changes in this PR
Related Issues
Resolves #[Issue number to be closed when this PR is merged]
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.