feat: refactor suspension type validation logic to be simpler and more performant #1155
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.
Reason for Change
Changes
schema_definition.yaml
to always use the (formerly known as) "complex_rule" format of defining your pandas queries in YAML rather than directly writing pandas queries as part of the definition.- therefore, rename "complex_rule" --> "rule" and rewrite existing "rule" entries to use this format
assay_ontology_term_id.dependencies
definition to group together assays that are validating for the same suspension_type (i.e. instead of 3 separate entries for "EFO:1", "EFO:2", and "descendants of EFO:3" must evaluate to suspension_type "cell", group them all into one dependency entry).- the groups are: suspension_type should be "cell" vs. "nucleus" vs. "na" vs. "cell or nucleus".
_validate_column_dependencies
to simplify the query builder--build set of terms to check (including descendants, if applicable), and run a single "isin" query per rule inschema_definition.yaml
rather than a custom vectorized function. This is more performant for our use cases._generate_match_ancestors_query_fn
, no longer usedschema_definition.yaml
. This will log which column values were matched and did not fit the rule definition (i.e. which assays in the df contain a suspension_type value validation error)Testing
Notes for Reviewer