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

return model id in registering remote model #1329

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

Zhangxunmt
Copy link
Collaborator

@Zhangxunmt Zhangxunmt commented Sep 12, 2023

Description

This change only applies to registering remote models. Registering a remote model doesn't need Asynchronize, it should return model_id right away in the response.

Before this change:
POST /_plugins/_ml/models/_register
{
"name": "openAI-GPT-3.5 completions",
"function_name": "remote",
"description": "test model",
"connector_id": "kUFFL4kB4ubqQRzeQ_r-"
}
Response:
{
"task_id": "l0FIL4kB4ubqQRzeKvpV",
"status": "CREATED"
}

After this change:
POST /_plugins/_ml/models/_register
{
"name": "openAI-GPT-3.5 completions",
"function_name": "remote",
"description": "test model",
"connector_id": "kUFFL4kB4ubqQRzeQ_r-"
}
Response:
{
"task_id": "l0FIL4kB4ubqQRzeKvpV",
"status": "CREATED",
"model_id": "xxxxxxxxxxxxxx",
}

@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 12, 2023 22:31 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 12, 2023 22:31 — with GitHub Actions Inactive
@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Merging #1329 (23c0471) into 2.x (0855241) will decrease coverage by 0.87%.
Report is 1 commits behind head on 2.x.
The diff coverage is 23.77%.

@@             Coverage Diff              @@
##                2.x    #1329      +/-   ##
============================================
- Coverage     79.46%   78.60%   -0.87%     
+ Complexity     2273     2272       -1     
============================================
  Files           190      190              
  Lines          9167     9250      +83     
  Branches        906      909       +3     
============================================
- Hits           7285     7271      -14     
- Misses         1472     1569      +97     
  Partials        410      410              
Flag Coverage Δ
ml-commons 78.60% <23.77%> (-0.87%) ⬇️

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

Files Changed Coverage Δ
...n/java/org/opensearch/ml/model/MLModelManager.java 54.62% <21.84%> (-8.36%) ⬇️
.../action/register/TransportRegisterModelAction.java 96.22% <100.00%> (+0.02%) ⬆️

... and 2 files with indirect coverage changes

@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 12, 2023 23:22 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 12, 2023 23:22 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 17:45 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 17:45 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:08 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:08 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:24 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:24 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:24 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:42 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:42 — with GitHub Actions Inactive
@Zhangxunmt Zhangxunmt temporarily deployed to ml-commons-cicd-env September 13, 2023 18:42 — with GitHub Actions Inactive
Comment on lines 30 to 33
this.taskId = in.readString();
this.status = in.readString();
this.modelId = in.readOptionalString();
}
Copy link
Member

Choose a reason for hiding this comment

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

Feels like a good improvement for remote models, do we really have a taskId which is doing real work for remote models?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, we have a actual task id. It will do some validation work

Copy link
Member

Choose a reason for hiding this comment

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

Curious what kind of validations ?

@@ -249,8 +250,8 @@ private void registerModel(MLRegisterModelInput registerModelInput, ActionListen
mlTaskManager.createMLTask(mlTask, ActionListener.wrap(response -> {
String taskId = response.getId();
mlTask.setTaskId(taskId);
mlModelManager.registerMLModel(registerModelInput, mlTask);
listener.onResponse(new MLRegisterModelResponse(taskId, MLTaskState.CREATED.name()));
System.out.println("mlModelManager calls registerMLRemoteModel");
Copy link
Member

@saratvemulapalli saratvemulapalli Sep 13, 2023

Choose a reason for hiding this comment

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

Nit: Probably unintended?
Same at L236

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! I think I forgot to delete. They will be cleaned up for sure.

@@ -249,8 +250,8 @@ private void registerModel(MLRegisterModelInput registerModelInput, ActionListen
mlTaskManager.createMLTask(mlTask, ActionListener.wrap(response -> {
String taskId = response.getId();
mlTask.setTaskId(taskId);
mlModelManager.registerMLModel(registerModelInput, mlTask);
listener.onResponse(new MLRegisterModelResponse(taskId, MLTaskState.CREATED.name()));
System.out.println("mlModelManager calls registerMLRemoteModel");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we keeping this line?

@@ -233,6 +233,7 @@ private void registerModel(MLRegisterModelInput registerModelInput, ActionListen
throw new IllegalArgumentException("URL can't match trusted url regex");
}
}
System.out.println("registering the model");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we keeping this?

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 avoid using system out print

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 I guarante these redundant lines will be removed in my next PR.

return (int) modelGroupSourceMap.get(MLModelGroup.LATEST_VERSION_FIELD) + 1;
}

private void indexRemoteModel(
Copy link
Collaborator

@dhrubo-os dhrubo-os Sep 13, 2023

Choose a reason for hiding this comment

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

Do we need the other method: private void indexRemoteModel(MLRegisterModelInput registerModelInput, MLTask mlTask, String modelVersion) as we are invoking this method only.

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 it's needed for registering non-remote models. Actually if you use the other method, the model_id will not be included and the model registering could be asynchronize.

);

client.update(updateModelGroupRequest, ActionListener.wrap(r -> {
uploadMLModelMeta(mlRegisterModelMetaInput, updatedVersion + "", listener);
Copy link
Collaborator

@dhrubo-os dhrubo-os Sep 13, 2023

Choose a reason for hiding this comment

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

regarding : updatedVersion + "" if the goal is to convert int to string, may be we can follow standard way like: Integer.toString(updatedVersion)?

mlModelManager.registerMLModel(registerModelInput, mlTask);
listener.onResponse(new MLRegisterModelResponse(taskId, MLTaskState.CREATED.name()));
System.out.println("mlModelManager calls registerMLRemoteModel");
mlModelManager.registerMLRemoteModel(registerModelInput, mlTask, listener);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this the expectation that, only remote model registration will be asynchronous? If yes, can we please add a comment here also?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just the opposite, remote model registration is synchronous only so the model_id can be returned right away. Comments will be added in the next PR.

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.

7 participants