You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@livy.apache.org by wangqiaoshi <gi...@git.apache.org> on 2018/10/08 07:53:14 UTC

[GitHub] incubator-livy pull request #119: added autocompletion api and implementatio...

GitHub user wangqiaoshi opened a pull request:

    https://github.com/apache/incubator-livy/pull/119

    added autocompletion api and implementation for ipython

    ## What changes were proposed in this pull request?
    
    (Please fill in changes proposed in this fix)
    Iinclude a link to the associated JIRA and make sure to add a link to this pr on the JIRA as well)
    
    ## How was this patch tested?
    
    (Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
    (If this patch involves UI changes, please attach a screenshot; otherwise, remove this)
    
    Please review https://livy.incubator.apache.org/community/ before opening a pull request.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/wangqiaoshi/incubator-livy master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-livy/pull/119.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #119
    
----
commit da2c07af33b1c4b38c1cc39668b662a506f4e373
Author: qiaoshi.wang <qi...@...>
Date:   2018-10-08T07:34:35Z

    add pyspark Completion function

----


---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243101650
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -195,6 +211,28 @@ def processBypassJob(self, serialized_job):
         def addFile(self, uri_path):
             job_context.sc.addFile(uri_path)
     
    +
    +
    +
    +    def complete(self,code,cursor_pos=None):
    +        results = []
    +        ip_completer =global_dict.get('ip_completer')
    +        p_completer = global_dict.get("p_completer")
    +        if ip_completer is not None:
    +            results = ip_completer.complete(code,cursor_pos=cursor_pos)[1]
    --- End diff --
    
    space after `,`


---

[GitHub] incubator-livy issue #119: added autocompletion api and implementation for i...

Posted by codecov-io <gi...@git.apache.org>.
Github user codecov-io commented on the issue:

    https://github.com/apache/incubator-livy/pull/119
  
    # [Codecov](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=h1) Report
    > Merging [#119](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=desc) into [master](https://codecov.io/gh/apache/incubator-livy/commit/d87a34872069107329b67940d193c2962cf2026d?src=pr&el=desc) will **decrease** coverage by `<.01%`.
    > The diff coverage is `0%`.
    
    [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-livy/pull/119/graphs/tree.svg?width=650&token=0MkVbiUFwE&height=150&src=pr)](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=tree)
    
    ```diff
    @@             Coverage Diff              @@
    ##             master     #119      +/-   ##
    ============================================
    - Coverage     70.94%   70.93%   -0.01%     
      Complexity      922      922              
    ============================================
      Files           100      100              
      Lines          5500     5502       +2     
      Branches        828      828              
    ============================================
    + Hits           3902     3903       +1     
    - Misses         1062     1064       +2     
    + Partials        536      535       -1
    ```
    
    
    | [Impacted Files](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=tree) | Coverage Δ | Complexity Δ | |
    |---|---|---|---|
    | [...scala/org/apache/livy/repl/PythonInterpreter.scala](https://codecov.io/gh/apache/incubator-livy/pull/119/diff?src=pr&el=tree#diff-cmVwbC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpdnkvcmVwbC9QeXRob25JbnRlcnByZXRlci5zY2FsYQ==) | `47.53% <0%> (-0.6%)` | `9 <0> (ø)` | |
    | [...main/scala/org/apache/livy/server/LivyServer.scala](https://codecov.io/gh/apache/incubator-livy/pull/119/diff?src=pr&el=tree#diff-c2VydmVyL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvbGl2eS9zZXJ2ZXIvTGl2eVNlcnZlci5zY2FsYQ==) | `34.83% <0%> (-0.57%)` | `9% <0%> (ø)` | |
    | [...c/main/scala/org/apache/livy/repl/ReplDriver.scala](https://codecov.io/gh/apache/incubator-livy/pull/119/diff?src=pr&el=tree#diff-cmVwbC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpdnkvcmVwbC9SZXBsRHJpdmVyLnNjYWxh) | `33.33% <0%> (+2.56%)` | `7% <0%> (ø)` | :arrow_down: |
    | [.../scala/org/apache/livy/sessions/SessionState.scala](https://codecov.io/gh/apache/incubator-livy/pull/119/diff?src=pr&el=tree#diff-Y29yZS9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2xpdnkvc2Vzc2lvbnMvU2Vzc2lvblN0YXRlLnNjYWxh) | `61.11% <0%> (+2.77%)` | `2% <0%> (ø)` | :arrow_down: |
    
    ------
    
    [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=continue).
    > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
    > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
    > Powered by [Codecov](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=footer). Last update [d87a348...039a63a](https://codecov.io/gh/apache/incubator-livy/pull/119?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).



---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243101498
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -49,6 +49,22 @@
     
     TOP_FRAME_REGEX = re.compile(r'\s*File "<stdin>".*in <module>')
     
    +def get_completer():
    +    try:
    +        __IPYTHON__
    +        from IPython.core.completer import IPCompleter
    +        ip = get_ipython()
    +        ip_completer = IPCompleter(ip,global_namespace=global_dict)
    +        global_dict['ip_completer'] = ip_completer
    --- End diff --
    
    Does the completer need to be visible to user statements? Otherwise it seems you can just use a regular global variable (like `job_context` or `local_tmp_dir_path` in this file).


---

[GitHub] incubator-livy issue #119: added autocompletion api and implementation for i...

Posted by wangqiaoshi <gi...@git.apache.org>.
Github user wangqiaoshi commented on the issue:

    https://github.com/apache/incubator-livy/pull/119
  
    ### Fix the bug : The completion function doesn't work in pyspark kind.
    description:
    when pyspark run in  ipython environment , kind pyspark completion work.
    this pr add  complete function in PySparkJobProcessor interface,  so ReplDriver can get completion message from python
    
    ### How was this patch tested?
    
    1. post /sessions/{sessionId}/completion
    set kind=pyspark


---

[GitHub] incubator-livy issue #119: added autocompletion api and implementation for i...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the issue:

    https://github.com/apache/incubator-livy/pull/119
  
    Please follow the guidelines in the contribution guide (linked in the PR template). Mainly:
    - file a bug with a description of the problem / feature
    - provide a proper description of your PR (which will be the commit message when merged).


---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243100751
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -195,6 +211,28 @@ def processBypassJob(self, serialized_job):
         def addFile(self, uri_path):
             job_context.sc.addFile(uri_path)
     
    +
    --- End diff --
    
    That's a lot of blank lines. Surprising the style checker didn't complain. Should be one line between methods.


---

[GitHub] incubator-livy issue #119: added autocompletion api and implementation for i...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on the issue:

    https://github.com/apache/incubator-livy/pull/119
  
    Please follow the contribution guide. It's linked in the PR template. In case you missed it:
    https://livy.incubator.apache.org/community/
    
    You're supposed to replace the PR template with your description of the changes. And file a bug.


---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243100790
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -195,6 +211,28 @@ def processBypassJob(self, serialized_job):
         def addFile(self, uri_path):
             job_context.sc.addFile(uri_path)
     
    +
    +
    +
    +    def complete(self,code,cursor_pos=None):
    +        results = []
    +        ip_completer =global_dict.get('ip_completer')
    --- End diff --
    
    space after `=`


---

[GitHub] incubator-livy issue #119: added autocompletion api and implementation for i...

Posted by wangqiaoshi <gi...@git.apache.org>.
Github user wangqiaoshi commented on the issue:

    https://github.com/apache/incubator-livy/pull/119
  
    should set 
    spark.pyspark.python ${ipython-path}


---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243101945
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -49,6 +49,22 @@
     
     TOP_FRAME_REGEX = re.compile(r'\s*File "<stdin>".*in <module>')
     
    +def get_completer():
    +    try:
    +        __IPYTHON__
    +        from IPython.core.completer import IPCompleter
    +        ip = get_ipython()
    +        ip_completer = IPCompleter(ip,global_namespace=global_dict)
    --- End diff --
    
    space after `,`


---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243101587
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -195,6 +211,28 @@ def processBypassJob(self, serialized_job):
         def addFile(self, uri_path):
             job_context.sc.addFile(uri_path)
     
    +
    +
    +
    +    def complete(self,code,cursor_pos=None):
    --- End diff --
    
    space after `,`


---

[GitHub] incubator-livy pull request #119: [LIVY-527] added autocompletion api and im...

Posted by vanzin <gi...@git.apache.org>.
Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/incubator-livy/pull/119#discussion_r243101834
  
    --- Diff: repl/src/main/resources/fake_shell.py ---
    @@ -555,6 +593,7 @@ def main():
         sys.stderr = UnicodeDecodingStringIO()
     
         spark_major_version = os.getenv("LIVY_SPARK_MAJOR_VERSION")
    +    get_completer()
    --- End diff --
    
    `get` assumes something is being returned. `initialize_completer()` is probably a better name.


---