feat: add input parameter validation to PlasmodiumDataResource public methods#1024
Open
suhaan-24 wants to merge 4 commits intomalariagen:masterfrom
Open
feat: add input parameter validation to PlasmodiumDataResource public methods#1024suhaan-24 wants to merge 4 commits intomalariagen:masterfrom
suhaan-24 wants to merge 4 commits intomalariagen:masterfrom
Conversation
Contributor
Author
|
@jonbrenas Please take a look at it |
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
This PR adds basic input parameter validation to the public methods in PlasmodiumDataResource, bringing it in line with the validation patterns already used in the Anopheles API.
Why this matters
Currently, methods like genome_sequence() and variant_calls() accept any input type without validation. When a user passes an invalid parameter (e.g., an incorrect contig string, or a string where a boolean is expected), the error propagates downwards and results in confusing low-level exceptions (like a cryptic zarr
KeyErroror daskTypeError) instead of a helpful message at the API boundary. This change improves the developer experience by catching these errors early.Changes
isinstanceand type checks to the top of variant_calls() (extended, inline_array, chunks) and genome_sequence() (region, inline_array, chunks) in malariagen_data/plasmodium.py.TypeErrorandValueErrorexceptions are raised for invalid inputs.Verification
All 32 tests in test_plasmodium.py pass successfully, and there are no changes to the behaviour for valid inputs.

Test Results:
Closes #1022