You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@systemml.apache.org by GitBox <gi...@apache.org> on 2020/04/27 09:08:57 UTC

[GitHub] [systemml] Baunsgaard opened a new pull request #900: [SYSTEMDS-316] [WIP] Rerun with different inputs without recompilation

Baunsgaard opened a new pull request #900:
URL: https://github.com/apache/systemml/pull/900


   This PR, contains code for upgrading the python interface to rerun code segments in DML without the recompilation step. To enable faster iteration of parameters.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [systemml] mboehm7 commented on a change in pull request #900: [SYSTEMDS-310] Python API Refactor

Posted by GitBox <gi...@apache.org>.
mboehm7 commented on a change in pull request #900:
URL: https://github.com/apache/systemml/pull/900#discussion_r420033904



##########
File path: src/main/java/org/apache/sysds/api/PythonDMLScript.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.sysds.api;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sysds.api.jmlc.Connection;
+
+import py4j.GatewayServer;
+
+public class PythonDMLScript {
+	private static final Log LOG = LogFactory.getLog(PythonDMLScript.class.getName());
+	private Connection _connection;
+
+	/**
+	 * Entry point for Python API.
+	 * 
+	 * The system returns with exit code 1, if the startup process fails, and 0 if the startup was successful.
+	 * 
+	 * @param args Command line arguments.
+	 */
+	public static void main(String[] args) {
+		System.exit((start(args[0])) ? 0 : 1);
+	}
+
+	private static boolean start(String port) {
+		try {
+			// TODO Add argument parsing here.
+			GatewayServer GwS = new GatewayServer(new PythonDMLScript(), Integer.parseInt(port));
+			// GwS is non blocking, if first argument is true then it becomes blocking,
+			// but then the python process will not know when the JVM instance is ready.
+			GwS.start();
+			// message the python interface that the JVM is ready.
+			System.out.println("GatewayServer Started");
+
+			// Hack block this process until python stops the gateway.
+			// https://stackoverflow.com/questions/30845546/how-can-we-make-a-thread-to-sleep-for-a-infinite-time-in-java#30845606
+			new CyclicBarrier(2).await();

Review comment:
       Maybe we could add a `GatewayServerListener` which in its `serverPostShutdown` simply calls a `notify` on a monitor we `wait` on here? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [systemml] Baunsgaard commented on a change in pull request #900: [SYSTEMDS-317] [WIP] Rerun with different inputs without recompilation

Posted by GitBox <gi...@apache.org>.
Baunsgaard commented on a change in pull request #900:
URL: https://github.com/apache/systemml/pull/900#discussion_r419460001



##########
File path: src/main/java/org/apache/sysds/api/PythonDMLScript.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.sysds.api;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sysds.api.jmlc.Connection;
+
+import py4j.GatewayServer;
+
+public class PythonDMLScript {
+	private static final Log LOG = LogFactory.getLog(PythonDMLScript.class.getName());
+	private Connection _connection;
+
+	/**
+	 * Entry point for Python API.
+	 * 
+	 * The system returns with exit code 1, if the startup process fails, and 0 if the startup was successful.
+	 * 
+	 * @param args Command line arguments.
+	 */
+	public static void main(String[] args) {
+		System.exit((start(args[0])) ? 0 : 1);
+	}
+
+	private static boolean start(String port) {
+		try {
+			// TODO Add argument parsing here.
+			GatewayServer GwS = new GatewayServer(new PythonDMLScript(), Integer.parseInt(port));
+			// GwS is non blocking, if first argument is true then it becomes blocking,
+			// but then the python process will not know when the JVM instance is ready.
+			GwS.start();
+			// message the python interface that the JVM is ready.
+			System.out.println("GatewayServer Started");
+
+			// Hack block this process until python stops the gateway.
+			// https://stackoverflow.com/questions/30845546/how-can-we-make-a-thread-to-sleep-for-a-infinite-time-in-java#30845606
+			new CyclicBarrier(2).await();

Review comment:
       If someone have a better suggestion for blocking the thread it would be appreciated.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [systemml] Baunsgaard commented on pull request #900: [SYSTEMDS-310] Python API Refactor

Posted by GitBox <gi...@apache.org>.
Baunsgaard commented on pull request #900:
URL: https://github.com/apache/systemml/pull/900#issuecomment-629399108


   Maybe a new committer want to review this. @kev-inn ?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [systemml] asfgit closed pull request #900: [SYSTEMDS-310] Python API Refactor

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #900:
URL: https://github.com/apache/systemml/pull/900


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [systemml] Baunsgaard commented on a change in pull request #900: [SYSTEMDS-310] Python API Refactor

Posted by GitBox <gi...@apache.org>.
Baunsgaard commented on a change in pull request #900:
URL: https://github.com/apache/systemml/pull/900#discussion_r420369567



##########
File path: src/main/java/org/apache/sysds/api/PythonDMLScript.java
##########
@@ -0,0 +1,82 @@
+/*
+ * 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.sysds.api;
+
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.sysds.api.jmlc.Connection;
+
+import py4j.GatewayServer;
+
+public class PythonDMLScript {
+	private static final Log LOG = LogFactory.getLog(PythonDMLScript.class.getName());
+	private Connection _connection;
+
+	/**
+	 * Entry point for Python API.
+	 * 
+	 * The system returns with exit code 1, if the startup process fails, and 0 if the startup was successful.
+	 * 
+	 * @param args Command line arguments.
+	 */
+	public static void main(String[] args) {
+		System.exit((start(args[0])) ? 0 : 1);
+	}
+
+	private static boolean start(String port) {
+		try {
+			// TODO Add argument parsing here.
+			GatewayServer GwS = new GatewayServer(new PythonDMLScript(), Integer.parseInt(port));
+			// GwS is non blocking, if first argument is true then it becomes blocking,
+			// but then the python process will not know when the JVM instance is ready.
+			GwS.start();
+			// message the python interface that the JVM is ready.
+			System.out.println("GatewayServer Started");
+
+			// Hack block this process until python stops the gateway.
+			// https://stackoverflow.com/questions/30845546/how-can-we-make-a-thread-to-sleep-for-a-infinite-time-in-java#30845606
+			new CyclicBarrier(2).await();

Review comment:
       Now changed to use that, thanks for the suggestion, absolutely the right call.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [systemml] mboehm7 commented on pull request #900: [SYSTEMDS-310] Python API Refactor

Posted by GitBox <gi...@apache.org>.
mboehm7 commented on pull request #900:
URL: https://github.com/apache/systemml/pull/900#issuecomment-634251033


   LGTM - that's a very nice patch @Baunsgaard. 
   
   Just some minor comments: (1) as I've seen it before: the correct spelling is built-in functions/algorithms (not build-in), (2) usually we try to delete commented code (e.g., `runFedTest.sh`) and avoid references to transient links as they might change (people will be able to find the quickstart guide of py4j). I fixed (1) but left (2) for now.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org