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/05/21 06:32:38 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_r636668467



##########
File path: zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java
##########
@@ -183,8 +195,43 @@ public String checkKernelPrerequisite(String pythonExec) {
     return "";
   }
 
+  private void activateCondaEnv(String envName) throws IOException {
+    LOGGER.info("Activating conda env: {}", envName);
+    ByteArrayOutputStream stdout = new ByteArrayOutputStream();
+    PumpStreamHandler psh = new PumpStreamHandler(stdout);
+    try {
+      if (!new File(envName).exists()) {
+        throw new IOException("Fail to activating conda env because no environment folder: " +
+                envName);
+      }
+      File scriptFile = Files.createTempFile("zeppelin_jupyter_kernel_", ".sh").toFile();
+      try (FileWriter writer = new FileWriter(scriptFile)) {
+        IOUtils.write(String.format("chmod 777 -R %s \nsource %s/bin/activate \nconda-unpack",
+                envName, envName),
+                writer);
+      }
+      scriptFile.setExecutable(true, false);
+      scriptFile.setReadable(true, false);
+      CommandLine cmd = new CommandLine(scriptFile.getAbsolutePath());
+      DefaultExecutor executor = new DefaultExecutor();
+      executor.setStreamHandler(psh);
+      int exitCode = executor.execute(cmd);
+      if (exitCode != 0) {
+        throw new IOException("Fail to activate conda env, " + stdout.toString());
+      } else {
+        LOGGER.info("Activate conda env successfully");
+        this.condaEnv = envName;
+        this.pythonExecutable = envName + "/bin/python";
+      }
+    } catch (Exception e) {

Review comment:
       This should be changed to specific exceptions. More at [RSPEC-2221](https://rules.sonarsource.com/java/tag/error-handling/RSPEC-2221)

##########
File path: zeppelin-plugins/launcher/yarn/src/main/java/org/apache/zeppelin/interpreter/launcher/YarnRemoteInterpreterProcess.java
##########
@@ -316,6 +347,25 @@ private ContainerLaunchContext setUpAMLaunchContext() throws IOException {
     return amContainer;
   }
 
+  private URI resolveURI(String path) {

Review comment:
       It would be good if we could add tests with high coverage for this function, as the process is a bit special




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