Skip to content

Commit

Permalink
update ml-common to use OS 2.0 (#238)
Browse files Browse the repository at this point in the history
Signed-off-by: Xun Zhang <xunzh@amazon.com>
  • Loading branch information
Zhangxunmt authored Mar 22, 2022
1 parent c59785c commit 53a821e
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 185 deletions.
55 changes: 28 additions & 27 deletions .github/workflows/CI-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,38 +28,39 @@ jobs:

- name: Build and Run Tests
run: |
./gradlew build -Dopensearch.version=1.3.0-SNAPSHOT
./gradlew build -Dopensearch.version=2.0.0-SNAPSHOT
- name: Publish to Maven Local
run: |
./gradlew publishToMavenLocal -Dopensearch.version=1.3.0-SNAPSHOT
./gradlew publishToMavenLocal -Dopensearch.version=2.0.0-SNAPSHOT
- name: Multi Nodes Integration Testing
run: |
./gradlew integTest -PnumNodes=3
- name: Pull and Run Docker
run: |
plugin=`ls plugin/build/distributions/*.zip`
echo MLCommons plugin $plugin
version=1.3.0
plugin_version=1.3.0.0-SNAPSHOT
echo Using OpenSearch $version with MLCommons $plugin_version
cd ..
if docker pull opensearchstaging/opensearch:$version
then
echo "FROM opensearchstaging/opensearch:$version" >> Dockerfile
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-ml ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-ml; fi" >> Dockerfile
echo "ADD ml-commons/plugin/build/distributions/opensearch-ml-$plugin_version.zip /tmp/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-ml-$plugin_version.zip" >> Dockerfile
docker build -t opensearch-ml:test .
echo "imagePresent=true" >> $GITHUB_ENV
else
echo "imagePresent=false" >> $GITHUB_ENV
fi
- name: Run Docker Image
if: env.imagePresent == 'true'
run: |
cd ..
docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-ml:test
sleep 90
# ToDo: Check infra team for 2.0 docker availability and re-enable
# - name: Pull and Run Docker
# run: |
# plugin=`ls plugin/build/distributions/*.zip`
# echo MLCommons plugin $plugin
# version=2.0.0
# plugin_version=2.0.0-SNAPSHOT
# echo Using OpenSearch $version with MLCommons $plugin_version
# cd ..
# if docker pull opensearchstaging/opensearch:$version
# then
# echo "FROM opensearchstaging/opensearch:$version" >> Dockerfile
# echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-ml ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-ml; fi" >> Dockerfile
# echo "ADD ml-commons/plugin/build/distributions/opensearch-ml-$plugin_version.zip /tmp/" >> Dockerfile
# echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-ml-$plugin_version.zip" >> Dockerfile
# docker build -t opensearch-ml:test .
# echo "imagePresent=true" >> $GITHUB_ENV
# else
# echo "imagePresent=false" >> $GITHUB_ENV
# fi
# - name: Run Docker Image
# if: env.imagePresent == 'true'
# run: |
# cd ..
# docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-ml:test
# sleep 90
- name: Run MLCommons Test
if: env.imagePresent == 'true'
run: |
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ buildscript {

ext {
opensearch_group = "org.opensearch"
opensearch_version = System.getProperty("opensearch.version", "1.3.0-SNAPSHOT")
// 1.3.0 -> 1.3.0.0, and 1.3.0-SNAPSHOT -> 1.3.0.0-SNAPSHOT
opensearch_version = System.getProperty("opensearch.version", "2.0.0-SNAPSHOT")
// 2.0.0-SNAPSHOT -> 2.0.0.0-SNAPSHOT
opensearch_build = opensearch_version.replaceAll(/(\.\d)([^\d]*)$/, '$1.0$2')
common_utils_version = System.getProperty("common_utils.version", opensearch_build)
}
Expand Down
5 changes: 2 additions & 3 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ plugins {
id "io.freefair.lombok"
id 'jacoco'
id 'com.github.johnrengelman.shadow'
id 'maven'
id 'maven-publish'
id 'signing'
}

dependencies {
compile project(':opensearch-ml-common')
implementation project(':opensearch-ml-common')
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
testCompile group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.9.0'

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public void deleteModel() {
doAnswer(invocation -> {
ActionListener<DeleteResponse> actionListener = invocation.getArgument(2);
ShardId shardId = new ShardId(new Index("indexName", "uuid"), 1);
DeleteResponse output = new DeleteResponse(shardId, "_doc", modelId, 1, 1, 1, true);
DeleteResponse output = new DeleteResponse(shardId, modelId, 1, 1, 1, true);
actionListener.onResponse(output);
return null;
}).when(client).execute(eq(MLModelDeleteAction.INSTANCE), any(), any());
Expand Down Expand Up @@ -345,7 +345,7 @@ public void deleteTask() {
doAnswer(invocation -> {
ActionListener<DeleteResponse> actionListener = invocation.getArgument(2);
ShardId shardId = new ShardId(new Index("indexName", "uuid"), 1);
DeleteResponse output = new DeleteResponse(shardId, "_doc", taskId, 1, 1, 1, true);
DeleteResponse output = new DeleteResponse(shardId, taskId, 1, 1, 1, true);
actionListener.onResponse(output);
return null;
}).when(client).execute(eq(MLTaskDeleteAction.INSTANCE), any(), any());
Expand Down
6 changes: 3 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ plugins {

dependencies {
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
compile group: 'org.reflections', name: 'reflections', version: '0.9.12'
testCompile group: 'junit', name: 'junit', version: '4.12'
implementation group: 'org.reflections', name: 'reflections', version: '0.9.12'
testImplementation group: 'junit', name: 'junit', version: '4.12'
compileOnly "org.opensearch.client:opensearch-rest-client:${opensearch_version}"
compile "org.opensearch:common-utils:${common_utils_version}"
implementation "org.opensearch:common-utils:${common_utils_version}"
testImplementation group: 'org.mockito', name: 'mockito-core', version: '3.9.0'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class SearchQueryInputDataset extends MLInputDataset {
private static NamedXContentRegistry xContentRegistry;

static {
SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
SearchModule searchModule = new SearchModule(Settings.EMPTY, Collections.emptyList());
xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void testXContentFullObject() throws Exception {
String json = Strings.toString(builder);

XContentParser parser = XContentType.JSON.xContent().createParser(new NamedXContentRegistry(new SearchModule(Settings.EMPTY,
false, Collections.emptyList()).getNamedXContents()), null, json);
Collections.emptyList()).getNamedXContents()), null, json);
parser.nextToken();
AnomalyLocalizationInput newInput = AnomalyLocalizationInput.parse(parser);

Expand All @@ -56,7 +56,7 @@ public void testXContentMissingAnomalyStartFilter() throws Exception {
String json = Strings.toString(builder);

XContentParser parser = XContentType.JSON.xContent().createParser(new NamedXContentRegistry(new SearchModule(Settings.EMPTY,
false, Collections.emptyList()).getNamedXContents()), null, json);
Collections.emptyList()).getNamedXContents()), null, json);
parser.nextToken();
AnomalyLocalizationInput newInput = AnomalyLocalizationInput.parse(parser);

Expand All @@ -72,7 +72,7 @@ public void testWriteable() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
input.writeTo(out);
StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(),
new NamedWriteableRegistry(new SearchModule(Settings.EMPTY, false, Collections.emptyList()).getNamedWriteables()));
new NamedWriteableRegistry(new SearchModule(Settings.EMPTY, Collections.emptyList()).getNamedWriteables()));
AnomalyLocalizationInput newInput = new AnomalyLocalizationInput(in);

assertEquals(input, newInput);
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#

#Mon Jan 04 08:34:55 PST 2021
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
Expand Down
Loading

0 comments on commit 53a821e

Please sign in to comment.