[SYSTEMML-1984] Fix special cases of JMLC prepare/execute sequences

This patch fixes issues with special cases of prepare and execute
sequences on the same connection, which currently fail due to the
cleanup of thread-local configurations after execute. 

Furthermore, this also adds the existing JMLC tests from building the
lite jar to our testsuite in order to avoid regressions. This also
includes a minor fix of these tests regarding the recently modified
L2SVM predict script.


Project: http://git-wip-us.apache.org/repos/asf/systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/820b5304
Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/820b5304
Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/820b5304

Branch: refs/heads/master
Commit: 820b5304672a81093787670c70b1c083daab446d
Parents: 4f60ded
Author: Matthias Boehm <[email protected]>
Authored: Fri Nov 3 18:59:00 2017 -0700
Committer: Matthias Boehm <[email protected]>
Committed: Fri Nov 3 18:59:30 2017 -0700

----------------------------------------------------------------------
 .../org/apache/sysml/api/jmlc/Connection.java   | 10 ++-
 .../sysml/utils/lite/BuildLiteExecution.java    |  4 +-
 .../functions/jmlc/BuildLiteJarTest.java        | 87 ++++++++++++++++++++
 .../functions/jmlc/ZPackageSuite.java           |  1 +
 4 files changed, 97 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/systemml/blob/820b5304/src/main/java/org/apache/sysml/api/jmlc/Connection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/api/jmlc/Connection.java 
b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
index 4caa86c..e96e0aa 100644
--- a/src/main/java/org/apache/sysml/api/jmlc/Connection.java
+++ b/src/main/java/org/apache/sysml/api/jmlc/Connection.java
@@ -131,7 +131,7 @@ public class Connection implements Closeable
                //create default configuration
                _dmlconf = new DMLConfig();
                
-               //set thread-local configurations for compilation
+               //set thread-local configurations for compilation and read
                ConfigurationManager.setLocalConfig(_dmlconf);
                ConfigurationManager.setLocalConfig(_cconf);
        }
@@ -150,7 +150,7 @@ public class Connection implements Closeable
                for( ConfigType configType : configs )
                        _cconf.set(configType, true);
                
-               //set thread-local configurations for compilation
+               //set thread-local configurations for compilation and read
                ConfigurationManager.setLocalConfig(_dmlconf);
                ConfigurationManager.setLocalConfig(_cconf);
        }
