toree-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mariusvniek...@apache.org
Subject [02/15] incubator-toree git commit: Moving language_info to the interpreter, maintaining current values
Date Mon, 07 Nov 2016 14:29:25 GMT
Moving language_info to the interpreter, maintaining current values


Project: http://git-wip-us.apache.org/repos/asf/incubator-toree/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-toree/commit/a0646adc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-toree/tree/a0646adc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-toree/diff/a0646adc

Branch: refs/heads/master
Commit: a0646adc172e38bfbd60cb710a8a49fc0c6e3fc7
Parents: 1ed5821
Author: Liam Fisk <liamfisk@xtra.co.nz>
Authored: Sun Jun 19 11:19:24 2016 +1200
Committer: Marius van Niekerk <marius.vanniekerk@maxpoint.com>
Committed: Thu Oct 20 17:50:56 2016 -0400

----------------------------------------------------------------------
 .../main/scala/org/apache/toree/interpreter/Interpreter.scala  | 6 ++++++
 .../src/main/scala/org/apache/toree/boot/KernelBootstrap.scala | 2 +-
 .../org/apache/toree/boot/layer/HandlerInitialization.scala    | 6 +++---
 .../kernel/protocol/v5/handler/KernelInfoRequestHandler.scala  | 4 ++--
 .../protocol/v5/handler/KernelInfoRequestHandlerSpec.scala     | 2 +-
 kernel/src/test/scala/test/utils/DummyInterpreter.scala        | 3 +++
 .../org/apache/toree/kernel/protocol/v5/SparkKernelInfo.scala  | 4 ++--
 .../toree/kernel/interpreter/pyspark/PySparkInterpreter.scala  | 3 +++
 .../toree/kernel/interpreter/scala/ScalaInterpreter.scala      | 4 ++++
 .../toree/kernel/interpreter/sparkr/SparkRInterpreter.scala    | 4 ++++
 .../apache/toree/kernel/interpreter/sql/SqlInterpreter.scala   | 4 ++++
 11 files changed, 33 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala
