Skip to content

Commit 313c448

Browse files
authored
publish ml client to maven (#165)
* publish ml client to maven Signed-off-by: Yaliang Wu <[email protected]> * disable debug logging Signed-off-by: Yaliang Wu <[email protected]> * fix local staging repo path in build.sh Signed-off-by: Yaliang Wu <[email protected]>
1 parent 83d905b commit 313c448

File tree

3 files changed

+110
-15
lines changed

3 files changed

+110
-15
lines changed

client/build.gradle

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
plugins {
77
id 'java'
88
id "io.freefair.lombok"
9-
id 'maven-publish'
109
id 'jacoco'
1110
id 'com.github.johnrengelman.shadow'
11+
id 'maven'
12+
id 'maven-publish'
13+
id 'signing'
1214
}
1315

1416
dependencies {
@@ -50,20 +52,39 @@ shadowJar {
5052
archiveClassifier.set(null)
5153
}
5254

55+
task sourcesJar(type: Jar) {
56+
archiveClassifier.set 'sources'
57+
from sourceSets.main.allJava
58+
}
59+
60+
task javadocJar(type: Jar) {
61+
archiveClassifier.set 'javadoc'
62+
from javadoc.destinationDir
63+
dependsOn javadoc
64+
}
65+
5366
publishing {
67+
repositories {
68+
maven {
69+
name = 'staging'
70+
url = "${rootProject.buildDir}/local-staging-repo"
71+
}
72+
}
5473
publications {
55-
shadow(MavenPublication) {
56-
project.shadow.component(it)
74+
shadow(MavenPublication) { publication ->
75+
project.shadow.component(publication)
76+
artifact sourcesJar
77+
artifact javadocJar
5778

5879
pom {
59-
name = "OpenSearch Machine Learning Client Library"
80+
name = "OpenSearch Machine Learning Client"
6081
packaging = "jar"
61-
url = "https://github.com/opensearch-project/machine-learning"
62-
description = "OpenSearch Machine Learning Client Library"
82+
url = "https://github.com/opensearch-project/ml-commons"
83+
description = "OpenSearch Machine Learning Client"
6384
scm {
64-
connection = "scm:[email protected]:opensearch-project/machine-learning.git"
65-
developerConnection = "scm:[email protected]:opensearch-project/machine-learning.git"
66-
url = "[email protected]:opensearch-project/machine-learning.git"
85+
connection = "scm:[email protected]:opensearch-project/ml-commons.git"
86+
developerConnection = "scm:[email protected]:opensearch-project/ml-commons.git"
87+
url = "[email protected]:opensearch-project/ml-commons.git"
6788
}
6889
licenses {
6990
license {
@@ -73,14 +94,13 @@ publishing {
7394
}
7495
developers {
7596
developer {
76-
id = "amazonwebservices"
77-
organization = "Amazon Web Services"
78-
organizationUrl = "https://aws.amazon.com"
97+
name = "OpenSearch"
98+
url = "https://github.com/opensearch-project/ml-commons"
7999
}
80100
}
81101
}
82102
}
83103
}
84104

85-
86105
}
106+

client/src/main/java/org/opensearch/ml/client/MachineLearningClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface MachineLearningClient {
2727
* Do prediction machine learning job
2828
* @param modelId the trained model id
2929
* @param mlInput ML input
30-
* @return
30+
* @return ActionFuture of MLOutput
3131
*/
3232
default ActionFuture<MLOutput> predict(String modelId, MLInput mlInput) {
3333
PlainActionFuture<MLOutput> actionFuture = PlainActionFuture.newFuture();
@@ -64,7 +64,8 @@ default ActionFuture<MLOutput> trainAndPredict(MLInput mlInput) {
6464
/**
6565
* Do the training machine learning job. The training job will be always async process. The job id will be returned in this method.
6666
* @param mlInput ML input
67-
* @return the result future
67+
* @param asyncTask is async task or not
68+
* @return ActionFuture of MLOutput
6869
*/
6970
default ActionFuture<MLOutput> train(MLInput mlInput, boolean asyncTask) {
7071
PlainActionFuture<MLOutput> actionFuture = PlainActionFuture.newFuture();
@@ -76,6 +77,7 @@ default ActionFuture<MLOutput> train(MLInput mlInput, boolean asyncTask) {
7677
/**
7778
* Do the training machine learning job. The training job will be always async process. The job id will be returned in this method.
7879
* @param mlInput ML input
80+
* @param asyncTask is async task or not
7981
* @param listener a listener to be notified of the result
8082
*/
8183
void train(MLInput mlInput, boolean asyncTask, ActionListener<MLOutput> listener);

scripts/build.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
3+
#
4+
# Copyright OpenSearch Contributors
5+
#
6+
# SPDX-License-Identifier: Apache-2.0
7+
#
8+
9+
set -ex
10+
11+
function usage() {
12+
echo "Usage: $0 [args]"
13+
echo ""
14+
echo "Arguments:"
15+
echo -e "-v VERSION\t[Required] OpenSearch version."
16+
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
17+
echo -e "-p PLATFORM\t[Optional] Platform, ignored."
18+
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored."
19+
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
20+
echo -e "-h help"
21+
}
22+
23+
while getopts ":h:v:s:o:p:a:" arg; do
24+
case $arg in
25+
h)
26+
usage
27+
exit 1
28+
;;
29+
v)
30+
VERSION=$OPTARG
31+
;;
32+
s)
33+
SNAPSHOT=$OPTARG
34+
;;
35+
o)
36+
OUTPUT=$OPTARG
37+
;;
38+
p)
39+
PLATFORM=$OPTARG
40+
;;
41+
a)
42+
ARCHITECTURE=$OPTARG
43+
;;
44+
:)
45+
echo "Error: -${OPTARG} requires an argument"
46+
usage
47+
exit 1
48+
;;
49+
?)
50+
echo "Invalid option: -${arg}"
51+
exit 1
52+
;;
53+
esac
54+
done
55+
56+
if [ -z "$VERSION" ]; then
57+
echo "Error: You must specify the OpenSearch version"
58+
usage
59+
exit 1
60+
fi
61+
62+
[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
63+
[ -z "$OUTPUT" ] && OUTPUT=artifacts
64+
65+
./gradlew publishToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
66+
./gradlew publishAllPublicationsToStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
67+
mkdir -p $OUTPUT/maven/org/opensearch
68+
cp -r ./build/local-staging-repo/org/opensearch/ml/. $OUTPUT/maven/org/opensearch
69+
70+
./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
71+
[ -z "$OUTPUT" ] && OUTPUT=artifacts
72+
mkdir -p $OUTPUT/plugins
73+
cp ./plugin/build/distributions/*.zip $OUTPUT/plugins

0 commit comments

Comments
 (0)