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.
|
|
||
| Returns | ||
| ------- | ||
| scala.tools.nsc.interpreter.PresentationCompilerCompleter |
There was a problem hiding this comment.
this looks almost fully qualified. Should this be: py4j.java_gateway.JVMView. scala.tools.nsc.interpreter.PresentationCompilerCompleter ?
There was a problem hiding this comment.
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.
Ah alright well fair enough then. Made up object paths, yey
| # 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.
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.
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.
| intp.interpret(name) | ||
| return intp.last_result() | ||
|
|
||
| def do_execute_direct(self, code, silent=False): |
| """ | ||
| 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.
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.
doesn't look ignored. it's passed to self._scalamagic.get_help_on()
There was a problem hiding this comment.
Ignored down in _scalamagic.get_help_on. I'll try to figure out from the metakernel source exactly how it's used.
| 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.
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.
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.
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.
The original log message had indents as well.
| 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.
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 |
| """ | ||
| 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.
what the heck. Why does this produce different results??
There was a problem hiding this comment.
That's one @mariusvniekerk will need to answer.
There was a problem hiding this comment.
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.
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.
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