Skip to content

Commit e48d434

Browse files
pan3793requaos
andauthored
[TOREE-556] Support Scala 2.13 (#218)
Support Scala 2.13 --------- Co-authored-by: Neil Skinner <[email protected]>
1 parent cdaae5e commit e48d434

File tree

94 files changed

+750
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+750
-194
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
fail-fast: false
3232
matrix:
3333
java: [ '8', '11' ]
34+
scala: [ '2.12', '2.13' ]
3435
env:
3536
# define Java options for both official sbt and sbt-extras
3637
JAVA_OPTS: -Xms2048M -Xmx2048M -Xss6M -XX:ReservedCodeCacheSize=256M -Dfile.encoding=UTF-8
@@ -54,14 +55,14 @@ jobs:
5455
uses: sbt/setup-sbt@v1
5556
- name: Build
5657
run: |
57-
make clean release
58+
make SCALA_VERSION=${{ matrix.scala }} clean release
5859
- name: Run tests
5960
run: |
60-
make test
61+
make SCALA_VERSION=${{ matrix.scala }} test
6162
# See https://issues.apache.org/jira/browse/TOREE-526
6263
# - name: Run system tests
6364
# run: |
64-
# make system-test
65-
- name: Run license eudit
65+
# make SCALA_VERSION=${{ matrix.scala }} system-test
66+
- name: Run license audit
6667
run: |
67-
make audit-licenses
68+
make SCALA_VERSION=${{ matrix.scala }} audit-licenses

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RUN curl -sL https://deb.nodesource.com/setup_0.12 | bash - && \
2727

2828
# for Apache Spark demos
2929
ENV APACHE_SPARK_VERSION 3.4.4
30-
ENV APACHE_SPARK_CUSTOM_NAME=hadoop3
30+
ARG SCALA_VERSION=2.12
3131

3232
RUN apt-get -y update && \
3333
apt-get -y install software-properties-common
@@ -47,11 +47,11 @@ RUN echo "===> install Java" && \
4747
update-java-alternatives -s java-8-oracle
4848

4949
RUN cd /tmp && \
50+
if [ "$SCALA_VERSION" = "2.13" ]; then APACHE_SPARK_CUSTOM_NAME=hadoop3-scala2.13; else APACHE_SPARK_CUSTOM_NAME=hadoop3; fi && \
5051
wget -q https://archive.apache.org/dist/spark/spark-${APACHE_SPARK_VERSION}/spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz && \
5152
tar xzf spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz -C /usr/local && \
52-
rm spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz
53-
54-
RUN cd /usr/local && ln -s spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME} spark
53+
rm spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz && \
54+
ln -snf /usr/local/spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME} /usr/local/spark
5555

5656
# R support
5757
RUN apt-get update && \

Dockerfile.toree-dev

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ FROM jupyter/all-spark-notebook
2323
USER root
2424

2525
# Spark dependencies
26-
ENV APACHE_SPARK_VERSION 3.3.2
27-
ENV APACHE_SPARK_CUSTOM_NAME=hadoop3
26+
ARG APACHE_SPARK_VERSION=3.4.4
27+
ARG SCALA_VERSION=2.12
2828

2929
RUN apt-get -y update && \
3030
apt-get install -y --no-install-recommends openjdk-8-jdk ca-certificates-java && \
@@ -36,14 +36,11 @@ RUN apt-get -y update && \
3636

3737
# Installing Spark3
3838
RUN cd /tmp && \
39+
if [ "$SCALA_VERSION" = "2.13" ]; then APACHE_SPARK_CUSTOM_NAME=hadoop3-scala2.13; else APACHE_SPARK_CUSTOM_NAME=hadoop3; fi && \
3940
wget -q https://archive.apache.org/dist/spark/spark-${APACHE_SPARK_VERSION}/spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz && \
4041
tar xzf spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz -C /usr/local && \
41-
rm spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz
42-
43-
# Overwrite symlink
44-
RUN cd /usr/local && \
45-
rm spark && \
46-
ln -s spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME} spark
42+
rm spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME}.tgz && \
43+
ln -snf /usr/local/spark-${APACHE_SPARK_VERSION}-bin-${APACHE_SPARK_CUSTOM_NAME} /usr/local/spark
4744

4845
# Remove other scala kernels
4946
RUN cd /opt/conda/share/jupyter/kernels/ && \

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ endef
4949

5050
RUN=$(RUN_PREFIX)$(1)$(RUN_SUFFIX)
5151

