Refactor processing functions to use RawProcessingResult for less verbose error/warning handling#6537
Draft
Copilot wants to merge 2 commits into
Draft
Refactor processing functions to use RawProcessingResult for less verbose error/warning handling#6537Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
…bose error/warning handling - Add RawProcessingResult dataclass with plain string warnings/errors - Add processing_error() and processing_warning() helper functions - Modify call_function to handle both ProcessingResult and RawProcessingResult - Convert all processing functions to return RawProcessingResult - Simplify check_latin_characters and taxonomy helper functions - Remove unused invalid_value_annotation function - Update tests to match new return types (errors/warnings are now strings) This reduces the file from 2208 to 1719 lines by eliminating repetitive ProcessingAnnotation.from_fields(...) boilerplate in every error/warning.
Copilot
AI
changed the title
[WIP] Refactor error/warnings to be less verbose in code
Refactor processing functions to use RawProcessingResult for less verbose error/warning handling
May 29, 2026
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.
resolves #3857
processing_functions.pyhad ~50 instances of verboseProcessingAnnotation.from_fields(input_fields, [output_field], AnnotationSourceType.METADATA, message=...)boilerplate. Processing functions don't need to know about annotation structure—only the message matters. The caller (call_function) already has all the context to build the full annotation.Changes
datatypes.py: AddedRawProcessingResult(datum, warnings: list[str], errors: list[str])and helpersprocessing_error(msg)/processing_warning(msg, datum)processing_functions.py:call_functionnow accepts bothProcessingResultandRawProcessingResult, converting the latter by attaching field/type metadataRawProcessingResultcheck_latin_characters,missing_taxonomy_service_error,taxonomy_network_error) simplified accordinglyinvalid_value_annotationfunction.errors[0].message→.errors[0](now plain strings)Before / After
Screenshot
N/A — backend refactoring only, no UI changes.
PR Checklist
test_nextclade_preprocessing.pywhich requires externalnextclade3binary).