----------------------------------------------------------------------
diff --git a/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala b/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala
index 84d0e70..986a506 100644
--- a/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala
+++ b/kernel-api/src/main/scala/org/apache/toree/interpreter/Interpreter.scala
@@ -128,4 +128,10 @@ trait Interpreter {
    * @return The runtime class loader used by this interpreter
    */
   def classLoader: ClassLoader
+
+  /**
+    * Returns the language metadata for syntax highlighting
+    */
+  def languageInfo: Map[String, String]
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/kernel/src/main/scala/org/apache/toree/boot/KernelBootstrap.scala
----------------------------------------------------------------------
diff --git a/kernel/src/main/scala/org/apache/toree/boot/KernelBootstrap.scala b/kernel/src/main/scala/org/apache/toree/boot/KernelBootstrap.scala
index 938ccd7..7e393c4 100644
--- a/kernel/src/main/scala/org/apache/toree/boot/KernelBootstrap.scala
+++ b/kernel/src/main/scala/org/apache/toree/boot/KernelBootstrap.scala
@@ -174,7 +174,7 @@ class KernelBootstrap(config: Config) extends LogLike {
 
   @inline private def displayVersionInfo() = {
     logger.info("Kernel version: " + SparkKernelInfo.implementationVersion)
-    logger.info("Scala version: " + SparkKernelInfo.language_info.get("version"))
+    logger.info("Scala version: " + SparkKernelInfo.scalaVersion)
     logger.info("ZeroMQ (JeroMQ) version: " + ZMQ.getVersionString)
   }
 }

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/kernel/src/main/scala/org/apache/toree/boot/layer/HandlerInitialization.scala
----------------------------------------------------------------------
diff --git a/kernel/src/main/scala/org/apache/toree/boot/layer/HandlerInitialization.scala
b/kernel/src/main/scala/org/apache/toree/boot/layer/HandlerInitialization.scala
index 572da8d..e4407fd 100644
--- a/kernel/src/main/scala/org/apache/toree/boot/layer/HandlerInitialization.scala
+++ b/kernel/src/main/scala/org/apache/toree/boot/layer/HandlerInitialization.scala
@@ -86,7 +86,7 @@ trait StandardHandlerInitialization extends HandlerInitialization {
     responseMap: collection.mutable.Map[String, ActorRef]
   ): Unit = {
     initializeKernelHandlers(
-      actorSystem, actorLoader, kernel, commRegistrar, commStorage, responseMap
+      actorSystem, actorLoader, interpreter, kernel, commRegistrar, commStorage, responseMap
     )
     initializeSystemActors(
       actorSystem, actorLoader, interpreter, pluginManager, magicManager
@@ -117,7 +117,7 @@ trait StandardHandlerInitialization extends HandlerInitialization {
 
   private def initializeKernelHandlers(
     actorSystem: ActorSystem, actorLoader: ActorLoader,
-    kernel: Kernel,
+    interpreter: Interpreter, kernel: Kernel,
     commRegistrar: CommRegistrar, commStorage: CommStorage,
     responseMap: collection.mutable.Map[String, ActorRef]
   ): Unit = {
@@ -161,7 +161,7 @@ trait StandardHandlerInitialization extends HandlerInitialization {
     initializeRequestHandler(classOf[ExecuteRequestHandler],
       MessageType.Incoming.ExecuteRequest, kernel)
     initializeRequestHandler(classOf[KernelInfoRequestHandler],
-      MessageType.Incoming.KernelInfoRequest)
+      MessageType.Incoming.KernelInfoRequest, interpreter.languageInfo)
     initializeRequestHandler(classOf[CommInfoRequestHandler],
       MessageType.Incoming.CommInfoRequest, commStorage)
     initializeRequestHandler(classOf[CodeCompleteHandler],

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandler.scala
----------------------------------------------------------------------
diff --git a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandler.scala
b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandler.scala
index f27773e..a4dd329 100644
--- a/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandler.scala
+++ b/kernel/src/main/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandler.scala
@@ -28,7 +28,7 @@ import scala.concurrent._
  * Receives a KernelInfoRequest KernelMessage and returns a KernelInfoReply
  * KernelMessage.
  */
-class KernelInfoRequestHandler(actorLoader: ActorLoader)
+class KernelInfoRequestHandler(actorLoader: ActorLoader, languageInfo: Map[String, String])
   extends BaseHandler(actorLoader) with LogLike
 {
   def process(kernelMessage: KernelMessage): Future[_] = {
@@ -41,7 +41,7 @@ class KernelInfoRequestHandler(actorLoader: ActorLoader)
         kernelInfo.protocolVersion,
         kernelInfo.implementation,
         kernelInfo.implementationVersion,
-        kernelInfo.language_info,
+        languageInfo, // TODO permit arbitrary JSON serializable object here (rather than
Map)
         kernelInfo.banner
       )
 

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala
----------------------------------------------------------------------
diff --git a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala
b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala
index b4bd912..a96a22a 100644
--- a/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala
+++ b/kernel/src/test/scala/org/apache/toree/kernel/protocol/v5/handler/KernelInfoRequestHandlerSpec.scala
@@ -42,7 +42,7 @@ class KernelInfoRequestHandlerSpec extends TestKit(
     ConfigFactory.parseString(KernelInfoRequestHandlerSpec.config))
 ) with ImplicitSender with FunSpecLike with Matchers with MockitoSugar {
   val actorLoader: ActorLoader =  mock[ActorLoader]
-  val actor = system.actorOf(Props(classOf[KernelInfoRequestHandler], actorLoader))
+  val actor = system.actorOf(Props(classOf[KernelInfoRequestHandler], actorLoader, Map.empty))
 
   val relayProbe : TestProbe = TestProbe()
   val relaySelection : ActorSelection =

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/kernel/src/test/scala/test/utils/DummyInterpreter.scala
----------------------------------------------------------------------
diff --git a/kernel/src/test/scala/test/utils/DummyInterpreter.scala b/kernel/src/test/scala/test/utils/DummyInterpreter.scala
index a4adedd..2dbe7f4 100644
--- a/kernel/src/test/scala/test/utils/DummyInterpreter.scala
+++ b/kernel/src/test/scala/test/utils/DummyInterpreter.scala
@@ -113,4 +113,7 @@ class DummyInterpreter(kernel: KernelLike) extends Interpreter {
    * @return The newly initialized interpreter
    */
   override def init(kernel: KernelLike): Interpreter = ???
+
+  override def languageInfo: Map[String, String] = Map.empty
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/SparkKernelInfo.scala
----------------------------------------------------------------------
diff --git a/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/SparkKernelInfo.scala
b/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/SparkKernelInfo.scala
index 622d5ed..52ad0d7 100644
--- a/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/SparkKernelInfo.scala
+++ b/protocol/src/main/scala/org/apache/toree/kernel/protocol/v5/SparkKernelInfo.scala
@@ -36,9 +36,9 @@ object SparkKernelInfo {
   val implementationVersion   = BuildInfo.version
 
   /**
-   * Represents the language supported by the kernel.
+   * Represents the scala version.
    */
-  val language_info           = Map("name" -> "scala", "version" -> BuildInfo.scalaVersion)
+  val scalaVersion            = BuildInfo.scalaVersion
 
   /**
    * Represents the displayed name of the kernel.

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/pyspark-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/pyspark/PySparkInterpreter.scala
----------------------------------------------------------------------
diff --git a/pyspark-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/pyspark/PySparkInterpreter.scala
b/pyspark-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/pyspark/PySparkInterpreter.scala
index 9b59c73..6b6b2fd 100644
--- a/pyspark-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/pyspark/PySparkInterpreter.scala
+++ b/pyspark-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/pyspark/PySparkInterpreter.scala
@@ -21,6 +21,7 @@ import java.net.URL
 import org.apache.toree.interpreter.Results.Result
 import org.apache.toree.interpreter._
 import org.apache.toree.kernel.api.KernelLike
+import org.apache.toree.kernel.BuildInfo
 import org.slf4j.LoggerFactory
 import py4j.GatewayServer
 
@@ -148,4 +149,6 @@ class PySparkInterpreter(
   // Unsupported
   override def doQuietly[T](body: => T): T = ???
 
+  override def languageInfo: Map[String, String] = Map("name" -> "scala", "version" ->
BuildInfo.scalaVersion)
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
----------------------------------------------------------------------
diff --git a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
index 33fa861..4df3158 100644
--- a/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
+++ b/scala-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/scala/ScalaInterpreter.scala
@@ -31,6 +31,7 @@ import org.apache.toree.interpreter._
 import org.apache.toree.kernel.api.{KernelLike, KernelOptions}
 import org.apache.toree.utils.{MultiOutputStream, TaskManager}
 import org.slf4j.LoggerFactory
+import org.apache.toree.kernel.BuildInfo
 
 import scala.annotation.tailrec
 import scala.concurrent.{Await, Future}
@@ -336,5 +337,8 @@ object ScalaInterpreter {
     outputDir
   }
 
+
+  override def languageInfo: Map[String, String] = Map("name" -> "scala", "version" ->
BuildInfo.scalaVersion)
+
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/sparkr-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sparkr/SparkRInterpreter.scala
----------------------------------------------------------------------
diff --git a/sparkr-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sparkr/SparkRInterpreter.scala
b/sparkr-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sparkr/SparkRInterpreter.scala
index 91b4b7b..2c21a54 100644
--- a/sparkr-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sparkr/SparkRInterpreter.scala
+++ b/sparkr-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sparkr/SparkRInterpreter.scala
@@ -21,6 +21,7 @@ import java.net.URL
 import org.apache.toree.interpreter.Results.Result
 import org.apache.toree.interpreter._
 import org.apache.toree.kernel.api.KernelLike
+import org.apache.toree.kernel.BuildInfo
 import org.slf4j.LoggerFactory
 
 import scala.concurrent.Await
@@ -137,4 +138,7 @@ class SparkRInterpreter(
 
   // Unsupported
   override def doQuietly[T](body: => T): T = ???
+
+  override def languageInfo: Map[String, String] = Map("name" -> "scala", "version" ->
BuildInfo.scalaVersion)
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-toree/blob/a0646adc/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala
----------------------------------------------------------------------
diff --git a/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala
b/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala
index ad7f684..90d211e 100644
--- a/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala
+++ b/sql-interpreter/src/main/scala/org/apache/toree/kernel/interpreter/sql/SqlInterpreter.scala
@@ -21,6 +21,7 @@ import java.net.URL
 import org.apache.toree.interpreter.Results.Result
 import org.apache.toree.interpreter.{ExecuteFailure, ExecuteOutput, Interpreter}
 import org.apache.toree.kernel.api.KernelLike
+import org.apache.toree.kernel.BuildInfo
 
 import scala.concurrent.Await
 import scala.concurrent.duration._
@@ -105,4 +106,7 @@ class SqlInterpreter() extends Interpreter {
 
   // Unsupported
   override def doQuietly[T](body: => T): T = ???
+
+  override def languageInfo: Map[String, String] = Map("name" -> "scala", "version" ->
BuildInfo.scalaVersion)
+
 }


Mime
View raw message