-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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
[SPARK-24418][Build] Upgrade Scala to 2.11.12 and 2.12.6 #21495
Conversation
*/ | ||
override def initializeSynchronous(): Unit = { | ||
super.initializeSynchronous() | ||
initializeSpark() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@som-snytt It's working, but I'm wondering if I'm doing it correctly.
In this case, I'll use $intp
without checking
if (intp.reporter.hasErrors) {
echo("Interpreter encountered errors during initialization!")
null
}
in iLoop.scala
. Of course, I can add the checking in our own code, but it doesn't look right to me.
And intp.quietBind(NamedParam[IMain]("$intp", intp)(tagOfIMain, classTag[IMain]))
will not be executed before our custom Spark initialization code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my environment (with build/sbt
), I'm hitting NoSuchMethodError
like the following. Did you see something like this?
~/PR-21495:PR-21495$ bin/spark-shell
18/06/07 23:39:00 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
Setting default log level to "WARN".
To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel).
Welcome to
____ __
/ __/__ ___ _____/ /__
_\ \/ _ \/ _ `/ __/ '_/
/___/ .__/\_,_/_/ /_/\_\ version 2.4.0-SNAPSHOT
/_/
Using Scala version 2.11.12 (OpenJDK 64-Bit Server VM, Java 1.8.0_171)
Type in expressions to have them evaluated.
Type :help for more information.
scala> Spark context Web UI available at http://localhost:4040
Spark context available as 'sc' (master = local[*], app id = local-1528414746558).
Spark session available as 'spark'.
Exception in thread "main" java.lang.NoSuchMethodError: jline.console.completer.CandidateListCompletionHandler.setPrintSpaceAfterFullCompletion(Z)V
at scala.tools.nsc.interpreter.jline.JLineConsoleReader.initCompletion(JLineReader.scala:139)
at scala.tools.nsc.interpreter.jline.InteractiveReader.postInit(JLineReader.scala:54)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is working for me. I got scala-compiler-2.11.12.jar
in my classpath. Can you do a clean build?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Of course, it's a clean clone and build of this PR. Accoring to the error message and the followings, we need jline-2.14.3.jar
because scala
uses the setPrintSpaceAfterFullCompletion
API of higher version of jline
. Could you confirm this, @som-snytt ?
$ java -version
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)
$ javap -cp jline-2.12.1.jar jline.console.completer.CandidateListCompletionHandler
Compiled from "CandidateListCompletionHandler.java"
public class jline.console.completer.CandidateListCompletionHandler implements jline.console.completer.CompletionHandler {
public jline.console.completer.CandidateListCompletionHandler();
public boolean complete(jline.console.ConsoleReader, java.util.List<java.lang.CharSequence>, int) throws java.io.IOException;
public static void setBuffer(jline.console.ConsoleReader, java.lang.CharSequence, int) throws java.io.IOException;
public static void printCandidates(jline.console.ConsoleReader, java.util.Collection<java.lang.CharSequence>) throws java.io.IOException;
}
$ javap -cp jline-2.14.3.jar jline.console.completer.CandidateListCompletionHandler
Compiled from "CandidateListCompletionHandler.java"
public class jline.console.completer.CandidateListCompletionHandler implements jline.console.completer.CompletionHandler {
public jline.console.completer.CandidateListCompletionHandler();
public boolean getPrintSpaceAfterFullCompletion();
public void setPrintSpaceAfterFullCompletion(boolean);
public boolean isStripAnsi();
public void setStripAnsi(boolean);
public boolean complete(jline.console.ConsoleReader, java.util.List<java.lang.CharSequence>, int) throws java.io.IOException;
public static void setBuffer(jline.console.ConsoleReader, java.lang.CharSequence, int) throws java.io.IOException;
public static void printCandidates(jline.console.ConsoleReader, java.util.Collection<java.lang.CharSequence>) throws java.io.IOException;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we upgrade to the corresponding jline
version together in this PR, @dbtsai ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completion was upgraded since the old days; also, other bugs required updating jline. There is interest in upgrading to jline 3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for confirming, @som-snytt .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I know why it works for me.
I just run the following without building a distribution. jline
was automatically resolved to newer version.
./build/sbt clean package
./bin/spark-shell
Test build #91474 has finished for PR 21495 at commit
|
retest this please. |
Test build #91476 has finished for PR 21495 at commit
|
Your best bet for synchronous startup is to do everything in printWelcome: createInterpreter, your init commands that produce output. It looks like Scala REPL is moving toward a different architecture in 2.13, with loosely coupled front and back ends. |
retest this please |
Test build #91491 has finished for PR 21495 at commit
|
Retest this please. |
@som-snytt initialize it in |
@dbtsai 2.11 looks similar to 2.12. Do you mean you want the same technique on 2.10? I would not expect to find a single hook for all versions. Edit: sorry, I see it was a mid-2.11 change. |
Test build #91538 has finished for PR 21495 at commit
|
Test build #91541 has finished for PR 21495 at commit
|
class SparkILoopInterpreter(settings: Settings, out: JPrintWriter) extends IMain(settings, out) { | ||
self => | ||
class SparkILoopInterpreter(settings: Settings, out: JPrintWriter, initializeSpark: () => Unit) | ||
extends IMain(settings, out) { self => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: two spaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought for extends
, it's four spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, four spaces is OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely two spaces after a period. I've been wanting to make that joke, but held off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guys, parameters are listed in 4 spaces and other keywords after that are lined up with 2 spaces, which is written in https://github.com/databricks/scala-style-guide#spacing-and-indentation
In case of two lines, it's not explicitly written but wouldn't we better stick to the example as possible as we can? "Use 2-space indentation in general.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, there's a bunch of code in Spark where both 4-space and 2-space indentation are existed. From my thought it is not so worthy to stick to this tiny point.
If you want to fix it, then creating a separate PR to fix all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can fix them in place. There are many other style nits too. It's not worth swiping them making the backport harder.
I am fine with ignoring such nits and they don't block this PR but it's not something we should say the opposite side is okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really not worthy to block on this thing (if it is the only issue).
Test build #91561 has finished for PR 21495 at commit
|
Test build #91559 has finished for PR 21495 at commit
|
Test build #91579 has finished for PR 21495 at commit
|
Test build #91580 has finished for PR 21495 at commit
|
NVM, just using the old patch... |
I decided to remove the hack I put in to get the Spark UI consistent because this hack will bring in more problems. @som-snytt Is it possible to move the |
Test build #91650 has finished for PR 21495 at commit
|
Test build #92292 has finished for PR 21495 at commit
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
db might be out for a bit. we should merge it if it looks/tested good? |
OK, I'm going to merge it. We can fix the following issues if exists. |
LGTM too. |
I was on a family leave for couple weeks. Thank you all for helping out and merging it. The only change with this PR is that the welcome message will be printed first, and then the Spark URL will be shown latter. It's a minor difference. I had an offline discussion with @adriaanm in Scala community. To overcome this issue, He is open to working with us to add proper hook in Scala so we don't need use hacks to initialize our code. Thanks. |
I think it’d be great to not change the order
…________________________________
|
I think we should create a JIRA to create this change, also evaluate the necessity to fix this issue. If this behavior change will affect some users, maybe we should move the target version to 3.0.0? @dbtsai @felixcheung |
I don’t feel strongly either way.
Agreed we should track it with JIRA
…________________________________
|
In addition to that, it woud be great if we fix $ ./build/sbt -Pyarn -Phadoop-2.7 -Phadoop-cloud -Phive -Phive-thriftserver -Psparkr test:package
$ bin/spark-shell
scala> Spark context Web UI available at http://localhost:4040
Spark context available as 'sc' (master = local[*], app id = local-1530385877441).
Spark session available as 'spark'.
Exception in thread "main" java.lang.NoSuchMethodError: jline.console.completer.CandidateListCompletionHandler.setPrintSpaceAfterFullCompletion(Z)V |
@dongjoon-hyun can you please create a JIRA to track this issue. |
Sure. https://issues.apache.org/jira/browse/SPARK-24715 is created now. |
JIRA and PR are created to make sure the messages are printed in the right order. |
* Upgrade Scala to 2.11.12 - Modifies slightly the Spark REPL code to reflect internal changes in Scala tooling - This code was ported from apache#21495 (cherry picked from commit 3e52a9160875ec5c145c4e9fa0106ff7d1f380b2)
…elcome message ## What changes were proposed in this pull request? After #21495 the welcome message is printed first, and then Scala prompt will be shown before the Spark UI info is printed. Although it's a minor issue, but visually, it doesn't look as nice as the existing behavior. This PR intends to fix it by duplicating the Scala `process` code to arrange the printing order. However, one variable is private, so reflection has to be used which is not desirable. We can use this PR to brainstorm how to handle it properly and how Scala can change their APIs to fit our need. ## How was this patch tested? Existing test Closes #21749 from dbtsai/repl-followup. Authored-by: DB Tsai <[email protected]> Signed-off-by: DB Tsai <[email protected]>
* Upgrade Scala to 2.11.12 - Modifies slightly the Spark REPL code to reflect internal changes in Scala tooling - This code was ported from apache#21495 (cherry picked from commit 3e52a9160875ec5c145c4e9fa0106ff7d1f380b2) (cherry picked from commit f5a3901)
* Upgrade Scala to 2.11.12 - Modifies slightly the Spark REPL code to reflect internal changes in Scala tooling - This code was ported from apache#21495 (cherry picked from commit 3e52a9160875ec5c145c4e9fa0106ff7d1f380b2) (cherry picked from commit f5a3901) (cherry picked from commit a72488d)
Adaptation of apache#21495
* Upgrade Scala to 2.11.12 - Modifies slightly the Spark REPL code to reflect internal changes in Scala tooling - This code was ported from apache#21495 (cherry picked from commit 3e52a9160875ec5c145c4e9fa0106ff7d1f380b2) (cherry picked from commit f5a3901) (cherry picked from commit a72488d)
Adaptation of apache#21495
Adaptation of apache#21495
What changes were proposed in this pull request?
Scala is upgraded to
2.11.12
and2.12.6
.We used
loadFIles()
inILoop
as a hook to initialize the Spark before REPL sees any files in Scala2.11.8
. However, it was a hack, and it was not intended to be a public API, so it was removed in Scala2.11.12
.From the discussion in Scala community, scala/bug#10913 , we can use
initializeSynchronous
to initialize Spark instead. This PR implements the Spark initialization there.However, in Scala
2.11.12
'sILoop.scala
, in functiondef startup()
, the first thing it calls isprintWelcome()
. As a result, Scala will callprintWelcome()
andsplash
before callinginitializeSynchronous
.Thus, the Spark shell will allow users to type commends first, and then show the Spark UI URL. It's working, but it will change the Spark Shell interface as the following.
It seems there is no easy way to inject the Spark initialization code in the proper place as Scala doesn't provide a hook. Maybe @som-snytt can comment on this.
The following command is used to update the dep files.
How was this patch tested?
Existing tests