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 2023/01/12 03:31:18 UTC

[GitHub] [zeppelin] 3792274 commented on pull request #1868: [ZEPPELIN-1917] Improve python.conda interpreter

3792274 commented on PR #1868:
URL: https://github.com/apache/zeppelin/pull/1868#issuecomment-1379767545

   > ### What is this PR for?
   > Add missing commands to the `python.conda` interpreter
   > 
   > * `conda info`
   > * `conda list`
   > * `conda create`
   > * `conda install`
   > * `conda uninstall (alias of remove)`
   > * `conda env *`
   > 
   > #### Implementation Detail
   > The reason I modified `PythonProcess` is due to NPE
   > 
   > ```java
   > // https://github.com/apache/zeppelin/blob/master/python/src/main/java/org/apache/zeppelin/python/PythonProcess.java#L107-L118
   > 
   > 
   >   public String sendAndGetResult(String cmd) throws IOException {
   >     writer.println(cmd);
   >     writer.println();
   >     writer.println("\"" + STATEMENT_END + "\"");
   >     StringBuilder output = new StringBuilder();
   >     String line = null;
   > 
   >     // NPE when line is null
   >     while (!(line = reader.readLine()).contains(STATEMENT_END)) {
   >       logger.debug("Read line from python shell : " + line);
   >       output.append(line + "\n");
   >     }
   >     return output.toString();
   >   }
   > ```
   > 
   > ```
   > java.lang.NullPointerException
   > at org.apache.zeppelin.python.PythonProcess.sendAndGetResult(PythonProcess.java:113)
   > at org.apache.zeppelin.python.PythonInterpreter.sendCommandToPython(PythonInterpreter.java:250)
   > at org.apache.zeppelin.python.PythonInterpreter.bootStrapInterpreter(PythonInterpreter.java:272)
   > at org.apache.zeppelin.python.PythonInterpreter.open(PythonInterpreter.java:100)
   > at org.apache.zeppelin.python.PythonCondaInterpreter.restartPythonProcess(PythonCondaInterpreter.java:139)
   > at org.apache.zeppelin.python.PythonCondaInterpreter.interpret(PythonCondaInterpreter.java:88)
   > at org.apache.zeppelin.interpreter.LazyOpenInterpreter.interpret(LazyOpenInterpreter.java:94)
   > at org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer$InterpretJob.jobRun(RemoteInterpreterServer.java:494)
   > at org.apache.zeppelin.scheduler.Job.run(Job.java:175)
   > at org.apache.zeppelin.scheduler.FIFOScheduler$1.run(FIFOScheduler.java:139)
   > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
   > at java.util.concurrent.FutureTask.run(FutureTask.java:262)
   > at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
   > at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
   > at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
   > at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
   > at java.lang.Thread.run(Thread.java:745)
   > ```
   > 
   > ### What type of PR is it?
   > [Improvement | Refactoring]
   > 
   > ### Todos
   > * [x]  - info
   > * [x]  - list
   > * [x]  - create
   > * [x]  - install
   > * [x]  - uninstall (= remove)
   > * [x]  - env *
   > 
   > ### What is the Jira issue?
   > [ZEPPELIN-1917](https://issues.apache.org/jira/browse/ZEPPELIN-1917)
   > 
   > ### How should this be tested?
   > 1. Install [miniconda](http://conda.pydata.org/miniconda.html)
   > 2. Make sure that your python interpreter can use `conda` (check the Interpreter Binding page)
   > 3. Remove `test` conda env since we will create in the following section
   > 
   > ```shell
   > $ conda env remove --yes --name test
   > ```
   > 
   > 4. Run these commands with `%python.conda`
   > 
   > ```
   > %python.conda info
   > %python.conda env list
   > %python.conda create --name test
   > 
   > # you should be able to see `test` in the list
   > %python.conda env list
   > %python.conda activate pymysql
   > %python.conda install pymysql
   > 
   > # you should be able to import
   > %python
   > import pymysql.cursors
   > 
   > %python.conda uninstall pymysql
   > %python.conda deactivate pymysql
   > 
   > # you should be able to see `No module named pymysql.cursor` since we deactivated
   > %python
   > import pymysql.cursors
   > ```
   > 
   > ### Screenshots (if appropriate)
   > ![conda-screenshot](https://cloud.githubusercontent.com/assets/4968473/21747565/98c0e366-d5ad-11e6-8000-e293996089fa.gif) [ ](https://cloud.githubusercontent.com/assets/4968473/21747565/98c0e366-d5ad-11e6-8000-e293996089fa.gif) ![conda-screenshot](https://cloud.githubusercontent.com/assets/4968473/21747565/98c0e366-d5ad-11e6-8000-e293996089fa.gif) [ ](https://cloud.githubusercontent.com/assets/4968473/21747565/98c0e366-d5ad-11e6-8000-e293996089fa.gif)
   > 
   > ### Questions:
   > * Does the licenses files need update? - NO
   > * Is there breaking changes for older versions? - NO
   > * Does this needs documentation? - NO
   
   
   
   
   **how to remove the html tag?**
   
   
   ![111](https://user-images.githubusercontent.com/19231863/211969319-67c06c40-434d-4c8a-a8a3-9171f86bacbd.png)
   


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

To unsubscribe, e-mail: dev-unsubscribe@zeppelin.apache.org

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