-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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-24377][Spark Submit] make --py-files work in non pyspark application #21420
Closed
Closed
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -430,18 +430,15 @@ private[spark] class SparkSubmit extends Logging { | |
// Usage: PythonAppRunner <main python file> <extra python files> [app arguments] | ||
args.mainClass = "org.apache.spark.deploy.PythonRunner" | ||
args.childArgs = ArrayBuffer(localPrimaryResource, localPyFiles) ++ args.childArgs | ||
if (clusterManager != YARN) { | ||
// The YARN backend distributes the primary file differently, so don't merge it. | ||
args.files = mergeFileLists(args.files, args.primaryResource) | ||
} | ||
} | ||
if (clusterManager != YARN) { | ||
// The YARN backend handles python files differently, so don't merge the lists. | ||
args.files = mergeFileLists(args.files, args.pyFiles) | ||
} | ||
if (localPyFiles != null) { | ||
} | ||
|
||
if (localPyFiles != null) { | ||
sparkConf.set("spark.submit.pyFiles", localPyFiles) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks indented too far now. |
||
} | ||
} | ||
|
||
// In YARN mode for an R app, add the SparkR package archive and the R package | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -771,9 +771,13 @@ class SparkSubmitSuite | |
PythonRunner.formatPaths(Utils.resolveURIs(pyFiles)).mkString(",")) | ||
|
||
// Test remote python files | ||
val hadoopConf = new Configuration() | ||
updateConfWithFakeS3Fs(hadoopConf) | ||
val f4 = File.createTempFile("test-submit-remote-python-files", "", tmpDir) | ||
val pyFile1 = File.createTempFile("file1", ".py", tmpDir) | ||
val pyFile2 = File.createTempFile("file2", ".py", tmpDir) | ||
val writer4 = new PrintWriter(f4) | ||
val remotePyFiles = "hdfs:///tmp/file1.py,hdfs:///tmp/file2.py" | ||
val remotePyFiles = s"s3a://${pyFile1.getAbsolutePath},s3a://${pyFile2.getAbsolutePath}" | ||
writer4.println("spark.submit.pyFiles " + remotePyFiles) | ||
writer4.close() | ||
val clArgs4 = Seq( | ||
|
@@ -783,7 +787,7 @@ class SparkSubmitSuite | |
"hdfs:///tmp/mister.py" | ||
) | ||
val appArgs4 = new SparkSubmitArguments(clArgs4) | ||
val (_, _, conf4, _) = submit.prepareSubmitEnvironment(appArgs4) | ||
val (_, _, conf4, _) = submit.prepareSubmitEnvironment(appArgs4, conf = Some(hadoopConf)) | ||
// Should not format python path for yarn cluster mode | ||
conf4.get("spark.submit.pyFiles") should be(Utils.resolveURIs(remotePyFiles)) | ||
} | ||
|
@@ -1093,6 +1097,44 @@ class SparkSubmitSuite | |
assert(exception.getMessage() === "hello") | ||
} | ||
|
||
test("support --py-files/spark.submit.pyFiles in non pyspark application") { | ||
val hadoopConf = new Configuration() | ||
updateConfWithFakeS3Fs(hadoopConf) | ||
|
||
val tmpDir = Utils.createTempDir() | ||
val pyFile = File.createTempFile("tmpPy", ".egg", tmpDir) | ||
|
||
val args = Seq( | ||
"--class", UserClasspathFirstTest.getClass.getName.stripPrefix("$"), | ||
"--name", "testApp", | ||
"--master", "yarn", | ||
"--deploy-mode", "client", | ||
"--py-files", s"s3a://${pyFile.getAbsolutePath}", | ||
"spark-internal" | ||
) | ||
|
||
val appArgs = new SparkSubmitArguments(args) | ||
val (_, _, conf, _) = submit.prepareSubmitEnvironment(appArgs, conf = Some(hadoopConf)) | ||
|
||
conf.get("spark.yarn.dist.pyFiles") should be (s"s3a://${pyFile.getAbsolutePath}") | ||
conf.get("spark.submit.pyFiles") should (startWith("/")) | ||
|
||
// Verify "spark.submit.pyFiles" | ||
val args1 = Seq( | ||
"--class", UserClasspathFirstTest.getClass.getName.stripPrefix("$"), | ||
"--name", "testApp", | ||
"--master", "yarn", | ||
"--deploy-mode", "client", | ||
"--conf", s"spark.submit.pyFiles=s3a://${pyFile.getAbsolutePath}", | ||
"spark-internal" | ||
) | ||
|
||
val appArgs1 = new SparkSubmitArguments(args1) | ||
val (_, _, conf1, _) = submit.prepareSubmitEnvironment(appArgs1, conf = Some(hadoopConf)) | ||
|
||
conf1.get("spark.yarn.dist.pyFiles") should be (s"s3a://${pyFile.getAbsolutePath}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
conf1.get("spark.submit.pyFiles") should (startWith("/")) | ||
} | ||
} | ||
|
||
object SparkSubmitSuite extends SparkFunSuite with TimeLimits { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Eh @jerryshao why did we remove this?
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 duplicated with below code, you can check the original code.