You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by GitBox <gi...@apache.org> on 2021/06/07 05:08:59 UTC

[GitHub] [zeppelin] Reamer commented on a change in pull request #4097: [ZEPPELIN-5330]. Support conda env for python interpreter in yarn mode

Reamer commented on a change in pull request #4097:
URL: https://github.com/apache/zeppelin/pull/4097#discussion_r646271563



##########
File path: zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java
##########
@@ -216,6 +259,23 @@ private void launchJupyterKernel(int kernelPort)
     }
   }
 
+  private File buildBootstrapScriptFile(int kernelPort) throws IOException {
+    StringBuilder builder = new StringBuilder();
+    if (condaEnv != null) {
+      builder.append("source " + condaEnv + "/bin/activate\n");
+    }
+    builder.append(pythonExecutable);
+    builder.append(" " + kernelWorkDir.getAbsolutePath() + "/kernel_server.py");

Review comment:
       If you use the StringBuilder, you should use the String Builder for the entire string.
   ```
   builder.append(" ").append(kernelWorkDir.getAbsolutePath()).append("/kernel_server.py");
   ...
   ```

##########
File path: zeppelin-plugins/launcher/yarn/src/main/java/org/apache/zeppelin/interpreter/launcher/YarnLauncherUtil.java
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.zeppelin.interpreter.launcher;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+public class YarnLauncherUtil {
+
+  private static final Logger LOGGER = LoggerFactory.getLogger(YarnLauncherUtil.class);
+
+  public static URI resolveURI(String path) {

Review comment:
       Some javadoc would be nice.
   Please describe why `URI uri = new URI(path);` is not sufficient.

##########
File path: zeppelin-plugins/launcher/yarn/src/test/java/org/apache/zeppelin/interpreter/launcher/YarnLauncherUtilTest.java
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.zeppelin.interpreter.launcher;
+
+import org.junit.Test;
+
+import java.net.URI;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class YarnLauncherUtilTest {
+
+  @Test
+  public void testURIUtil() {
+    URI uri = YarnLauncherUtil.resolveURI("/tmp/env_1");
+    assertEquals("file", uri.getScheme());
+    assertEquals("/tmp/env_1", uri.getPath());
+    assertNull(uri.getFragment());
+
+    uri = YarnLauncherUtil.resolveURI("/tmp/env_1#env");

Review comment:
       Thank you for the tests. I think we should add some more tests.
   1) a string with a scheme
   2) a relative path




-- 
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