diff --git a/spylon_kernel/scala_kernel.py b/spylon_kernel/scala_kernel.py index 8530428..5f94833 100644 --- a/spylon_kernel/scala_kernel.py +++ b/spylon_kernel/scala_kernel.py @@ -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 ''} \ No newline at end of file + return {'status': status, 'indent': ' ' * 4 if status == 'incomplete' else ''} diff --git a/spylon_kernel/scala_magic.py b/spylon_kernel/scala_magic.py index 42b87e6..14e6f27 100644 --- a/spylon_kernel/scala_magic.py +++ b/spylon_kernel/scala_magic.py @@ -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 @@ -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): @@ -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