52-
ENV_OPTS:=APACHE_SPARK_VERSION=$(APACHE_SPARK_VERSION) VERSION=$(VERSION) IS_SNAPSHOT=$(IS_SNAPSHOT)
52+
ENV_OPTS:=APACHE_SPARK_VERSION=$(APACHE_SPARK_VERSION) SCALA_VERSION=$(SCALA_VERSION) VERSION=$(VERSION) IS_SNAPSHOT=$(IS_SNAPSHOT)
5353

5454
ASSEMBLY_JAR:=toree-assembly-$(VERSION)$(SNAPSHOT).jar
5555

@@ -83,7 +83,10 @@ clean: clean-dist
8383
@-docker rmi -f $(TOREE_DEV_IMAGE)
8484

8585
.toree-dev-image:
86-
@docker build -t $(TOREE_DEV_IMAGE) -f Dockerfile.toree-dev .
86+
@docker build -t $(TOREE_DEV_IMAGE) -f Dockerfile.toree-dev \
87+
--build-arg APACHE_SPARK_VERSION=$(APACHE_SPARK_VERSION) \
88+
--build-arg SCALA_VERSION=$(SCALA_VERSION) \
89+
.
8790
touch $@
8891

8992
.clean-binder-image:

build.sbt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@
1818
import scala.util.Properties
1919
import sbtassembly.AssemblyOption
2020

