Skip to content
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

Add wait flag for extractions. #5101

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
Expand Down Expand Up @@ -797,14 +798,23 @@ public ResponseEntity<Void> variableExtractions(
)
public ResponseEntity<Void> pdfExtractions(
@RequestParam("document-id") final UUID documentId,
@RequestParam(name = "domain", defaultValue = "epi") final String domain,
@RequestParam(name = "project-id", required = false) final UUID projectId
@RequestParam(name = "project-id", required = false) final UUID projectId,
@RequestParam(name = "wait", required = false, defaultValue = "false") final Boolean wait
YohannParis marked this conversation as resolved.
Show resolved Hide resolved
) {
final Schema.Permission permission = projectService.checkPermissionCanWrite(
currentUserService.get().getId(),
projectId
);
extractionService.extractPDFAndApplyToDocument(documentId, projectId, permission);

final Future<DocumentAsset> f = extractionService.extractPDFAndApplyToDocument(documentId, projectId, permission);
if (wait) {
try {
f.get();
} catch (InterruptedException | ExecutionException e) {
log.error("Error extracting PDF", e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, messages.get("document.extracton.failed"));
}
}
return ResponseEntity.accepted().build();
}

Expand Down
1 change: 1 addition & 0 deletions packages/server/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ document.not-found = We couldn't find the requested document. Please verify that
document.unable-to-delete = We couldn't delete the document. Please try again later.
document.unable-to-update = We couldn't update the document. Please try again later.
document.text-length-exceeded = This document exceeds our 600,000-word limit. If you still need to analyze this document, contact support.
document.extracton.failed = "Document extraction failed. Please try again later."
kbirk marked this conversation as resolved.
Show resolved Hide resolved

mira.concept.bad-curies = Our domain knowledge service (MIRA) couldn't find any valid concepts for the selected IDs. Please review the IDs that you selected and try again.
mira.concept.bad-query = Our domain knowledge service (MIRA) couldn't find any valid concepts for the entered query. Please review your search criteria and try again.
Expand Down
Loading