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

Enhance batch job task management by adding default action types #3080

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

rbhavna
Copy link
Collaborator

@rbhavna rbhavna commented Oct 8, 2024

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

  • 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.

@Zhangxunmt
Copy link
Collaborator

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";


Copy link
Collaborator

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);
Copy link
Collaborator

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";
Copy link
Collaborator

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"))
Copy link
Collaborator

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) {
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 need same method 2 times?

Copy link
Collaborator Author

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]>
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env October 9, 2024 20:35 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env October 9, 2024 20:35 — with GitHub Actions Inactive
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env October 9, 2024 21:34 — with GitHub Actions Inactive
Comment on lines +343 to +359
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;
Copy link
Collaborator

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".

Copy link
Collaborator Author

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

Comment on lines +66 to +68
public static final List<String> SUPPORTED_REMOTE_SERVERS_FOR_DEFAULT_ACTION_TYPES = List
.of("sagemaker", "openai", "bedrock", "cohere");

Copy link
Collaborator

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?

Copy link
Collaborator Author

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]>
@rbhavna rbhavna temporarily deployed to ml-commons-cicd-env October 9, 2024 22:05 — with GitHub Actions Inactive
@rbhavna rbhavna had a problem deploying to ml-commons-cicd-env October 9, 2024 22:05 — with GitHub Actions Failure
@rbhavna rbhavna merged commit ff6fe67 into opensearch-project:main Oct 9, 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-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 base branch is 2.x and the compare/head branch is backport/backport-3080-to-2.x.

@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.17 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.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 base branch is 2.17 and the compare/head branch is backport/backport-3080-to-2.17.

rbhavna added a commit to rbhavna/ml-commons that referenced this pull request Oct 9, 2024
…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)
rbhavna added a commit to rbhavna/ml-commons that referenced this pull request Oct 9, 2024
…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)
rbhavna added a commit that referenced this pull request Oct 10, 2024
…) (#3086)

* enhance batch job task management by adding default action types

Signed-off-by: Bhavana Ramaram <[email protected]>
(cherry picked from commit ff6fe67)
rbhavna added a commit that referenced this pull request Oct 10, 2024
…) (#3085)

* enhance batch job task management by adding default action types

Signed-off-by: Bhavana Ramaram <[email protected]>
(cherry picked from commit ff6fe67)
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