21+
lazy val scala212 = "2.12.17"
22+
lazy val scala213 = "2.13.8"
23+
lazy val defaultScalaVersion = sys.env.get("SCALA_VERSION") match {
24+
case Some("2.13") => scala213
25+
case _ => scala212
26+
}
27+
2128
// Version settings
2229
ThisBuild / version := Properties.envOrElse("VERSION", "0.0.0-dev") +
2330
(if ((ThisBuild / isSnapshot ).value) "-SNAPSHOT" else "")
2431
ThisBuild / isSnapshot := Properties.envOrElse("IS_SNAPSHOT","true").toBoolean
2532
ThisBuild / organization := "org.apache.toree.kernel"
26-
ThisBuild / crossScalaVersions := Seq("2.12.17")
27-
ThisBuild / scalaVersion := (ThisBuild / crossScalaVersions ).value.head
33+
ThisBuild / crossScalaVersions := Seq(scala212, scala213)
34+
ThisBuild / scalaVersion := defaultScalaVersion
2835
ThisBuild / Dependencies.sparkVersion := {
2936
val envVar = "APACHE_SPARK_VERSION"
3037
val defaultVersion = "3.4.4"
@@ -44,7 +51,6 @@ ThisBuild / scalacOptions ++= Seq(
4451
"-deprecation",
4552
"-unchecked",
4653
"-feature",
47-
"-Xfatal-warnings",
4854
"-language:reflectiveCalls",
4955
"-target:jvm-1.8"
5056
)
@@ -118,7 +124,7 @@ ThisBuild / credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
118124

119125
/** Root Toree project. */
120126
lazy val root = (project in file("."))
121-
.settings(name := "toree", crossScalaVersions := Nil)
127+
.settings(name := "toree")
122128
.aggregate(
123129
macros,protocol,plugins,communication,kernelApi,client,scalaInterpreter,sqlInterpreter,kernel
124130
)
@@ -203,10 +209,7 @@ lazy val kernel = (project in file("kernel"))
203209
enablePlugins(ScalaUnidocPlugin)
204210
(ScalaUnidoc / unidoc / scalacOptions) ++= Seq(
205211
"-Ymacro-expand:none",
206-
"-skip-packages", Seq(
207-
"org.apache.pekko",
208-
"scala"
209-
).mkString(":"),
212+
"-skip-packages", "org.apache.pekko:scala",
210213
"-no-link-warnings" // Suppresses problems with Scaladoc @throws links
211214
)
212215

client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/Utilities.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import org.apache.toree.kernel.protocol.v5.content.ExecuteRequest
2626
import org.apache.toree.utils.LogLike
2727
import play.api.libs.json.{JsPath, Json, JsonValidationError, Reads}
2828

29+
import scala.collection.mutable
2930
import scala.concurrent.duration._
3031

3132
object Utilities extends LogLike {
@@ -64,7 +65,7 @@ object Utilities extends LogLike {
6465
val header = Json.parse(message.frames(delimiterIndex + 2)).as[Header]
6566
val parentHeader = Json.parse(message.frames(delimiterIndex + 3)).validate[ParentHeader].fold[ParentHeader](
6667
// TODO: Investigate better solution than setting parentHeader to null for {}
67-
(invalid: Seq[(JsPath, Seq[JsonValidationError])]) => null, //HeaderBuilder.empty,
68+
(invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) => null, //HeaderBuilder.empty,
6869
(valid: ParentHeader) => valid
6970
)
7071
val metadata = Json.parse(message.frames(delimiterIndex + 4)).as[Metadata]
@@ -78,20 +79,20 @@ object Utilities extends LogLike {
7879
}
7980

8081
implicit def KernelMessageToZMQMessage(kernelMessage : KernelMessage) : ZMQMessage = {
81-
val frames: scala.collection.mutable.ListBuffer[ByteString] = scala.collection.mutable.ListBuffer()
82-
kernelMessage.ids.map((id : Array[Byte]) => frames += ByteString.apply(id) )
82+
val frames: mutable.ListBuffer[ByteString] = mutable.ListBuffer()
83+
kernelMessage.ids.map((id: Array[Byte]) => frames += ByteString.apply(id))
8384
frames += "<IDS|MSG>"
8485
frames += kernelMessage.signature
8586
frames += Json.toJson(kernelMessage.header).toString()
8687
frames += Json.toJson(kernelMessage.parentHeader).toString()
8788
frames += Json.toJson(kernelMessage.metadata).toString
8889
frames += kernelMessage.contentString
89-
ZMQMessage(frames : _*)
90+
ZMQMessage(frames.toSeq : _*)
9091
}
9192

9293
def parseAndHandle[T](json: String, reads: Reads[T], handler: T => Unit) : Unit = {
9394
Json.parse(json).validate[T](reads).fold(
94-
(invalid: Seq[(JsPath, Seq[JsonValidationError])]) =>
95+
(invalid: collection.Seq[(JsPath, collection.Seq[JsonValidationError])]) =>
9596
logger.error(s"Could not parse JSON, ${json}"),
9697
(content: T) => handler(content)
9798
)

client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/HeartbeatClient.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class HeartbeatClient(
6060
case HeartbeatMessage =>
6161
import scala.concurrent.ExecutionContext.Implicits.global
6262
val id = java.util.UUID.randomUUID().toString
63-
futureMap += (id -> sender)
63+
futureMap += (id -> sender())
6464
logger.info(s"Heartbeat client send: $id")
6565
val future = socket ? ZMQMessage(ByteString(id.getBytes))
6666
future.onComplete {

client/src/main/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClient.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class IOPubClient(
7676
} else {
7777
logger.warn("Received message with null parent header.")
7878
logger.debug(s"Kernel message is: $kernelMessage")
79-
sender.forward(Failure(new RuntimeException(PARENT_HEADER_NULL_MESSAGE)))
79+
sender().forward(Failure(new RuntimeException(PARENT_HEADER_NULL_MESSAGE)))
8080
}
8181
}
8282

client/src/test/scala/org/apache/toree/kernel/protocol/v5/client/socket/IOPubClientSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import org.mockito.ArgumentMatchers.{eq => mockEq, _}
3636
import org.mockito.Mockito._
3737
import org.scalatest.concurrent.{Eventually, ScalaFutures}
3838
import org.scalatestplus.mockito.MockitoSugar
39-
import org.scalatest.time.{Milliseconds, Span}
39+
import org.scalatest.time.{Milliseconds, Seconds, Span}
4040
import org.scalatest.funspec.AnyFunSpecLike
4141
import org.scalatest.matchers.should.Matchers
4242
import org.scalatest.BeforeAndAfterEach
@@ -60,7 +60,7 @@ class IOPubClientSpec extends TestKit(ActorSystem(
6060
{
6161
private val TestTimeout = Timeout(10.seconds)
6262
implicit override val patienceConfig = PatienceConfig(
63-
timeout = scaled(Span(200, Milliseconds)),
63+
timeout = scaled(Span(1, Seconds)),
6464
interval = scaled(Span(5, Milliseconds))
6565
)
6666
private val SignatureEnabled = true

communication/src/main/scala/org/apache/toree/communication/security/SignatureCheckerActor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SignatureCheckerActor(
3535
val isValidSignature = hmacString == signature
3636
logger.trace(s"Signature ${signature} validity checked against " +
3737
s"hmac ${hmacString} with outcome ${isValidSignature}")
38-
sender ! isValidSignature
38+
sender() ! isValidSignature
3939
}
4040
}
4141

0 commit comments

Comments
 (0)