-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* memory interface Signed-off-by: Jing Zhang <[email protected]> * remove unused test plugin from gradle Signed-off-by: Jing Zhang <[email protected]> --------- Signed-off-by: Jing Zhang <[email protected]> (cherry picked from commit 7cc9399) Co-authored-by: Jing Zhang <[email protected]>
- Loading branch information
1 parent
0a1b4b5
commit 8e581f7
Showing
7 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import com.github.jengelman.gradle.plugins.shadow.ShadowBasePlugin | ||
import org.opensearch.gradle.test.RestIntegTestTask | ||
|
||
plugins { | ||
id 'com.github.johnrengelman.shadow' | ||
id 'jacoco' | ||
id 'maven-publish' | ||
id 'signing' | ||
} | ||
|
||
apply plugin: 'opensearch.java' | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" } | ||
} | ||
|
||
ext { | ||
projectSubstitutions = [:] | ||
licenseFile = rootProject.file('LICENSE.txt') | ||
noticeFile = rootProject.file('NOTICE') | ||
} | ||
|
||
jacoco { | ||
toolVersion = '0.8.7' | ||
reportsDirectory = file("$buildDir/JacocoReport") | ||
} | ||
|
||
jacocoTestReport { | ||
reports { | ||
xml.required = false | ||
csv.required = false | ||
html.destination file("${buildDir}/jacoco/") | ||
} | ||
} | ||
check.dependsOn jacocoTestReport | ||
|
||
def slf4j_version_of_cronutils = "1.7.36" | ||
dependencies { | ||
compileOnly "org.opensearch:opensearch:${opensearch_version}" | ||
|
||
testImplementation "org.opensearch.test:framework:${opensearch_version}" | ||
testImplementation "org.apache.logging.log4j:log4j-core:${versions.log4j}" | ||
} | ||
|
||
configurations.all { | ||
if (it.state != Configuration.State.UNRESOLVED) return | ||
resolutionStrategy { | ||
force "org.slf4j:slf4j-api:${slf4j_version_of_cronutils}" | ||
} | ||
} | ||
|
||
shadowJar { | ||
archiveClassifier = null | ||
} | ||
|
||
test { | ||
doFirst { | ||
test.classpath -= project.files(project.tasks.named('shadowJar')) | ||
test.classpath -= project.configurations.getByName(ShadowBasePlugin.CONFIGURATION_NAME) | ||
test.classpath += project.extensions.getByType(SourceSetContainer).getByName(SourceSet.MAIN_SOURCE_SET_NAME).runtimeClasspath | ||
} | ||
systemProperty 'tests.security.manager', 'false' | ||
} | ||
|
||
task integTest(type: RestIntegTestTask) { | ||
description 'Run integ test with opensearch test framework' | ||
group 'verification' | ||
systemProperty 'tests.security.manager', 'false' | ||
dependsOn test | ||
} | ||
check.dependsOn integTest | ||
|
||
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" | ||
} | ||
maven { | ||
name = "Snapshots" // optional target repository name | ||
url = "https://aws.oss.sonatype.org/content/repositories/snapshots" | ||
credentials { | ||
username "$System.env.SONATYPE_USERNAME" | ||
password "$System.env.SONATYPE_PASSWORD" | ||
} | ||
} | ||
} | ||
publications { | ||
shadow(MavenPublication) { publication -> | ||
project.shadow.component(publication) | ||
artifact sourcesJar | ||
artifact javadocJar | ||
|
||
pom { | ||
name = "OpenSearch ML Commons SPI" | ||
packaging = "jar" | ||
url = "https://github.com/opensearch-project/ml-commons" | ||
description = "OpenSearch ML spi" | ||
scm { | ||
connection = "scm:[email protected]:opensearch-project/ml-commons.git" | ||
developerConnection = "scm:[email protected]:opensearch-project/ml-commons.git" | ||
url = "[email protected]:opensearch-project/ml-commons.git" | ||
} | ||
licenses { | ||
license { | ||
name = "The Apache License, Version 2.0" | ||
url = "http://www.apache.org/licenses/LICENSE-2.0.txt" | ||
} | ||
} | ||
developers { | ||
developer { | ||
name = "OpenSearch" | ||
url = "https://github.com/opensearch-project/ml-commons" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
spi/src/main/java/org/opensearch/ml/common/spi/memory/Memory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.spi.memory; | ||
|
||
import org.opensearch.core.action.ActionListener; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* A general memory interface. | ||
* @param <T> | ||
*/ | ||
public interface Memory<T extends Message> { | ||
|
||
/** | ||
* Get memory type. | ||
* @return | ||
*/ | ||
String getType(); | ||
|
||
/** | ||
* Save message to id. | ||
* @param id memory id | ||
* @param message message to be saved | ||
*/ | ||
default void save(String id, T message) {} | ||
|
||
default <S> void save(String id, T message, ActionListener<S> listener){} | ||
|
||
/** | ||
* Get messages of memory id. | ||
* @param id memory id | ||
* @return | ||
*/ | ||
default T[] getMessages(String id){return null;} | ||
default void getMessages(String id, ActionListener<T> listener){} | ||
|
||
/** | ||
* Clear all memory. | ||
*/ | ||
void clear(); | ||
|
||
/** | ||
* Remove memory of specific id. | ||
* @param id memory id | ||
*/ | ||
void remove(String id); | ||
|
||
interface Factory<T extends Memory> { | ||
/** | ||
* Create an instance of this Memory. | ||
* | ||
* @param params Parameters for the memory | ||
* @param listener Action listern for the memory creation action | ||
*/ | ||
void create(Map<String, Object> params, ActionListener<T> listener); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
spi/src/main/java/org/opensearch/ml/common/spi/memory/Message.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.ml.common.spi.memory; | ||
|
||
/** | ||
* General message interface. | ||
*/ | ||
public interface Message { | ||
|
||
/** | ||
* Get message type. | ||
* @return | ||
*/ | ||
String getType(); | ||
|
||
/** | ||
* Get message content. | ||
* @return | ||
*/ | ||
String getContent(); | ||
} |