-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Add Async support #204
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
Conversation
:java_duke: JaCoCo coverage report
|
|
||||||||||||||
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
No worries. Enjoy the weekend! |
...ing-serve/docling-serve-client/src/main/java/ai/docling/serve/client/DoclingServeClient.java
Outdated
Show resolved
Hide resolved
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeApi.java
Outdated
Show resolved
Hide resolved
edeandrea
left a comment
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.
I've made a few general comments about how I envisioned the async to work. I was thinking that we would return CompletableFuture objects in the async operations. This would solve a number of issues, but the biggest is that the current implementation polls on the same thread that that it executes the task from. This could lead to deadlock in systems that are not thread-per-request.
Plus other downstream implementors may want to use virtual threads or some other threading mechanism.
Sticking to CompletableFuture allows more more customization by downstream frameworks.
@ThomasVitale thoughts?
.../docling-serve-api/src/main/java/ai/docling/serve/api/convert/response/ConversionStatus.java
Outdated
Show resolved
Hide resolved
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeApi.java
Outdated
Show resolved
Hide resolved
...docling-serve-client/src/main/java/ai/docling/serve/client/operations/ConvertOperations.java
Outdated
Show resolved
Hide resolved
|
I proposed a new solution with CompletableFuture. If it works for all I'll change to Duration the missing field and add the section to whats new. |
edeandrea
left a comment
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.
See my comments on the DoclingServeConvertApi
I think we only need a single method:
CompletableFuture<ConvertDocumentResponse> convertSource(ConvertDocumentRequest request);The implementation of that method would handle all the necessary polling to return the completed future once its complete.
At least that was my vision. Thoughts @ThomasVitale ?
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeConvertApi.java
Outdated
Show resolved
Hide resolved
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeConvertApi.java
Outdated
Show resolved
Hide resolved
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeConvertApi.java
Outdated
Show resolved
Hide resolved
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeConvertApi.java
Outdated
Show resolved
Hide resolved
docling-serve/docling-serve-api/src/main/java/ai/docling/serve/api/DoclingServeConvertApi.java
Outdated
Show resolved
Hide resolved
|
I guess I'll need to tackle this from scratch again. I was porting the logic coming from Camel, so I could have miss some parts of the API on this side. I'll rework on this next week. |
|
I think it's actually simpler than you realize. All the polling apis are already there, plus you already have the logic for polling based on a duration. It's just providing a method which ties everything together. |
02759ae to
33f4cea
Compare
|
It should be better now. I spent an hour or so looking at the API a bit deeper. |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
Looks good to me! Just left a couple of comments about the docs. I like the clean API returning |
0f58301 to
ca6ef1c
Compare
|
I fixed the docs based on the comments. I will merge this once CI passes! Thanks a lot @oscerd! |
|
@all-contributors add @oscerd as code docs |
|
I've put up a pull request to add @oscerd! 🎉 |
|
Great, thank you both! This is a very useful addition to the project. |
|
Now we just need to add the async to the chunk apis following the same pattern! |
Signed-off-by: Andrea Cosentino <[email protected]>
Simplified the async polling logic in `ConvertOperations` by replacing the custom scheduler with `CompletionStage` chaining. Improved task status handling by centralizing logic for success, failure, and retry behavior. Cleaned up imports and adjusted tests to maintain consistency with updated logic. Signed-off-by: Eric Deandrea <[email protected]>
Simplified method description by removing unnecessary implementation details about async threading and background polling, focusing on core functionality. Signed-off-by: Eric Deandrea <[email protected]>
Signed-off-by: Eric Deandrea <[email protected]>
e9d869b
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
🎉 This issue has been resolved in |
This should fix #127