feat: implement auto strategy for #59#82
Merged
Conversation
Add comprehensive test suite for CLI strategy routing feature: - Tests for --strategy flag with choices [fast, balanced, sensitive] - Verification that balanced is the default strategy - Routing tests to confirm correct built-in workflow selection - Error handling when --strategy used with torch-embedded workflows - Help text validation for strategy options and restrictions - Integration tests with multi-scheme torch support - Path resolution and workflow discovery interaction tests All tests currently fail as expected (RED phase of TDD). Feature implementation will make these tests pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implement CLI strategy routing with --strategy flag for torchbase run command. Key features: - Added --strategy flag with choices [fast, balanced, sensitive] - Default strategy is 'balanced' - CLI routes to appropriate built-in workflow based on strategy selection - Error handling: raises error if --strategy used with torch-embedded workflows - Integrated with multi-scheme support from #53 - Help text explains strategy options and restrictions Built-in workflows: - fast_typing.wdl: MinHash-only pipeline (fastest) - balanced_typing.wdl: MinHash + alignment fallback (default) - sensitive_typing.wdl: Full alignment-based calling (most accurate) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add comprehensive test suite for auto strategy decision logic: - Tests for --strategy auto flag with CLI integration - Pre-analysis sequence inspection tests (length, N50, format) - Decision routing tests for contigs (fast), reads (balanced), edge cases - Decision rationale validation in workflow output notes - Helper function tests for _analyze_sequences (mean length, N50, type detection) - Integration tests for end-to-end auto strategy workflow - Error handling tests for embedded workflows and analysis failures All tests currently fail as expected (RED phase of TDD). Feature implementation will make these tests pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implements automatic strategy detection and selection based on input sequence characteristics: - Added _analyze_sequences() function that inspects input files and extracts statistics (mean length, N50) - Decision logic: contigs (mean >1000bp) route to fast, reads (mean <500bp) route to balanced, edge cases default to balanced - Added 'auto' as a valid --strategy choice alongside 'fast', 'balanced', 'sensitive' - Updated help text to document auto strategy behavior - Decision rationale included in workflow inputs as 'auto_decision' parameter - Handles both FASTA and FASTQ formats - Gracefully defaults to balanced strategy on analysis errors or empty files - Updated WDL files to accept optional auto_decision input parameter Tests: 28/29 passing. One test fails due to excessive Path mocking that prevents file reading in a unit test scenario, but integration tests and all core functionality tests pass. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
54b447f to
7625007
Compare
Removed overly broad Path mock that was causing workflow path to be a MagicMock instead of actual path string. This prevented the test from checking if fast_typing was correctly selected.
- Add FileReaderWithPath wrapper class to store original file paths - Use wrapper in ReadsFile converter for all compressed formats - Simplify auto strategy path extraction to use _original_path attribute - Replace dummy workflow files with real implementations from main - All 29 auto strategy tests pass Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
# Conflicts: # torchbase/cli.py
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.
Summary
Implements
--strategy autofeature for automatic input type detection and strategy selection:Implementation Details
_analyze_sequences()function that reads FASTA/FASTQ files and calculates length statisticsTest Status
Acceptance Criteria Met
--strategy autooption works in CLI