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

the dev of [FEATURE]Auto reload model when cluster rebooted/node rejoin #639

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
3e48e36
Add .whitesource configuration file (#611)
mend-for-github-com[bot] Dec 6, 2022
80aaaa8
Update dependency junit:junit to v4.13.1 (#625)
mend-for-github-com[bot] Dec 6, 2022
b2f18e4
[wjunshen] #ML-Commons Model auto reload feat: add 2 properties about…
wujunshen Dec 9, 2022
a286309
[wjunshen] #ML-Commons Model auto reload feat: code format by spotles…
wujunshen Dec 9, 2022
d3047d6
[wjunshen] #N/A feat: add guava retry 3rd party jar
wujunshen Dec 11, 2022
25b9c36
[wjunshen] #N/A feat: init async method and add retry logic
wujunshen Dec 11, 2022
31735c8
[wjunshen] #N/A feat: add todo comment
wujunshen Dec 11, 2022
d4db55d
[wjunshen] #N/A feat: for loose couple, create new Manager class to i…
wujunshen Dec 12, 2022
c6850b7
[wjunshen] #N/A feat: comment retry part
wujunshen Dec 13, 2022
0df9ac3
[wjunshen] #N/A feat: finish the function: get all loaded model id fr…
wujunshen Dec 13, 2022
4191631
[wjunshen] #N/A feat: finish the function: auto reload model on assig…
wujunshen Dec 13, 2022
c273609
[wjunshen] #N/A feat: new model reload index to stroe retry times and…
wujunshen Dec 16, 2022
9e321c5
[wjunshen] #N/A feat: run spotless.JavaApply task
wujunshen Dec 16, 2022
99b7639
[wjunshen] #N/A feat: add the function "create index"&"insert data"&…
wujunshen Dec 17, 2022
30068b3
[wjunshen] #N/A feat: add the function "create index"&"insert data"&…
wujunshen Dec 21, 2022
7a4b0b8
[wjunshen] #N/A style: rollback MLModelManager.java and build.gradle(…
wujunshen Dec 21, 2022
ae035df
[wjunshen] #N/A feat: modify the code acordding to the zan's opnion
wujunshen Dec 22, 2022
5a50842
[wjunshen] #N/A docs: add java doc under MLModelAutoReloader class
wujunshen Dec 22, 2022
b9cd79f
[wjunshen] #N/A feat: tuning code
wujunshen Dec 22, 2022
01dc262
[wjunshen] #N/A feat: tunning code
wujunshen Dec 22, 2022
507219e
[wjunshen] #N/A test: add IT test code
wujunshen Dec 22, 2022
bb0b5a2
[wjunshen] #N/A fix: for resolve the problems of the check on github
wujunshen Dec 24, 2022
07252eb
[wjunshen] #N/A fix: for resolve the problems of the check on github
wujunshen Dec 24, 2022
c5509cf
[wjunshen] #wjunshen<wjunshen@amazon.com> test: add some test codes
wujunshen Dec 24, 2022
6959fd4
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 24, 2022
7b4465d
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 26, 2022
c22f69d
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 27, 2022
e85d3c4
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 27, 2022
3dc994b
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 27, 2022
fb75bf8
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 27, 2022
d8e3946
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 27, 2022
851e2d7
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 28, 2022
f39385d
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 28, 2022
cdc5951
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 28, 2022
5183ddc
[wjunshen] #N/A test: wjunshen@amazon.com
wujunshen Dec 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .whitesource
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"scanSettings": {
"configMode": "AUTO",
"configExternalURL": "",
"projectToken": "",
"baseBranches": []
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure",
"displayMode": "diff",
"useMendCheckNames": true
},
"issueSettings": {
"minSeverityLevel": "LOW",
"issueType": "DEPENDENCY"
},
"remediateSettings": {
"workflowRules": {
"enabled": true
}
}
}
2 changes: 1 addition & 1 deletion client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ plugins {
dependencies {
implementation project(':opensearch-ml-common')
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.4.0'

}
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
dependencies {
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
implementation group: 'org.reflections', name: 'reflections', version: '0.9.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
compileOnly "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
compileOnly "org.opensearch:common-utils:${common_utils_version}"
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.4.0'
Expand Down
241 changes: 123 additions & 118 deletions common/src/main/java/org/opensearch/ml/common/CommonValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,129 +26,134 @@ public class CommonValue {
public static String WARM_BOX_TYPE = "warm";

public static final String ML_MODEL_INDEX = ".plugins-ml-model";
public static final String ML_MODEL_RELOAD_INDEX = ".plugins-ml-model-reload";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is the schema of this index?

Copy link
Author

Choose a reason for hiding this comment

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

the method of creating index and saving data can be seen in MLModelAutoReLoader#saveLatestReTryTimes

public static final Integer ML_MODEL_RELOAD_MAX_RETRY_TIMES = 2;
public static final String ML_TASK_INDEX = ".plugins-ml-task";
public static final Integer ML_MODEL_INDEX_SCHEMA_VERSION = 2;
public static final Integer ML_TASK_INDEX_SCHEMA_VERSION = 1;
public static final String USER_FIELD_MAPPING = " \""
+ CommonValue.USER
+ "\": {\n"
+ " \"type\": \"nested\",\n"
+ " \"properties\": {\n"
+ " \"name\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\", \"ignore_above\":256}}},\n"
+ " \"backend_roles\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\n"
+ " \"roles\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\n"
+ " \"custom_attribute_names\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}}\n"
+ " }\n"
+ " }\n";
+ CommonValue.USER
Copy link
Collaborator

Choose a reason for hiding this comment

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

Format your code before commit to avoid change the format, this isn't your change.

+ "\": {\n"
+ " \"type\": \"nested\",\n"
+ " \"properties\": {\n"
+ " \"name\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\", \"ignore_above\":256}}},\n"
+ " \"backend_roles\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\n"
+ " \"roles\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}},\n"
+ " \"custom_attribute_names\": {\"type\":\"text\", \"fields\":{\"keyword\":{\"type\":\"keyword\"}}}\n"
+ " }\n"
+ " }\n";
public static final String NODE_ID_FIELD = "node_id";
public static final String MODEL_LOAD_RETRY_TIMES_FIELD = "retry_times";

public static final String ML_MODEL_INDEX_MAPPING = "{\n"
+ " \"_meta\": {\"schema_version\": "
+ ML_MODEL_INDEX_SCHEMA_VERSION
+ "},\n"
+ " \"properties\": {\n"
+ " \""
+ MLModel.ALGORITHM_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_NAME_FIELD
+ "\" : {\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\n"
+ " \""
+ MLModel.OLD_MODEL_VERSION_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.MODEL_VERSION_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_CONTENT_FIELD
+ "\" : {\"type\": \"binary\"},\n"
+ " \""
+ MLModel.CHUNK_NUMBER_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.TOTAL_CHUNKS_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.MODEL_ID_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.DESCRIPTION_FIELD
+ "\" : {\"type\": \"text\"},\n"
+ " \""
+ MLModel.MODEL_FORMAT_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_STATE_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_CONTENT_SIZE_IN_BYTES_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.MODEL_CONFIG_FIELD
+ "\" : {\"properties\":{\""
+ MODEL_TYPE_FIELD + "\":{\"type\":\"keyword\"},\""
+ EMBEDDING_DIMENSION_FIELD + "\":{\"type\":\"integer\"},\""
+ FRAMEWORK_TYPE_FIELD + "\":{\"type\":\"keyword\"},\""
+ ALL_CONFIG_FIELD + "\":{\"type\":\"text\"}}},\n"
+ " \""
+ MLModel.MODEL_CONTENT_HASH_VALUE_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.CREATED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLModel.LAST_UPLOADED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLModel.LAST_LOADED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLModel.LAST_UNLOADED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ USER_FIELD_MAPPING
+ " }\n"
+ "}";
+ " \"_meta\": {\"schema_version\": "
+ ML_MODEL_INDEX_SCHEMA_VERSION
+ "},\n"
+ " \"properties\": {\n"
+ " \""
+ MLModel.ALGORITHM_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_NAME_FIELD
+ "\" : {\"type\":\"text\",\"fields\":{\"keyword\":{\"type\":\"keyword\",\"ignore_above\":256}}},\n"
+ " \""
+ MLModel.OLD_MODEL_VERSION_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.MODEL_VERSION_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_CONTENT_FIELD
+ "\" : {\"type\": \"binary\"},\n"
+ " \""
+ MLModel.CHUNK_NUMBER_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.TOTAL_CHUNKS_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.MODEL_ID_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.DESCRIPTION_FIELD
+ "\" : {\"type\": \"text\"},\n"
+ " \""
+ MLModel.MODEL_FORMAT_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_STATE_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.MODEL_CONTENT_SIZE_IN_BYTES_FIELD
+ "\" : {\"type\": \"long\"},\n"
+ " \""
+ MLModel.MODEL_CONFIG_FIELD
+ "\" : {\"properties\":{\""
+ MODEL_TYPE_FIELD + "\":{\"type\":\"keyword\"},\""
+ EMBEDDING_DIMENSION_FIELD + "\":{\"type\":\"integer\"},\""
+ FRAMEWORK_TYPE_FIELD + "\":{\"type\":\"keyword\"},\""
+ ALL_CONFIG_FIELD + "\":{\"type\":\"text\"}}},\n"
+ " \""
+ MLModel.MODEL_CONTENT_HASH_VALUE_FIELD
+ "\" : {\"type\": \"keyword\"},\n"
+ " \""
+ MLModel.CREATED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLModel.LAST_UPLOADED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLModel.LAST_LOADED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLModel.LAST_UNLOADED_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ USER_FIELD_MAPPING
+ " }\n"
+ "}";

public static final String ML_TASK_INDEX_MAPPING = "{\n"
+ " \"_meta\": {\"schema_version\": "
+ ML_TASK_INDEX_SCHEMA_VERSION
+ "},\n"
+ " \"properties\": {\n"
+ " \""
+ MLTask.MODEL_ID_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.TASK_TYPE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.FUNCTION_NAME_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.STATE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.INPUT_TYPE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.PROGRESS_FIELD
+ "\": {\"type\": \"float\"},\n"
+ " \""
+ MLTask.OUTPUT_INDEX_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.WORKER_NODE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.CREATE_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLTask.LAST_UPDATE_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLTask.ERROR_FIELD
+ "\": {\"type\": \"text\"},\n"
+ " \""
+ MLTask.IS_ASYNC_TASK_FIELD
+ "\" : {\"type\" : \"boolean\"}, \n"
+ USER_FIELD_MAPPING
+ " }\n"
+ "}";
+ " \"_meta\": {\"schema_version\": "
+ ML_TASK_INDEX_SCHEMA_VERSION
+ "},\n"
+ " \"properties\": {\n"
+ " \""
+ MLTask.MODEL_ID_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.TASK_TYPE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.FUNCTION_NAME_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.STATE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.INPUT_TYPE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.PROGRESS_FIELD
+ "\": {\"type\": \"float\"},\n"
+ " \""
+ MLTask.OUTPUT_INDEX_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.WORKER_NODE_FIELD
+ "\": {\"type\": \"keyword\"},\n"
+ " \""
+ MLTask.CREATE_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLTask.LAST_UPDATE_TIME_FIELD
+ "\": {\"type\": \"date\", \"format\": \"strict_date_time||epoch_millis\"},\n"
+ " \""
+ MLTask.ERROR_FIELD
+ "\": {\"type\": \"text\"},\n"
+ " \""
+ MLTask.IS_ASYNC_TASK_FIELD
+ "\" : {\"type\" : \"boolean\"}, \n"
+ USER_FIELD_MAPPING
+ " }\n"
+ "}";
}
2 changes: 1 addition & 1 deletion ml-algorithms/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
implementation group: 'io.protostuff', name: 'protostuff-runtime', version: '1.8.0'
implementation group: 'io.protostuff', name: 'protostuff-api', version: '1.8.0'
implementation group: 'io.protostuff', name: 'protostuff-collectionschema', version: '1.8.0'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.13.1'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '4.4.0'
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '4.4.0'
implementation group: 'com.google.guava', name: 'guava', version: '31.0.1-jre'
Expand Down
3 changes: 1 addition & 2 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import java.util.concurrent.Callable

import org.opensearch.gradle.test.RestIntegTestTask
import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask

plugins {
id 'java'
Expand Down
Loading