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/02 06:15:25 UTC

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

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



##########
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:
       Addressed

##########
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:
       Addressed




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