@@ -186,7 +186,7 @@ public class Connection implements Closeable
                throws DMLException 
        {
                DMLScript.SCRIPT_TYPE = parsePyDML ? ScriptType.PYDML : 
ScriptType.DML;
-
+               
                //check for valid names of passed arguments
                String[] invalidArgs = args.keySet().stream()
                        .filter(k -> k==null || 
!k.startsWith("$")).toArray(String[]::new);
@@ -202,6 +202,10 @@ public class Connection implements Closeable
                //simplified compilation chain
                Program rtprog = null;
                try {
+                       //set thread-local configurations for compilation
+                       ConfigurationManager.setLocalConfig(_dmlconf);
+                       ConfigurationManager.setLocalConfig(_cconf);
+                       
                        //parsing
                        ParserWrapper parser = 
ParserFactory.createParser(parsePyDML ? ScriptType.PYDML : ScriptType.DML);
                        DMLProgram prog = parser.parse(null, script, args);

http://git-wip-us.apache.org/repos/asf/systemml/blob/820b5304/src/main/java/org/apache/sysml/utils/lite/BuildLiteExecution.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/sysml/utils/lite/BuildLiteExecution.java 
b/src/main/java/org/apache/sysml/utils/lite/BuildLiteExecution.java
index b2b2574..4ce6f33 100644
--- a/src/main/java/org/apache/sysml/utils/lite/BuildLiteExecution.java
+++ b/src/main/java/org/apache/sysml/utils/lite/BuildLiteExecution.java
@@ -330,7 +330,7 @@ public class BuildLiteExecution {
                m.put("$confusion", "temp/2.csv");
                m.put("$scores", "temp/3.csv");
 
-               PreparedScript l2svmPredict = conn.prepareScript(s, m, new 
String[] { "X", "y", "w", "fmt" },
+               PreparedScript l2svmPredict = conn.prepareScript(s, m, new 
String[] { "X", "Y", "w", "fmt" },
                                new String[] { "scores", "confusion_mat" }, 
false);
 
                double[][] testData = new double[150][3];
@@ -349,7 +349,7 @@ public class BuildLiteExecution {
                        double[] row = new double[] { one };
                        testLabels[i] = row;
                }
-               l2svmPredict.setMatrix("y", testLabels);
+               l2svmPredict.setMatrix("Y", testLabels);
 
                l2svmPredict.setMatrix("w", model);
 

http://git-wip-us.apache.org/repos/asf/systemml/blob/820b5304/src/test/java/org/apache/sysml/test/integration/functions/jmlc/BuildLiteJarTest.java
----------------------------------------------------------------------
diff --git 
a/src/test/java/org/apache/sysml/test/integration/functions/jmlc/BuildLiteJarTest.java
 
b/src/test/java/org/apache/sysml/test/integration/functions/jmlc/BuildLiteJarTest.java
new file mode 100644
index 0000000..24c400f
--- /dev/null
+++ 
b/src/test/java/org/apache/sysml/test/integration/functions/jmlc/BuildLiteJarTest.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysml.test.integration.functions.jmlc;
+
+import org.apache.sysml.test.integration.AutomatedTestBase;
+import org.apache.sysml.utils.lite.BuildLiteExecution;
+import org.junit.Test;
+
+public class BuildLiteJarTest extends AutomatedTestBase 
+{
+       @Override
+       public void setUp() {
+               //do nothing
+       }
+       
+       @Test
+       public void testJMLCHelloWorld() throws Exception {
+               BuildLiteExecution.jmlcHelloWorld();
+       }
+       
+       @Test
+       public void testJMLCScoringExample() throws Exception {
+               BuildLiteExecution.jmlcScoringExample();
+       }
+       
+       @Test
+       public void testJMLCUnivariateStats() throws Exception {
+               BuildLiteExecution.jmlcUnivariateStatistics();
+       }
+       
+       @Test
+       public void testJMLCWriteMatrix() throws Exception {
+               BuildLiteExecution.jmlcWriteMatrix();
+       }
+       
+       @Test
+       public void testJMLCReadMatrix() throws Exception {
+               BuildLiteExecution.jmlcReadMatrix();
+       }
+       
+       @Test
+       public void testJMLCBasics() throws Exception {
+               BuildLiteExecution.jmlcBasics();
+       }
+       
+       @Test
+       public void testJMLCL2SVM() throws Exception {
+               BuildLiteExecution.jmlcL2SVM();
+       }
+       
+       @Test
+       public void testJMLCLinReg() throws Exception {
+               BuildLiteExecution.jmlcLinReg();
+       }
+       
+       @Test
+       public void testJMLCALS() throws Exception {
+               BuildLiteExecution.jmlcALS();
+       }
+       
+       @Test
+       public void testJMLCKmeans() throws Exception {
+               BuildLiteExecution.jmlcKmeans();
+       }
+       
+       @Test
+       public void testJMLCTests() throws Exception {
+               BuildLiteExecution.jmlcTests();
+       }
+}

http://git-wip-us.apache.org/repos/asf/systemml/blob/820b5304/src/test_suites/java/org/apache/sysml/test/integration/functions/jmlc/ZPackageSuite.java
----------------------------------------------------------------------
diff --git 
a/src/test_suites/java/org/apache/sysml/test/integration/functions/jmlc/ZPackageSuite.java
 
b/src/test_suites/java/org/apache/sysml/test/integration/functions/jmlc/ZPackageSuite.java
index 87244aa..3d5c13a 100644
--- 
a/src/test_suites/java/org/apache/sysml/test/integration/functions/jmlc/ZPackageSuite.java
+++ 
b/src/test_suites/java/org/apache/sysml/test/integration/functions/jmlc/ZPackageSuite.java
@@ -26,6 +26,7 @@ import org.junit.runners.Suite;
  *  won't run two of them at once. */
 @RunWith(Suite.class)
 @Suite.SuiteClasses({
+       BuildLiteJarTest.class,
        FrameCastingTest.class,
        FrameDecodeTest.class,
        FrameEncodeTest.class,

Reply via email to