WeichenXu123 commented on code in PR #41357:
URL: https://github.com/apache/spark/pull/41357#discussion_r1211157822


##########
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:
   `SparkConnectAddArtifactsHandler` already defined `onError` handler (note 
this class inherits `StreamObserver`) , see
   
   
https://github.com/apache/spark/blob/e8f87413bdd905e5e208ac8484b3b11de1623fc2/connector/connect/server/src/main/scala/org/apache/spark/sql/connect/service/SparkConnectAddArtifactsHandler.scala#L83
   
   We might need to do some refactor to make it use `handleError` , 
@allisonwang-db would you mind to do it in follow-up PR ?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to