Skip to content
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

Bugfix for #28 #41

Merged
merged 1 commit into from
Aug 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spylon_kernel/scala_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,4 @@ def do_is_complete(self, code):
status = self.scala_interpreter.is_complete(code)
# TODO: We can probably do a better job of detecting a good indent
# level here by making use of a code parser such as pygments
return {'status': status, 'indent': ' ' * 4 if status == 'incomplete' else ''}
return {'status': status, 'indent': ' ' * 4 if status == 'incomplete' else ''}
10 changes: 6 additions & 4 deletions spylon_kernel/scala_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from tornado import ioloop, gen
from textwrap import dedent

from .scala_interpreter import get_scala_interpreter, ScalaException
from .scala_interpreter import get_scala_interpreter, scala_intp, ScalaException
from . import scala_interpreter


Expand All @@ -29,7 +29,7 @@ class ScalaMagic(Magic):
def __init__(self, kernel):
super(ScalaMagic, self).__init__(kernel)
self.retval = None
self._interp = None
self._interp = scala_intp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Is this really needed? _get_scala_interpreter initializes this variable by calling get_scala_interpreter() instead of reaching in and grabbing the global directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not necessary. It's really just to avoid the messaging, etc. around using the magic for the first time if an interpreter already exists.

self._is_complete_ready = False

def _get_scala_interpreter(self):
Expand All @@ -44,9 +44,11 @@ def _get_scala_interpreter(self):
assert isinstance(self.kernel, MetaKernel)
self.kernel.Display(TextOutput("Intitializing Scala interpreter ..."))
self._interp = get_scala_interpreter()

# Ensure that spark is available in the python session as well.
self.kernel.cell_magics['python'].env['spark'] = self._interp.spark_session
self.kernel.cell_magics['python'].env['sc'] = self._interp.sc
if 'python' in self.kernel.cell_magics: # tests if in scala mode
self.kernel.cell_magics['python'].env['spark'] = self._interp.spark_session
self.kernel.cell_magics['python'].env['sc'] = self._interp.sc

# Display some information about the Spark session
sc = self._interp.sc
Expand Down