-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR is part of the effort to move download functionality from front end to backend. ## New endpoint: /export/result Previously, `ResultExportService` was called from `WorkflowWebsocketResource`, with this PR, it is now called from a new endpoint defined in `ResultExportResource`. To unify export to dataset and export to local (download), we need to have an endpoint to remove front end from the process. Currently front end fetch all the result and then send them to the user but the goal is to use this new endpoint to stream result directly from backend to user. ## Current behavior The new endpoint only provides export to dataset currently. In code, it supports multiple formats but in front end, we only allow two formats: CSV and Arrow (for binary files). This limitation is based on the previous implementation and might be revised. ## Future work There are four main TODOs left in this PR: - Use `rowIndex` and `columnIndex` in frontend because already available in backend - Request multiple operators result in one HTTP request - Adjust endpoint to return the file itself if the export destination is local - Adjust endpoint to return a zip file if the export destination is local and multiple operators are selected https://github.com/user-attachments/assets/a86eb3e5-8550-4d56-b86f-a5805cc10ffe
- Loading branch information
Showing
7 changed files
with
123 additions
and
20 deletions.
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
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
42 changes: 42 additions & 0 deletions
42
core/amber/src/main/scala/edu/uci/ics/texera/web/resource/ResultResource.scala
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package edu.uci.ics.texera.web.resource | ||
|
||
import com.typesafe.scalalogging.LazyLogging | ||
import edu.uci.ics.amber.core.virtualidentity.WorkflowIdentity | ||
import edu.uci.ics.texera.web.auth.SessionUser | ||
import edu.uci.ics.texera.web.model.websocket.request.ResultExportRequest | ||
import edu.uci.ics.texera.web.model.websocket.response.ResultExportResponse | ||
import edu.uci.ics.texera.web.service.{ResultExportService, WorkflowService} | ||
import io.dropwizard.auth.Auth | ||
|
||
import javax.ws.rs._ | ||
import javax.ws.rs.core.Response | ||
import scala.jdk.CollectionConverters._ | ||
|
||
@Path("/result") | ||
class ResultResource extends LazyLogging { | ||
|
||
@POST | ||
@Path("/export") | ||
def exportResult( | ||
request: ResultExportRequest, | ||
@Auth user: SessionUser | ||
): Response = { | ||
|
||
try { | ||
val resultExportService = new ResultExportService(WorkflowIdentity(request.workflowId)) | ||
|
||
val exportResponse: ResultExportResponse = | ||
resultExportService.exportResult(user.user, request) | ||
|
||
Response.ok(exportResponse).build() | ||
|
||
} catch { | ||
case ex: Exception => | ||
Response | ||
.status(Response.Status.INTERNAL_SERVER_ERROR) | ||
.entity(Map("error" -> ex.getMessage).asJava) | ||
.build() | ||
} | ||
} | ||
|
||
} |
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
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