Error handling for Grobid when not responding#35
Open
Sanakhamassi wants to merge 1 commit intoScienciaLAB:mainfrom
Open
Error handling for Grobid when not responding#35Sanakhamassi wants to merge 1 commit intoScienciaLAB:mainfrom
Sanakhamassi wants to merge 1 commit intoScienciaLAB:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds explicit error handling for Grobid failures so the Streamlit UI can surface a clear “please try later” message instead of failing ambiguously (issue #11).
Changes:
- Introduce
GrobidServiceErrorand raise it when Grobid errors or returns non-200. - Catch
GrobidServiceErrorin the Streamlit upload/embedding flow and display an error message. - Add a (currently redundant) guard in
DocumentQAEnginefor missing Grobid output.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
streamlit_app.py |
Catches Grobid failures during embedding creation and shows a user-facing error. |
document_qa/grobid_processors.py |
Defines GrobidServiceError and raises it from Grobid processing on failure/non-200. |
document_qa/document_qa_engine.py |
Imports/raises GrobidServiceError when Grobid structure is missing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+331
to
+335
| status = f" (status {exc.status_code})" if exc.status_code else "" | ||
| st.session_state['doc_id'] = None | ||
| st.session_state['loaded_embeddings'] = False | ||
| st.session_state['uploaded'] = False | ||
| st.error(f"Grobid is not responding{status}. Please try later.") |
Comment on lines
107
to
+125
| def process_structure(self, input_path, coordinates=False): | ||
| pdf_file, status, text = self.grobid_client.process_pdf("processFulltextDocument", | ||
| input_path, | ||
| consolidate_header=True, | ||
| consolidate_citations=False, | ||
| segment_sentences=False, | ||
| tei_coordinates=coordinates, | ||
| include_raw_citations=False, | ||
| include_raw_affiliations=False, | ||
| generateIDs=True) | ||
| try: | ||
| pdf_file, status, text = self.grobid_client.process_pdf("processFulltextDocument", | ||
| input_path, | ||
| consolidate_header=True, | ||
| consolidate_citations=False, | ||
| segment_sentences=False, | ||
| tei_coordinates=coordinates, | ||
| include_raw_citations=False, | ||
| include_raw_affiliations=False, | ||
| generateIDs=True) | ||
| except Exception as exc: | ||
| raise GrobidServiceError("Grobid service did not respond.") from exc | ||
|
|
||
| if status != 200: | ||
| return | ||
| raise GrobidServiceError( | ||
| f"Grobid service returned status {status}.", | ||
| status_code=status | ||
| ) |
lfoppiano
approved these changes
Apr 26, 2026
Collaborator
lfoppiano
left a comment
There was a problem hiding this comment.
There is a missing space, the rest looks fine. I did not test it, so please make sure you tested it before merge/squash.
| st.session_state['doc_id'] = None | ||
| st.session_state['loaded_embeddings'] = False | ||
| st.session_state['uploaded'] = False | ||
| st.error(f"Grobid is not responding{status}. Please try later.") |
Collaborator
There was a problem hiding this comment.
here there seems to be a missing space
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to issue #11