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

publish ml client to maven #165

Merged
merged 3 commits into from
Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 33 additions & 13 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
plugins {
id 'java'
id "io.freefair.lombok"
id 'maven-publish'
id 'jacoco'
id 'com.github.johnrengelman.shadow'
id 'maven'
id 'maven-publish'
id 'signing'
}

dependencies {
Expand Down Expand Up @@ -50,20 +52,39 @@ shadowJar {
archiveClassifier.set(null)
}

task sourcesJar(type: Jar) {
archiveClassifier.set 'sources'
from sourceSets.main.allJava
}

task javadocJar(type: Jar) {
archiveClassifier.set 'javadoc'
from javadoc.destinationDir
dependsOn javadoc
}

publishing {
repositories {
maven {
name = 'staging'
url = "${rootProject.buildDir}/local-staging-repo"
}
}
publications {
shadow(MavenPublication) {
project.shadow.component(it)
shadow(MavenPublication) { publication ->
project.shadow.component(publication)
artifact sourcesJar
artifact javadocJar

pom {
name = "OpenSearch Machine Learning Client Library"
name = "OpenSearch Machine Learning Client"
packaging = "jar"
url = "https://github.com/opensearch-project/machine-learning"
description = "OpenSearch Machine Learning Client Library"
url = "https://github.com/opensearch-project/ml-commons"
description = "OpenSearch Machine Learning Client"
scm {
connection = "scm:git@github.com:opensearch-project/machine-learning.git"
developerConnection = "scm:git@github.com:opensearch-project/machine-learning.git"
url = "git@github.com:opensearch-project/machine-learning.git"
connection = "scm:git@github.com:opensearch-project/ml-commons.git"
developerConnection = "scm:git@github.com:opensearch-project/ml-commons.git"
url = "git@github.com:opensearch-project/ml-commons.git"
}
licenses {
license {
Expand All @@ -73,14 +94,13 @@ publishing {
}
developers {
developer {
id = "amazonwebservices"
organization = "Amazon Web Services"
organizationUrl = "https://aws.amazon.com"
name = "OpenSearch"
url = "https://github.com/opensearch-project/ml-commons"
}
}
}
}
}


}

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface MachineLearningClient {
* Do prediction machine learning job
* @param modelId the trained model id
* @param mlInput ML input
* @return
* @return ActionFuture of MLOutput
*/
default ActionFuture<MLOutput> predict(String modelId, MLInput mlInput) {
PlainActionFuture<MLOutput> actionFuture = PlainActionFuture.newFuture();
Expand Down Expand Up @@ -64,7 +64,8 @@ default ActionFuture<MLOutput> trainAndPredict(MLInput mlInput) {
/**
* Do the training machine learning job. The training job will be always async process. The job id will be returned in this method.
* @param mlInput ML input
* @return the result future
* @param asyncTask is async task or not
* @return ActionFuture of MLOutput
*/
default ActionFuture<MLOutput> train(MLInput mlInput, boolean asyncTask) {
PlainActionFuture<MLOutput> actionFuture = PlainActionFuture.newFuture();
Expand All @@ -76,6 +77,7 @@ default ActionFuture<MLOutput> train(MLInput mlInput, boolean asyncTask) {
/**
* Do the training machine learning job. The training job will be always async process. The job id will be returned in this method.
* @param mlInput ML input
* @param asyncTask is async task or not
* @param listener a listener to be notified of the result
*/
void train(MLInput mlInput, boolean asyncTask, ActionListener<MLOutput> listener);
Expand Down
73 changes: 73 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

#
# Copyright OpenSearch Contributors
#
# SPDX-License-Identifier: Apache-2.0
#

set -ex

function usage() {
echo "Usage: $0 [args]"
echo ""
echo "Arguments:"
echo -e "-v VERSION\t[Required] OpenSearch version."
echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'."
echo -e "-p PLATFORM\t[Optional] Platform, ignored."
echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored."
echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'."
echo -e "-h help"
}

while getopts ":h:v:s:o:p:a:" arg; do
case $arg in
h)
usage
exit 1
;;
v)
VERSION=$OPTARG
;;
s)
SNAPSHOT=$OPTARG
;;
o)
OUTPUT=$OPTARG
;;
p)
PLATFORM=$OPTARG
;;
a)
ARCHITECTURE=$OPTARG
;;
:)
echo "Error: -${OPTARG} requires an argument"
usage
exit 1
;;
?)
echo "Invalid option: -${arg}"
exit 1
;;
esac
done

if [ -z "$VERSION" ]; then
echo "Error: You must specify the OpenSearch version"
usage
exit 1
fi

[[ "$SNAPSHOT" == "true" ]] && VERSION=$VERSION-SNAPSHOT
[ -z "$OUTPUT" ] && OUTPUT=artifacts

./gradlew publishToMavenLocal -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
./gradlew publishAllPublicationsToStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
mkdir -p $OUTPUT/maven/org/opensearch
cp -r ./build/local-staging-repo/org/opensearch/ml/. $OUTPUT/maven/org/opensearch

./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT
[ -z "$OUTPUT" ] && OUTPUT=artifacts
mkdir -p $OUTPUT/plugins
cp ./plugin/build/distributions/*.zip $OUTPUT/plugins