[LIVY-527] added autocompletion api and implementation for ipython#119
[LIVY-527] added autocompletion api and implementation for ipython#119wangqiaoshi wants to merge 5 commits into
Conversation
|
should set |
Codecov Report
@@ Coverage Diff @@
## master #119 +/- ##
============================================
- Coverage 70.94% 68.49% -2.45%
+ Complexity 922 893 -29
============================================
Files 100 100
Lines 5500 5606 +106
Branches 828 840 +12
============================================
- Hits 3902 3840 -62
- Misses 1062 1214 +152
- Partials 536 552 +16
Continue to review full report at Codecov.
|
|
Please follow the guidelines in the contribution guide (linked in the PR template). Mainly:
|
Fix the bug : The completion function doesn't work in pyspark kind.description: How was this patch tested?
|
|
Please follow the contribution guide. It's linked in the PR template. In case you missed it: You're supposed to replace the PR template with your description of the changes. And file a bug. |
vanzin
left a comment
There was a problem hiding this comment.
Some style issues, otherwise looks ok.
Can a test be written for this (e.g. in InteractiveIT)? Not sure how easy it is to hit the completion API from tests.
| def addFile(self, uri_path): | ||
| job_context.sc.addFile(uri_path) | ||
|
|
||
|
|
There was a problem hiding this comment.
That's a lot of blank lines. Surprising the style checker didn't complain. Should be one line between methods.
|
|
||
| def complete(self,code,cursor_pos=None): | ||
| results = [] | ||
| ip_completer =global_dict.get('ip_completer') |
| from IPython.core.completer import IPCompleter | ||
| ip = get_ipython() | ||
| ip_completer = IPCompleter(ip,global_namespace=global_dict) | ||
| global_dict['ip_completer'] = ip_completer |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Completer will be different when python interpreter is different. The number of completer global variable will be two,I don't know if that's appropriate?
There was a problem hiding this comment.
I see what you mean (ip_completer vs. p_completer).
I think it would be better to keep a single variable for the completer, and a boolean that says whether to use the IPython API.
But my main question was: do they need to be stored in global_dict or can they just be a global variable in this module instead?
|
|
||
|
|
||
|
|
||
| def complete(self,code,cursor_pos=None): |
| 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] |
| sys.stderr = UnicodeDecodingStringIO() | ||
|
|
||
| spark_major_version = os.getenv("LIVY_SPARK_MAJOR_VERSION") | ||
| get_completer() |
There was a problem hiding this comment.
get assumes something is being returned. initialize_completer() is probably a better name.
| __IPYTHON__ | ||
| from IPython.core.completer import IPCompleter | ||
| ip = get_ipython() | ||
| ip_completer = IPCompleter(ip,global_namespace=global_dict) |
|
ping @wangqiaoshi - that's a great improvement! |
ok |
I have a doubt, |
|
Sorry, totally missed your question. I'm also not sure I understand the question. It would be really good to have some test for this. It doesn't need to be an integration tests, but it needs to be tested somehow. Otherwise the changes look good. |
|
What's the plan to merge this? |
|
Yes, it would be nice to implement this feature 👍 |
|
ping @wangqiaoshi |
|
Hi @wangqiaoshi , any plan to merge this ? |
|
Hi @wangqiaoshi, you would be doing a great favor for a lot of people if you could merge this. |
|
Hello @wangqiaoshi , |
|
Hello @wangqiaoshi |
|
Any updates on merging this feature @wangqiaoshi ? |
| def initialize_completer(): | ||
| global ip_completer,p_completer | ||
| try: | ||
| __IPYTHON__ |
There was a problem hiding this comment.
@wangqiaoshi Since fake_shell runs within a standard python process and not within an ipython shell, how will IPCompleter be initialized?
|
Any updates on merging this feature @wangqiaoshi @vanzin ? |
|
Anyone? |
|
This pull request has been automatically marked as stale because it has had no activity for at least 3 months. If you are still working on this change or plan to move it forward, please leave a comment or push a new commit so we know to keep it open. Otherwise, this PR will be closed automatically in about one month. Thank you for your contribution to Apache Livy! |
What changes were proposed in this pull request?
add complete function in PySparkJobProcessor interface, so ReplDriver can get completion message from python
How was this patch tested?
post /sessions/{sessionId}/completion
set kind=pyspark