-
Notifications
You must be signed in to change notification settings - Fork 130
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
Proof-of-concept: warn that only last --exclude-where used when user passes multiple #1229
Conversation
…passes multiple See https://bedfordlab.slack.com/archives/C01LCTT7JNN/p1684360772513889 for discussion leading up to this This change is entirely backwards compatible. All it does is add a helpful warning
de7352b
to
ea609d1
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1229 +/- ##
==========================================
- Coverage 68.87% 68.86% -0.02%
==========================================
Files 64 64
Lines 6937 6940 +3
Branches 1693 1694 +1
==========================================
+ Hits 4778 4779 +1
- Misses 1854 1855 +1
- Partials 305 306 +1
☔ View full report in Codecov by Sentry. |
Since I think this would mirror how we handle multiple |
@joverlee521 Interesting, so you're saying we should change the behaviour? I'm open for that, but maybe it would be best to first start warning about that change then. This PR is more about the ability to warn than a case for changing it. I'm fine with the current behaviour as long as users are warned. |
# Use only last exclude_where argument for backward compatibility. | ||
# User warned in validate_arguments.py |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like how the validation logic is separate from the actual logic. It's not stated explicitly anywhere, but the way I see it is that validate_arguments.py contains logic done ahead of time to avoid unnecessary computation at the cost of logical duplication. For example, there's no point in going through filtering only to realize subsampling is not possible.
Since this change is done during filter construction which doesn't come after any computationally expensive tasks, I suggest doing the validation here and not validate_arguments.py.
if args.exclude_where and len(args.exclude_where) > 1: | ||
print_err(f"WARNING: You passed `--exclude-where` {len(args.exclude_where)} times. Only the last argument {args.exclude_where[-1]} will be used.\n" | ||
f"The following arguments {set(sum(args.exclude_where,[])).difference(set(args.exclude_where[-1]))} will be ignored.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the current behavior also applies to --include-where
and other filter options. Should those get the same treatment?
+1 for directly changing the behavior. I don't see it as a breaking change - if a user is specifying |
See https://bedfordlab.slack.com/archives/C01LCTT7JNN/p1684360772513889
for discussion leading up to this
This change is entirely backwards compatible. All it does is add a helpful warning
Description of proposed changes
Warn users that only last
--exclude-where
is used when user passes the same optional arg multiple times.This is a proof of concept. It would make sense to roll this out more systematically to all arguments where we have
nargs="+"
The warning looks as follows:
Testing
What steps should be taken to test the changes you've proposed?
If you added or changed behavior in the codebase, did you update the tests, or do you need help with this?
Checklist