-
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-16829][SparkR]:sparkR sc.setLogLevel doesn't work #14433
Conversation
Test build #63069 has finished for PR 14433 at commit
|
I think a better change might be to change that message if we are launching SparkR ? cc @felixcheung |
@shivaram I found spark-shell and pyspark using the same message: Python 2.7.11 |Anaconda 2.4.0 (x86_64)| (default, Dec 6 2015, 18:57:58) ./bin/spark-shell |
Correct, I don't think should name the function |
@felixcheung Let me check the code of launching the sparkR shell. Can you point me the code? Thanks! |
@felixcheung I will try to retrieve terminal/shell type before printing out the message. I will update the PR if I can find a way of doing that. Thanks! |
Test build #63132 has finished for PR 14433 at commit
|
The failure seems unrelated to the change. |
Jenkins, re-test this please. |
Test build #63137 has finished for PR 14433 at commit
|
@felixcheung I checked which object calls the log and print message accordingly. ./bin/sparkR R version 3.3.0 (2016-05-03) -- "Supposedly Educational" R is free software and comes with ABSOLUTELY NO WARRANTY. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'demo()' for some demos, 'help()' for on-line help, or [Previously saved workspace restored] Launching java with spark-submit command /Users/mwang/spark_ws_0904/bin/spark-submit "sparkr-shell" /var/folders/s_/83b0sgvj2kl2kwq4stvft_pm0000gn/T//Rtmpi4dP8y/backend_portb9fa113abad2 ./bin/spark-shell ./bin/pyspark |
awesome! I think we might have a need to create a helper for "am I running in the SparkR shell" function? |
@felixcheung "I think we might have a need to create a helper for "am I running in the SparkR shell" function?" Do you mean for #14258 ? Not for this PR, right? |
I think both checks are a bit fragile and would be great to a single way to check if running as shell that is shared, and that could be what SparkSubmit.scala call as well.
Would be better not to have 3 different ways to check if running as shell, right?
|
@felixcheung Checking whether it is running from shell is not exactly the same as checking which shell is calling it. My approach is depends on the fact that the Logging trait is used in three different gateway objects. Let me check if there is a better way to do that. |
Sure - but one is an subset of another (ie. knowing it's the sparkR shell means it is running a shell) |
I am investigating a solution now. Either today or tomorrow, I can give an update. Thanks! |
@felixcheung Since all shell instances (i.e., spark-shell, pyspark and sparkR) are initialized through spark-submit script, I think a possible solution is to set a status flag in SparkSubmit object when shell is initialized. Then, we can create a API public to [spark] for by checking the flag. What do you think? Thanks! |
@felixcheung I don't find a better way other than checking the string either passed by resource or by the class name. Do you have any good ideas? |
@felixcheung I have an idea of creating an Enum object in scala, like the example below: I create a private API of setting the Enum value to a private variable and a public API of checking the shell type by returning Option[Shell_type]. If return value is NULL, it is not a shell otherwise, it returns the correct shell type. How do you think about this approach? Thanks! |
Can we have this like SparkSubmitAction that extends |
@felixcheung I think SparkSubmitAction is good for this purpose. We might have to make the scope as [spark] instead of [deploy]. So it can be used in other components if needed. I will create the Enum object accordingly. Thanks! |
Test build #63802 has finished for PR 14433 at commit
|
Test build #63805 has finished for PR 14433 at commit
|
import org.slf4j.{Logger, LoggerFactory} | ||
import org.slf4j.impl.StaticLoggerBinder | ||
|
||
import org.apache.spark.util.Utils |
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.
as per this import org.apache.spark.deploy
should go here
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.
@felixcheung It seems that you saw my old commit for some reason. I think I changed the import order in the latest commit. Thanks!
@felixcheung, Any comments on the new change? |
It feels like some overkill unless there are going to be more uses for changing logic based on whether it's running a shell. It seems not so bad to define |
that's a good point actually - how about we use |
|
Jenkins, retest this please. |
Test build #64491 has finished for PR 14433 at commit
|
Test build #64493 has finished for PR 14433 at commit
|
Any further comments? Thanks! |
@@ -135,7 +136,12 @@ private[spark] trait Logging { | |||
val replLevel = Option(replLogger.getLevel()).getOrElse(Level.WARN) | |||
if (replLevel != rootLogger.getEffectiveLevel()) { | |||
System.err.printf("Setting default log level to \"%s\".\n", replLevel) | |||
System.err.println("To adjust logging level use sc.setLogLevel(newLevel).") | |||
if (SparkSubmit.isRShell) { |
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 personally think it's a bit ugly to pipe through this info with extra methods and so on. It seems simpler just to amend the message to also state the right command for sparkr.
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.
+1 -- I personally find it odd that we would import deploy.SparkSubmit
into Logging
which is a base class used throughout the code base. We could also change the log message to be more vague. Something like To adjust logging level please call setLogLevel(newLevel) using SparkContext
might work for all languages ?
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.
How about I change the log like To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel)
? Thanks!
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.
Sounds good to me
@shivaram I simplified the solution by only changing the message as we discussed. Thanks! |
Test build #64839 has finished for PR 14433 at commit
|
LGTM. Thanks @wangmiao1981 -- I'll keep this open for a bit to see if there are any more comments. |
@@ -135,7 +135,8 @@ private[spark] trait Logging { | |||
val replLevel = Option(replLogger.getLevel()).getOrElse(Level.WARN) | |||
if (replLevel != rootLogger.getEffectiveLevel()) { | |||
System.err.printf("Setting default log level to \"%s\".\n", replLevel) | |||
System.err.println("To adjust logging level use sc.setLogLevel(newLevel).") | |||
System.err.println("To adjust logging level use sc.setLogLevel(newLevel). " + | |||
"For SparkR, use setLogLevel(newLevel).") |
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.
While I'd indent this continuation line, I don't think it's worth worrying about. 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.
I fixed this up during the merge
Merged into master |
What changes were proposed in this pull request?
(Please fill in changes proposed in this fix)
./bin/sparkR
Launching java with spark-submit command /Users/mwang/spark_ws_0904/bin/spark-submit "sparkr-shell" /var/folders/s_/83b0sgvj2kl2kwq4stvft_pm0000gn/T//RtmpQxJGiZ/backend_porte9474603ed1e
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).
sc.setLogLevel doesn't exist.
R has a function setLogLevel.
I rename the setLogLevel function to sc.setLogLevel.
How was this patch tested?
(Please explain how this patch was tested. E.g. unit tests, integration tests, manual tests)
Change unit test. Run unit tests.
Manually tested it in sparkR shell.