You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zeppelin.apache.org by "Thomas Decaux (Jira)" <ji...@apache.org> on 2022/09/01 21:37:00 UTC
[jira] [Created] (ZEPPELIN-5811) Shell script for activate conda env
Thomas Decaux created ZEPPELIN-5811:
---------------------------------------
Summary: Shell script for activate conda env
Key: ZEPPELIN-5811
URL: https://issues.apache.org/jira/browse/ZEPPELIN-5811
Project: Zeppelin
Issue Type: Improvement
Components: r-interpreter, zeppelin-interpreter
Affects Versions: 0.10.1
Reporter: Thomas Decaux
When using R interpreter, conda to install dependencies, Zeppelin have a very nice feature to activate conda env, but it creates from java code an executable shell script:
the following code is executed:
[https://github.com/apache/zeppelin/blob/master/zeppelin-jupyter-interpreter/src/main/java/org/apache/zeppelin/jupyter/JupyterKernelInterpreter.java#L199]
{code:java}
private String activateCondaEnv(String envName) throws IOException {
...
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); }
...
} {code}
In common case this is very nice and work well.
But in my use case, we have multiple conda envs, I cant add it in the Dockerfile (> 4G). We use "conda pack" to create tar archive, then "wget" from the container to download and "tar -xzf" to install the conda env.
I am wondering, if the shell script created by java could be a simple file inside "/opt/zeppelin/bin":
{code:java}
conda-activate-env.sh:
chmod 777 -R /opt/conda/envs/$1
source /opt/conda/envs/$1/bin/activate
conda-unpack{code}
So this is possible to override the file and change this behavior easily, in my case:
{code:java}
conda-activate-env.sh:
cd /tmp
wget https://conda-envs/$1.tar.gz
mkdir -p /opt/conda/envs/$1
tar -xzf $1.tar.gz -C /opt/conda/envs/$1/
chmod 777 -R /opt/conda/envs/$1
source /opt/conda/envs/$1/bin/activate{code}
I can do a PR very soon
--
This message was sent by Atlassian Jira
(v8.20.10#820010)