fix: Enhance logging and add allele consistency checks#22
fix: Enhance logging and add allele consistency checks#22gp201 merged 9 commits intoandersen-lab:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR standardizes CLI/library console output by centralizing Rich printing in barcodeforge.utils helper functions, and strengthens barcode validation by adding an allele consistency check that aborts on inconsistent mutation encodings.
Changes:
- Added
print_error/print_warning/print_success/print_info/print_debughelpers and refactored callers to use them (removingConsoleparameters/instances). - Introduced
check_allele_consistencyand integrated it into barcode generation/validation. - Updated tests to patch the shared
barcodeforge.utils.consoleand to expectclick.Abortfor CLI-style failures.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
barcodeforge/utils.py |
Adds shared console and printing helpers; updates subprocess + tree-format utilities to use them. |
barcodeforge/cli.py |
Refactors CLI output and error handling to standardized print helpers; removes Console usage. |
barcodeforge/generate_barcodes.py |
Adds allele consistency validation; standardizes flip-pair failure to click.Abort; refactors logging. |
barcodeforge/ref_muts.py |
Refactors messages to standardized printing helpers. |
barcodeforge/plot_barcode.py |
Updates debug/info output to standardized printing helpers. |
barcodeforge/auspice_tree_to_table.py |
Removes console parameter; standardizes errors/warnings via print helpers and click.Abort. |
tests/test_utils.py |
Updates tests for new utility signatures/output formatting and console patching approach. |
tests/test_cli.py |
Updates CLI tests for new signatures and console patching via barcodeforge.utils.console. |
tests/test_generate_barcodes.py |
Adds coverage for allele consistency; updates abort expectations for flip-pair check. |
tests/test_ref_muts.py |
Updates console patch target to barcodeforge.utils.console and adjusts expected messages. |
tests/test_auspice_tree_to_table.py |
Updates tests for console removal and abort behavior; captures output via shared console. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Pull request overview
This PR standardizes console output across the BarcodeForge CLI/tooling by centralizing printing in barcodeforge.utils helper functions, and adds an allele-consistency validation step to improve barcode integrity checks during generation.
Changes:
- Introduces
print_error/print_warning/print_success/print_info/print_debughelpers and removes per-moduleConsoleusage /consoleparameters. - Adds
check_allele_consistency()and invokes it during barcode mutation-chain validation. - Updates CLI + module error handling to raise
click.Abort, and adjusts tests accordingly.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
barcodeforge/utils.py |
Adds global console + new print helper functions; updates subprocess + format resolution logging. |
barcodeforge/cli.py |
Refactors CLI messaging to use print helpers; removes console plumbing and improves abort behavior. |
barcodeforge/generate_barcodes.py |
Uses print helpers; changes flip-pair handling to click.Abort; adds allele consistency validation and calls it from mutation-chain checks. |
barcodeforge/auspice_tree_to_table.py |
Removes console parameter and switches messaging/error handling to print helpers + click.Abort. |
barcodeforge/ref_muts.py |
Replaces direct console printing with print helpers. |
barcodeforge/plot_barcode.py |
Switches debug/info output to print helpers. |
tests/test_utils.py |
Updates unit tests for new utils signatures and centralized console patching. |
tests/test_cli.py |
Updates CLI tests to patch barcodeforge.utils.console and reflect new function signatures. |
tests/test_generate_barcodes.py |
Adds tests for check_allele_consistency; updates expected exceptions for flip-pair checks. |
tests/test_ref_muts.py |
Updates console patching target to barcodeforge.utils.console and expected message format. |
tests/test_auspice_tree_to_table.py |
Updates tests for removed console parameter and centralized console patching. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
This pull request refactors the codebase to standardize and simplify console output handling by replacing direct usage of the
rich.console.Consoleand manual style formatting with new utility functions (print_error,print_warning,print_success,print_info,print_debug). It also enhances barcode consistency checks by introducing a new allele consistency validation and improves error handling throughout the CLI and barcode generation modules.Console output refactoring:
console.printcalls and manual style formatting with utility functions (print_error,print_warning,print_success,print_info,print_debug) acrossbarcodeforge/cli.py,barcodeforge/generate_barcodes.py, andbarcodeforge/auspice_tree_to_table.pyfor more consistent and maintainable messaging. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18]Barcode consistency and error handling improvements:
check_allele_consistencyfunction to ensure that each position in the barcode matrix has only one reference allele and that no lineage has multiple alternative alleles at the same position, raising errors if inconsistencies are found. [1] [2] [3]check_no_flip_pairs) to useprint_successandprint_error, and to raiseclick.Abortinstead of a generic exception for improved CLI error handling. [1] [2]CLI interface and function signature changes:
consoleargument from CLI and processing functions, simplifying function signatures and reducing coupling to the console implementation. [1] [2] [3] [4] [5] [6]print_errorandclick.Abortfor unsupported formats and operational failures.General code cleanup:
These changes collectively make console output more uniform, improve error reporting, and add robust checks for barcode data integrity.