Skip to content

feat: add input parameter validation to PlasmodiumDataResource public methods#1024

Open
suhaan-24 wants to merge 4 commits intomalariagen:masterfrom
suhaan-24:fix/plasmodium-parameter-validation
Open

feat: add input parameter validation to PlasmodiumDataResource public methods#1024
suhaan-24 wants to merge 4 commits intomalariagen:masterfrom
suhaan-24:fix/plasmodium-parameter-validation

Conversation

@suhaan-24
Copy link
Contributor

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 KeyError or dask TypeError) instead of a helpful message at the API boundary. This change improves the developer experience by catching these errors early.

Changes

  • Added isinstance and type checks to the top of variant_calls() (extended, inline_array, chunks) and genome_sequence() (region, inline_array, chunks) in malariagen_data/plasmodium.py.
  • Added 5 new tests to tests/test_plasmodium.py to verify that helpful TypeError and ValueError exceptions 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:
Screenshot 2026-03-02 at 11 59 04 PM

Closes #1022

@suhaan-24
Copy link
Contributor Author

@jonbrenas Please take a look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve API robustness in PlasmodiumDataResource by adding explicit input validation

1 participant