feat(prepro): refactor processing functions to use RawProcessingResult for less verbose error/warning handling#6537
feat(prepro): refactor processing functions to use RawProcessingResult for less verbose error/warning handling#6537Copilot wants to merge 18 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.
b0a599d to
030c4fc
Compare
|
@claude review |
|
Claude finished @anna-parker's task in 2m 29s —— View job Code Review
This is a clean, well-motivated refactoring. The core idea—separating message construction from annotation metadata attachment—is sound, and the 22% line reduction is genuine rather than cosmetic. A few issues worth addressing: Issues1.
2. Unused parameters in After the refactoring, # check_latin_characters - input_fields and output_field unused
def check_latin_characters(
authors: str, input_fields: list[str], output_field: str # ← unused
) -> tuple[list[str], list[str]]:
# missing_taxonomy_service_error - both params unused
def missing_taxonomy_service_error(input_fields: list[str], output_field: str) -> RawProcessingResult:
# taxonomy_network_error - last two params unused
def taxonomy_network_error(subject, action, e, input_fields: list[str], output_field: str) -> RawProcessingResult:3. Tests bypass After the refactoring, test assertions changed from Consider adding at least one integration-level test that calls Minor observations
What's good
|
Co-authored-by: Cornelius Roemer <cornelius.roemer@gmail.com>
aadee66 to
b10a363
Compare
Co-authored-by: maverbiest <59956362+maverbiest@users.noreply.github.com>
maverbiest
left a comment
There was a problem hiding this comment.
This is a very nice improvement in readability! I leftsome minor comments here and there but should then be good to merge I think
…ude proper information (#6801) …lude proper information Follow up to #6537 - ensure that all internal errors thrown by prepro (these are related to invalid config, unexpected nextclade format etc.) are properly annotated with the prefix "Internal Error:" and the suffix "Please contact the administrator." ### Screenshot ### PR Checklist - [x] All necessary documentation has been adapted. - [x] The implemented feature is covered by appropriate, automated tests. - [ ] Any manual testing that has been done is documented (i.e. what exactly was tested?) 🚀 Preview: Add `preview` label to enable --------- Co-authored-by: maverbiest <59956362+maverbiest@users.noreply.github.com>
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).🚀 Preview: https://copilot-refactor-error-wa.loculus.org