You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "allisonwang-db (via GitHub)" <gi...@apache.org> on 2023/05/30 17:37:19 UTC
[GitHub] [spark] allisonwang-db commented on a diff in pull request #41357: [SPARK-43790][PYTHON][CONNECT][ML] Add `copyFromLocalToFS` API
allisonwang-db commented on code in PR #41357:
URL: https://github.com/apache/spark/pull/41357#discussion_r1210607108
##########
connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/SparkConnectAddArtifactsHandler.scala:
##########
@@ -89,6 +92,28 @@ class SparkConnectAddArtifactsHandler(val responseObserver: StreamObserver[AddAr
artifactManager.addArtifact(holder, artifact.path, artifact.stagedPath, artifact.fragment)
}
+ protected def uploadStagedArtifactToFS(artifact: StagedArtifact): Unit = {
+ try {
+ val hadoopConf = holder.session.sparkContext.hadoopConfiguration
+ assert(artifact.path.startsWith(forwardToFSPrefix))
+ val destFSPath = new FSPath(
+ Paths.get("/").resolve(artifact.path.subpath(1, artifact.path.getNameCount)).toString
+ )
+ val localPath = artifact.stagedPath
+ val fs = destFSPath.getFileSystem(hadoopConf)
+ fs.copyFromLocalFile(
+ false,
+ true,
+ new FSPath(localPath.toString),
+ destFSPath
+ )
+ } catch {
+ case e: java.io.IOException =>
+ // TODO: report failure in response message
Review Comment:
I think we should catch all gRPC errors using this handleError: https://github.com/apache/spark/blob/7d87fecda7077714601cdf7328a11d2719a99bb1/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/SparkConnectService.scala#L119-L123
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org