Skip to content

Commit

Permalink
Merge pull request #41 from patrick-nicholson/scala-magic-quickfix
Browse files Browse the repository at this point in the history
Bugfix for #28
  • Loading branch information
parente authored Aug 23, 2017
2 parents c857768 + 0c74cd9 commit d880daf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
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
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

0 comments on commit d880daf

Please sign in to comment.