diff --git a/build.gradle b/build.gradle index fcf08e16d..422d3190b 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,7 @@ opensearchplugin { noticeFile rootProject.file('NOTICE') } +dependencyLicenses.enabled = false // This requires an additional Jar not published as part of build-tools loggerUsageCheck.enabled = false @@ -62,6 +63,20 @@ validateNebulaPom.enabled = false buildscript { ext { opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") + buildVersionQualifier = System.getProperty("build.version_qualifier", "") + isSnapshot = "true" == System.getProperty("build.snapshot", "true") + version_tokens = opensearch_version.tokenize('-') + opensearch_build = version_tokens[0] + '.0' + plugin_no_snapshot = opensearch_build + if (buildVersionQualifier) { + opensearch_build += "-${buildVersionQualifier}" + plugin_no_snapshot += "-${buildVersionQualifier}" + } + if (isSnapshot) { + opensearch_build += "-SNAPSHOT" + } + opensearch_group = "org.opensearch" + opensearch_no_snapshot = opensearch_build.replace("-SNAPSHOT","") System.setProperty('tests.security.manager', 'false') } @@ -89,7 +104,9 @@ repositories { dependencies { implementation "org.opensearch:opensearch:${opensearch_version}" + implementation 'org.junit.jupiter:junit-jupiter:5.8.1' compileOnly "com.google.guava:guava:32.1.2-jre" + api group: 'org.opensearch', name:'opensearch-ml-client', version: "${opensearch_build}" configurations.all { resolutionStrategy { diff --git a/src/main/java/org/opensearch/flowframework/client/MLClient.java b/src/main/java/org/opensearch/flowframework/client/MLClient.java new file mode 100644 index 000000000..a1ef7d61e --- /dev/null +++ b/src/main/java/org/opensearch/flowframework/client/MLClient.java @@ -0,0 +1,34 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ +package org.opensearch.flowframework.client; + +import org.opensearch.client.node.NodeClient; +import org.opensearch.ml.client.MachineLearningNodeClient; + +/** + Class to initiate an instance of MLClient + */ +public class MLClient { + private static MachineLearningNodeClient INSTANCE; + + private MLClient() {} + + /** + * Creates machine learning client. + * + * @param nodeClient node client of OpenSearch. + * @return machine learning client from ml-commons. + */ + public static MachineLearningNodeClient createMLClient(NodeClient nodeClient) { + if (INSTANCE == null) { + INSTANCE = new MachineLearningNodeClient(nodeClient); + } + return INSTANCE; + } +} diff --git a/src/main/java/org/opensearch/flowframework/workflow/Workflow.java b/src/main/java/org/opensearch/flowframework/workflow/Workflow.java new file mode 100644 index 000000000..634877bec --- /dev/null +++ b/src/main/java/org/opensearch/flowframework/workflow/Workflow.java @@ -0,0 +1,26 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ +package org.opensearch.flowframework.workflow; + +import java.util.concurrent.CompletableFuture; + +/** + * Interface for the workflow setup of different building blocks. + */ +public interface Workflow { + + /** + * Triggers the processing of the building block. + * + * @return CompletableFuture of the building block. + * @throws Exception if execution fails + */ + CompletableFuture execute() throws Exception; + +} diff --git a/src/main/plugin-metadata/plugin-security.policy b/src/main/plugin-metadata/plugin-security.policy new file mode 100644 index 000000000..d205ccda0 --- /dev/null +++ b/src/main/plugin-metadata/plugin-security.policy @@ -0,0 +1,7 @@ +grant { + //ml-commons client + permission java.lang.RuntimePermission "getClassLoader"; + permission java.lang.RuntimePermission "accessDeclaredMembers"; + permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; + permission java.lang.RuntimePermission "setContextClassLoader"; +}; \ No newline at end of file