Skip to content

Commit d74ce98

Browse files
committed
add support for run script
1 parent 30b3d47 commit d74ce98

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/main/java/com/redislabs/redisai/RedisAI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ public boolean runModel(String key, String[] inputs, String[] outputs){
151151
/**
152152
* AI.SCRIPTRUN script_key fn_name INPUTS input_key1 ... OUTPUTS output_key1 ...
153153
*/
154-
public boolean runScript(String key, String[] inputs, String[] outputs) {
154+
public boolean runScript(String key, String function, String[] inputs, String[] outputs) {
155155

156156
try (Jedis conn = getConnection()) {
157157

158158
ArrayList<byte[]> args = new ArrayList<>();
159159
args.add(SafeEncoder.encode(key));
160+
args.add(SafeEncoder.encode(function));
160161

161162
args.add(Keyword.INPUTS.getRaw());
162163
for(String input: inputs) {

src/test/java/com/redislabs/redisai/RedisAITest.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ public void testSeScript() {
5959
// client.getScript("script");
6060
}
6161

62-
// @Test
63-
// public void testRunScript() {
64-
// ClassLoader classLoader = getClass().getClassLoader();
65-
// String script = classLoader.getResource("script.txt").getFile();
66-
// client.setScriptFile("script", Device.CPU, script);
67-
// client.setTensor("input", new int[]{1}, new int[] {1});
68-
//
69-
// Assert.assertTrue(client.runScript("model", new String[] {"input"}, new String[] {"target"}));
70-
// }
62+
@Test
63+
public void testRunScript() {
64+
ClassLoader classLoader = getClass().getClassLoader();
65+
String script = classLoader.getResource("script.txt").getFile();
66+
client.setScriptFile("script", Device.CPU, script);
67+
68+
client.setTensor("a1", new float[] {2, 3}, new int[]{2});
69+
client.setTensor("b1", new float[] {2, 3}, new int[]{2});
70+
71+
Assert.assertTrue(client.runScript("script", "bar", new String[] {"a1", "b1"}, new String[] {"c1"}));
72+
}
7173
}

0 commit comments

Comments
 (0)