-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General cleanup take #2 #30
Conversation
* Document scala_kernel * Rename SparkInterpreter to ScalaInterpreter for consistency with the factory function and module name
Codecov Report
@@ Coverage Diff @@
## master #30 +/- ##
==========================================
+ Coverage 84.31% 84.36% +0.05%
==========================================
Files 6 6
Lines 408 403 -5
==========================================
- Hits 344 340 -4
+ Misses 64 63 -1 |
All or nothing. Nothing for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gods work, my friend. Gods work.
|
||
Returns | ||
------- | ||
scala.tools.nsc.interpreter.PresentationCompilerCompleter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks almost fully qualified. Should this be: py4j.java_gateway.JVMView. scala.tools.nsc.interpreter.PresentationCompilerCompleter
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scala.tools.nsc.interpreter.PresentationCompilerCompleter
is the Scala type. py4j.java_gateway.JVMView
is a made up namespace which allows Python code to reference them I believe. There is no real Python module+type py4j.java_gateway.JVMView. scala.tools.nsc.interpreter.PresentationCompilerCompleter
.
What to do, what to do ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah alright well fair enough then. Made up object paths, yey
# don't actually want that to happen. Simplest is just to have this | ||
# flag as None initially. Furthermore the metakernel will attempt to | ||
# set things like _i1, _i, _ii etc. These we dont want in the kernel | ||
# for now. | ||
if self._scalamagic and (not name.startswith("_i")): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are your feelings on logging attempts to set _i...
variables? I'm generally 👎 on silent behavior changes but also don't have a clue how metakernel stuff works, so 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will happen after almost every cell execution as MetaKernel will update the FIFO queue of commands and outputs, so the logs will get pretty chatty. We could log at the debug level.
Returns | ||
------- | ||
value : any | ||
Scala variable value, tranformed to a Python type | ||
""" | ||
if self._scalamagic: | ||
intp = self.scala_interpreter | ||
intp.interpret(name) | ||
return intp.last_result() | ||
|
||
def do_execute_direct(self, code, silent=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this extra kwarg?
------- | ||
list of str | ||
Possible completions for the code | ||
""" | ||
return self._scalamagic.get_completions(info) | ||
|
||
def get_kernel_help_on(self, info, level=0, none_on_fail=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another spurious kwarg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed in person, will doc how these are all implementing the expected MetaKernel interface.
spylon_kernel/scala_kernel.py
Outdated
level : int | ||
Level of help to request, 0 for basic, 1 for more, etc. | ||
none_on_fail : bool | ||
Ignored |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't look ignored. it's passed to self._scalamagic.get_help_on()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignored down in _scalamagic.get_help_on
. I'll try to figure out from the metakernel source exactly how it's used.
"""Due to the nature of scala's completer we get full method names. | ||
We need to trim out the common pieces. Try longest prefix first etc | ||
"""Due to the nature of Scala's completer we get full method names. | ||
We need to trim out the common pieces. Try longest prefix first, etc. | ||
""" | ||
potential_prefix = os.path.commonprefix(completions) | ||
for i in reversed(range(len(potential_prefix)+1)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance for adding some in-line comments on this code block? My brain is getting angry with me when I try and parse this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passing on this one for now. I'll need to create some examples to really document this well.
spylon_kernel/scala_magic.py
Outdated
final_completions = [prefix + h[offset:] for h in completions] | ||
self.kernel.log.debug('''info %s | ||
completions %s | ||
final %s''', info, completions, final_completions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to dedent this? I think this will render as:
info <info>
completions <completions>
final <final>
but not 100% certain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original log message had indents as well.
spylon_kernel/scala_magic.py
Outdated
Information returned by `metakernel.parser.Parser.parse_code` | ||
including `help_obj`, etc. | ||
level : int | ||
Level of help to request, 0 for basic, 1 for more, etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how high can this number go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Infinity. It's by convention. I'll make note of that.
spylon_kernel/scala_magic.py
Outdated
info : dict | ||
Information returned by `metakernel.parser.Parser.parse_code` | ||
including `help_obj`, etc. | ||
level : int |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int, optional
------- | ||
str | ||
Help text | ||
""" | ||
intp = self._get_scala_interpreter() | ||
self.kernel.log.debug(info['help_obj']) | ||
# Calling this twice produces different output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what the heck. Why does this produce different results??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's one @mariusvniekerk will need to answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically it's pretty heavily assumed that this is used in the scala repl. So it is the same call for two tabs. It is kinda mad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, press tab twice for more details. Nice.
REPLs. REPLs all the way down.
@ericdill Ready for another look. |
|
||
Returns | ||
------- | ||
scala.tools.nsc.interpreter.PresentationCompilerCompleter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah alright well fair enough then. Made up object paths, yey
FWIW this has my blessing |
Thanks for taking the time @ericdill. |
Comments and code cleanup in the other two modules not hit in #29