-
Notifications
You must be signed in to change notification settings - Fork 188
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
add new flag: --skip-service #276
Conversation
Related feature request: #275 |
@tamsky Thank you very much for this; this will also help the person who opened #267. This is a bit more complicated of a PR, so I'm going to need a bit longer to review it. The TravisCI tests also failed on all unit test runs, so I can't see coverage information... but it looks like the failures were all due to pep8 violations (specifically, lines 105 and 131 in The docs build failure was happening at the time of your last PR as well. From what I can tell, it is most likely related to an issue or change in the build of the official Python docs. I'll ignore those failures for now, and fix the problem on |
TravisCI tests all fixed except one, which I'll guess you're better equipped to diagnose. |
Thanks. That's the docs build failure that I mentioned in my last comment. It's not related to your changes, so I'll merge this to develop and sort it out sometime this week. It looks like code coverage decreased a bit on this; there are a few branches that aren't covered. I can fix those up after merge though. I'm going to go through the code now. |
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.
The idea behind this is great, but there are some stylistic changes that could greatly simplify the code. I can merge this if you make them, or I can pull in these changes and rework them myself before I cut a new release later this week.
awslimitchecker/checker.py
Outdated
returning limits for | ||
:type service_to_skip: list | ||
""" | ||
if service_to_skip is not None: |
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.
The code and signature of this function would be much simpler of service_to_skip
defaulted to an empty list instead of None. That would allow removal of the if
branch here, and make the signature of the function look more like what it does. Also, service
in the variable name should be pluralized.
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.
Also, for what it's worth, I'd probably rename this function to either remove_services
or skip_services
.
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.
function signature updated as suggested.
if
removed.
service_to_skip
variable name changed to services_to_remove
.
awslimitchecker/runner.py
Outdated
@@ -358,6 +361,11 @@ def console_entry_point(self): | |||
ta_refresh_timeout=args.ta_refresh_timeout | |||
) | |||
|
|||
if args.skip_service is not None: | |||
if args.service is not None: | |||
raise SystemExit(0) |
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.
This conditional needs a bit more work. If we're considering skip_service
and service
to be mutually exclusive, then that should be handled in parse_args
, by telling Argparse that the options are mutually exclusive (see line 164 for an example of adding a mutually exclusive argument group).
Aside from that, on these lines we're raising a SystemExit
with code 0, which implies success, but this is actually an error condition. That would be very confusing to a user, as the program would exit early with no indication of why.
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 actually implemented the add_mutually_exclusive_group()
style arg, but wound up without a firm belief that they were, in fact, mutually exclusive.
If someone wanted to list --service A B C
and also --skip-service C
, I can't say it's strictly wrong, or even confusing.
Happy to remove this block (364-366) if you agree.
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.
Yeah, I agree. I think it's clear enough.
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.
Aside from this one last bit here, your last commit looks good; I'll merge once these conditionals are removed and tests pass.
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.
Removed.
awslimitchecker/runner.py
Outdated
@@ -358,6 +361,11 @@ def console_entry_point(self): | |||
ta_refresh_timeout=args.ta_refresh_timeout | |||
) | |||
|
|||
if args.skip_service is not None: |
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.
This conditional is not needed at all; the add_argument
call for --skip-service
can have default=[]
added to it to produce an empty list if not specified; that can be passed directly in to remove_skipped_services
.
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.
Updated.
Codecov Report
@@ Coverage Diff @@
## develop #276 +/- ##
===========================================
- Coverage 100% 99.88% -0.12%
===========================================
Files 23 23
Lines 1691 1699 +8
Branches 262 265 +3
===========================================
+ Hits 1691 1697 +6
- Misses 0 1 +1
- Partials 0 1 +1
Continue to review full report at Codecov.
|
@@ -614,6 +619,19 @@ def test_entry_no_service_name(self, capsys): | |||
assert excinfo.value.code == 6 | |||
assert self.cls.service_name is None | |||
|
|||
def test_entry_no_service_name_skip_service(self, capsys): |
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.
My question regarding tests was here.
Can we perform a better test than this?
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.
We can, but you've done more than enough work on this PR... that's entirely up to you. The test suite is pretty clunky, so I usually expect to add or rework some tests after merging PRs.
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.
Ok, well then -- thank you for the codereview, and suggested edits, they were all spot on.
I've definitely learned a few things along the way here.
I'll watch what you do to improve this test from the sidelines.
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.
Ok. It's probably not going to be until this weekend, sorry.
tox -e docs
was producing non-useful diffs.Contributor License Agreement
By submitting this work for inclusion in awslimitchecker, I agree to the following terms:
is being made under the same license as the awslimitchecker project (the Affero GPL v3,
or any subsequent version of that license if adopted by awslimitchecker).
this pull request grants a perpetual, global, unlimited license for it to be used and distributed
under the terms of awslimitchecker's license.
Signed-off-by: tamsky