Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom-cohort creation script patch #875

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open

Conversation

MattWellie
Copy link
Contributor

@MattWellie MattWellie commented Jul 18, 2024

Interface changes

Needed

  • dry-run doesn't work. The boolean is captured appropriately, but when sent to create_cohort_from_criteria it's ignored. This PR has not resolved that
  • project, name, description made mandatory (?)

QOL

  • projects changed from type=str, nargs='*' to a nargs='*', default=[] - the type here was misleading as we want a list?
  • multiple args changed from required=False, type=list[str] to nargs='*', default=[]
    • these are all lists of strings with none-to-many elements (though typically 1)
    • if the flag is not used, the value becomes an empty list
    • argparse's type doesn't work with nested types (afaik, the passed type is used as a callable), so list[str] is just list
    • argparse's type also casts values to the given type, so --sg_platform illumina becomes ['i', 'l', 'l', 'u', 'm', 'i', 'n', 'a'], instead of ['illumina'] (the result of list(input) instead of [input]

Strict Checking

  • where there's a strict enumeration of valid values in metamist I've applied these using choices - could bin this off, or query metamist for the available choices at runtime.

Challenge:

python scripts/create_custom_cohort.py --project matt --name MATT --description "Matt desc" --projects matt not_matt --sg_technology short-read --sg_platform illumina --sg_type genome --sg_ids_internal CPGA --sample_type blood

Current Result: (I couldn't find any way to use multiple CPG IDs, so just using a list of one in this toy example)

{'project': 'matt', 'name': 'MATT', 'description': 'Matt desc', 'template_id': None, 'projects': ['matt', 'not_matt'], 'sg_ids_internal': ['C', 'P', 'G', 'A'], 'excluded_sgs_internal': None, 'sg_technology': ['s', 'h', 'o', 'r', 't', '-', 'r', 'e', 'a', 'd'], 'sg_platform': ['i', 'l', 'l', 'u', 'm', 'i', 'n', 'a'], 'sg_type': ['g', 'e', 'n', 'o', 'm', 'e'], 'sample_type': ['b', 'l', 'o', 'o', 'd'], 'dry_run': False}

New Result:

{'project': 'matt', 'name': 'MATT', 'description': 'Matt desc', 'template_id': None, 'projects': ['matt', 'not_matt'], 'sg_ids_internal': ['CPGA'], 'excluded_sgs_internal': [], 'sg_technology': ['short-read'], 'sg_platform': ['illumina'], 'sg_type': ['genome'], 'sample_type': ['blood'], 'dry_run': False}

@MattWellie MattWellie requested a review from vivbak July 18, 2024 07:50
Copy link
Contributor

@vivbak vivbak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge thanks for this @MattWellie!
I'm just trying to think of a simple way to make codecov happy, presumably by testing that the parser is working correctly (?)

Not a super clear part of the code to test, to me.

@MattWellie
Copy link
Contributor Author

I'm just trying to think of a simple way to make codecov happy, presumably by testing that the parser is working correctly (?)

Yeah, there's a couple of ways to solve that. I'll have a tinker this morning!

Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 98.38710% with 1 line in your changes missing coverage. Please review.

Project coverage is 80.83%. Comparing base (e3a7f39) to head (c6272c4).
Report is 5 commits behind head on dev.

Files Patch % Lines
scripts/create_custom_cohort.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #875      +/-   ##
==========================================
+ Coverage   80.67%   80.83%   +0.15%     
==========================================
  Files         172      172              
  Lines       14551    14603      +52     
==========================================
+ Hits        11739    11804      +65     
+ Misses       2812     2799      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

2 participants