diff --git a/.github/release-drafter-config.yml b/.github/release-drafter-config.yml new file mode 100644 index 0000000..29a9a4b --- /dev/null +++ b/.github/release-drafter-config.yml @@ -0,0 +1,27 @@ +name-template: '$NEXT_PATCH_VERSION' +tag-template: '$NEXT_PATCH_VERSION' +categories: + - title: 'Features' + labels: + - 'type: new feature' + - 'type: enhancement' + - 'enhancement' + - title: 'Bug Fixes' + labels: + - 'type: bug' + - 'bug' + - title: 'Maintenance' + label: 'refactor' +change-template: '- $TITLE #$NUMBER' +exclude-labels: + - 'skip-changelog' +template: | + ## Changes + + $CHANGES + + ## Contributors + We'd like to thank all the contributors who worked on this release! + + $CONTRIBUTORS + diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 31b4200..bf81e56 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -23,7 +23,7 @@ jobs: ports: - 6379:6379 redisearch: - image: redislabs/redisearch:1.6.13 + image: redislabs/redisearch:latest options: >- --health-cmd "redis-cli ping" --health-interval 10s @@ -58,7 +58,7 @@ jobs: java-version: 1.8 - name: Build with Maven - run: mvn clean install -DskipTests=true --file pom.xml + run: mvn clean install -DskipTests=true -Dgpg.skip --file pom.xml - name: Test RedisBloom run: mvn test -pl redisbloom -DREDIS_HOST=localhost --file pom.xml diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000..1624591 --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,19 @@ +name: Release Drafter + +on: + push: + # branches to consider in the event; optional, defaults to all + branches: + - master + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + # Drafts your next Release notes as Pull Requests are merged into "master" + - uses: release-drafter/release-drafter@v5 + with: + # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml + config-name: release-drafter-config.yml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 47010a4..a6ae792 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![build](https://github.com/dengliming/redis-modules-java/workflows/build/badge.svg) ![java-version](https://img.shields.io/badge/JDK-1.8+-brightgreen.svg) ![maven](https://img.shields.io/badge/maven-3.5+-brightgreen.svg) [![license](https://img.shields.io/github/license/dengliming/redis-modules-java)](/LICENSE) [![codecov](https://codecov.io/gh/dengliming/redis-modules-java/branch/master/graph/badge.svg?token=U8BA091JD5)](https://codecov.io/gh/dengliming/redis-modules-java) +![build](https://github.com/dengliming/redis-modules-java/workflows/build/badge.svg) ![java-version](https://img.shields.io/badge/JDK-1.8+-brightgreen.svg) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.dengliming.redismodule/redis-modules-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.dengliming.redismodule/redis-modules-java) [![license](https://img.shields.io/github/license/dengliming/redis-modules-java)](/LICENSE) [![codecov](https://codecov.io/gh/dengliming/redis-modules-java/branch/master/graph/badge.svg?token=U8BA091JD5)](https://codecov.io/gh/dengliming/redis-modules-java) Java Client libraries for [redis-modules](https://redis.io/modules), based on [Redisson](https://github.com/redisson/redisson). @@ -17,32 +17,11 @@ Java Client libraries for [redis-modules](https://redis.io/modules), based on [R ## Installing #### Build from source -Execute ./mvnw clean install -DskipTests=true. The build process requires JDK8+. +Execute ./mvnw clean install -DskipTests=true -Dgpg.skip. The build process requires JDK8+. + #### Maven repository -repositories -```xml - - - snapshots-repo - https://raw.githubusercontent.com/dengliming/mvn-repo/master/snapshots - - - releases-repo - https://raw.githubusercontent.com/dengliming/mvn-repo/master/releases - - -``` Include all ```xml - - - io.github.dengliming.redismodule - all - 1.0.1-SNAPSHOT - -``` -or -```xml io.github.dengliming.redismodule @@ -52,15 +31,6 @@ or ``` Include single module like: ```xml - - - io.github.dengliming.redismodule - redistimeseries - 1.0.1-SNAPSHOT - -``` -or -```xml io.github.dengliming.redismodule @@ -68,6 +38,7 @@ or 1.0.0 ``` + ## Usage example RedisBloom ```java @@ -143,6 +114,17 @@ redisTimeSeries.add(new Sample("temperature:2:32", Sample.Value.of(timestamp, 26 .labels(new Label("sensor_id", "2"), new Label("area_id", "32"))); redisTimeSeriesClient.shutdown(); ``` + +RedisAI +```java +Config config = new Config(); +config.useSingleServer().setAddress("redis://127.0.0.1:6379"); +RedisAIClient redisAIClient = new RedisAIClient(config); + +RedisAI redisAI = redisAIClient.getRedisAI(); +redisAI.setTensor("tensor1", DataType.FLOAT, new int[]{2, 2}, null, new String[]{"1", "2", "3", "4"}); +redisAIClient.shutdown(); +``` ## License [Apache License 2.0](/LICENSE) diff --git a/commons/pom.xml b/commons/pom.xml index 781fb66..833c107 100644 --- a/commons/pom.xml +++ b/commons/pom.xml @@ -8,10 +8,4 @@ 4.0.0 commons Commons - - - org.redisson - redisson - - diff --git a/pom.xml b/pom.xml index 40e674d..332f51d 100644 --- a/pom.xml +++ b/pom.xml @@ -18,9 +18,36 @@ Redis-Modules-Java + Java Client libraries for redis-modules. https://github.com/dengliming/redis-modules-java - + + git:git@github.com:dengliming/redis-modules-java.git + scm:git:git@github.com:dengliming/redis-modules-java.git + scm:git:git@github.com:dengliming/redis-modules-java.git + HEAD + + + + + Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0 + + + + + + dengliming + dengliming + liming.d.pro@gmail.com + + Founder + Developer + + + + + UTF-8 3.13.4 5.6.2 @@ -29,15 +56,13 @@ 3.2.1 2.5.3 0.8.5 + 1.6 + 2.10.4 + 3.0.0-M3 + 3.17.2 + 2.2 - - scm:git:git@github.com:dengliming/redis-modules-java.git - scm:git:git@github.com:dengliming/redis-modules-java.git - scm:git:git@github.com:dengliming/redis-modules-java.git - HEAD - - @@ -81,16 +106,24 @@ redistimeseries ${project.version} - - - org.redisson - redisson - ${redisson.version} - + + org.assertj + assertj-core + ${assertj-core.version} + test + + + + org.hamcrest + hamcrest-library + ${hamcrest-library.version} + test + + org.junit.jupiter junit-jupiter-api @@ -110,6 +143,12 @@ ${junit.version} test + + + org.redisson + redisson + ${redisson.version} + @@ -136,6 +175,23 @@ + + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + true + -Xdoclint:none + + + + attach-javadoc + + jar + + + + + org.apache.maven.plugins maven-source-plugin @@ -150,6 +206,12 @@ + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire-plugin.version} + + org.jacoco jacoco-maven-plugin @@ -169,19 +231,32 @@ + + + org.apache.maven.plugins + maven-gpg-plugin + ${gpg-plugin.version} + + + sign-artifacts + verify + + sign + + + + - - releases - releases - file:/data/mvn-repo/repository/releases/ - - snapshot - snapshot - file:/data/mvn-repo/repository/snapshots/ + oss + https://s01.oss.sonatype.org/content/repositories/snapshots + + oss + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 + diff --git a/redisai/README.md b/redisai/README.md index c0d033d..7dbae41 100644 --- a/redisai/README.md +++ b/redisai/README.md @@ -5,18 +5,18 @@ See https://oss.redislabs.com/redisai/ for more details. Redis command|Sync / Async Api| | --- | --- | AI.TENSORSET | RedisAI.
setTensor()
setTensorAsync() | -AI.TENSORGET | N/A | +AI.TENSORGET | RedisAI.
getTensor()
getTensorAsync() | AI.MODELSET | RedisAI.
setModel()
setModelAsync() | -AI.MODELGET | N/A | +AI.MODELGET | RedisAI.
getModel()
getModelAsync() | AI.MODELDEL | RedisAI.
deleteModel()
deleteModelAsync() | AI.MODELRUN | N/A | AI._MODELSCAN | N/A | AI.SCRIPTSET | RedisAI.
setScript()
setScriptAsync() | -AI.SCRIPTGET | N/A | +AI.SCRIPTGET | RedisAI.
getScript()
getScriptAsync() | AI.SCRIPTDEL | RedisAI.
deleteScript()
deleteScriptAsync() | AI.SCRIPTRUN | RedisAI.
runScript()
runScriptAsync() | AI._SCRIPTSCAN | N/A | AI.DAGRUN | N/A | AI.DAGRUN_RO | N/A | AI.INFO | RedisAI.
getInfo()
getInfoAsync()
resetStat()
resetStatAsync() | -AI.CONFIG | RedisAI.
loadBackend()
loadBackendAsync()
setBackendPath()
setBackendPathAsync() | \ No newline at end of file +AI.CONFIG | RedisAI.
loadBackend()
loadBackendAsync()
setBackendPath()
setBackendPathAsync() | diff --git a/redisai/pom.xml b/redisai/pom.xml index 140af48..4a25b84 100644 --- a/redisai/pom.xml +++ b/redisai/pom.xml @@ -15,11 +15,6 @@ io.github.dengliming.redismodule commons
- - - org.redisson - redisson - diff --git a/redisai/src/main/java/io/github/dengliming/redismodule/redisai/RedisAI.java b/redisai/src/main/java/io/github/dengliming/redismodule/redisai/RedisAI.java index 3a3eb16..53c6a0e 100644 --- a/redisai/src/main/java/io/github/dengliming/redismodule/redisai/RedisAI.java +++ b/redisai/src/main/java/io/github/dengliming/redismodule/redisai/RedisAI.java @@ -16,8 +16,13 @@ package io.github.dengliming.redismodule.redisai; import io.github.dengliming.redismodule.common.util.RAssert; +import io.github.dengliming.redismodule.redisai.args.SetModelArgs; +import io.github.dengliming.redismodule.redisai.model.Model; +import io.github.dengliming.redismodule.redisai.model.Script; +import io.github.dengliming.redismodule.redisai.model.Tensor; import io.github.dengliming.redismodule.redisai.protocol.Keywords; import org.redisson.api.RFuture; +import org.redisson.client.codec.ByteArrayCodec; import org.redisson.client.codec.Codec; import org.redisson.client.codec.StringCodec; import org.redisson.command.CommandAsyncExecutor; @@ -52,14 +57,14 @@ public RedisAI(CommandAsyncExecutor commandExecutor) { * @return */ public boolean setTensor(String key, DataType type, int[] dimensions, byte[] data, String[] values) { - RAssert.notNull(key, "key must not be null"); - RAssert.notNull(type, "type must not be null"); - RAssert.notEmpty(dimensions, "dimensions must not be empty"); - return commandExecutor.get(setTensorAsync(key, type, dimensions, data, values)); } public RFuture setTensorAsync(String key, DataType type, int[] dimensions, byte[] data, String[] values) { + RAssert.notNull(key, "key must not be null"); + RAssert.notNull(type, "type must not be null"); + RAssert.notEmpty(dimensions, "dimensions must not be empty"); + List args = new ArrayList<>(); args.add(key); if (dimensions != null) { @@ -81,12 +86,24 @@ public RFuture setTensorAsync(String key, DataType type, int[] dimensio return commandExecutor.writeAsync(getName(), codec, AI_TENSORSET, args.toArray()); } - public boolean setModel(String key, Backend backEnd, Device device, byte[] model) { - return commandExecutor.get(setModelAsync()); + /** + * stores a model as the value of a key. + * + * @param key + * @param args + * @return + */ + public boolean setModel(String key, SetModelArgs args) { + return commandExecutor.get(setModelAsync(key, args)); } - public RFuture setModelAsync() { - return commandExecutor.writeAsync(getName(), codec, AI_TENSORSET); + public RFuture setModelAsync(String key, SetModelArgs modelArgs) { + RAssert.notNull(key, "key must not be null"); + + List args = new ArrayList<>(); + args.add(key); + modelArgs.build(args); + return commandExecutor.writeAsync(getName(), ByteArrayCodec.INSTANCE, AI_MODELSET, args.toArray()); } /** @@ -230,6 +247,56 @@ public RFuture resetStatAsync(String key) { return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, AI_INFO_RESETSTAT, key, Keywords.RESETSTAT); } + /** + * Returns a tensor stored as key's value. + * + * @param key the tensor's key name + * @return + */ + public Tensor getTensor(String key) { + return commandExecutor.get(getTensorAsync(key)); + } + + public RFuture getTensorAsync(String key) { + RAssert.notNull(key, "key must not be null"); + + return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, AI_TENSORGET, key, Keywords.META, Keywords.BLOB); + } + + /** + * Returns a model's metadata and blob stored as a key's value. + * + * @param key the tensor's key name + * @return + */ + public Model getModel(String key) { + return commandExecutor.get(getModelAsync(key)); + } + + public RFuture getModelAsync(String key) { + RAssert.notNull(key, "key must not be null"); + + return commandExecutor.readAsync(getName(), StringCodec.INSTANCE, AI_MODELGET, key, Keywords.META, Keywords.BLOB); + } + + /** + * Returns the TorchScript stored as a key's value. + * + * AI.SCRIPTGET [META] [SOURCE] + * + * @param key name of key to get the Script from RedisAI server + * @return + */ + public Script getScript(String key) { + return commandExecutor.get(getScriptAsync(key)); + } + + public RFuture