-
Notifications
You must be signed in to change notification settings - Fork 197
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 a --debug argument and some logging when retrieving CI status #2467
Conversation
03201bf
to
90e07fb
Compare
bodhi/client/bindings.py
Outdated
ch = logging.StreamHandler() | ||
ch.setLevel(logging.DEBUG) | ||
log.addHandler(ch) | ||
log.setLevel(logging.DEBUG) |
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.
libraries should not set up logging handlers or set log levels. This library is not just used by the bodhi cli and so it should be unopinionated about logging. It's OK for the lib to log things at debug level, but the logger should not be configured by it.
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.
Any preference where we could configure it?
I thought this was a good place since it was common with all the actions performed by the CLI, but I'm fine w/ changing this :)
On 07/25/2018 11:03 AM, Pierre-Yves Chibon wrote:
Any preference where we could configure it?
We should do it in bodhi/client/__init__.py. One way I can think of to
do it as a common action so you don't have to repeat code is you could
set up a validator on the --debug flag that does this if --debug is set.
There's already a validator in there on at least one flag as an example.
|
Is the validator you have in mind the I took a little bit of a different approach in the mean while, I've added the Again, if you prefer the validator approach I'll look into it some more :) |
On 07/26/2018 07:23 AM, Pierre-Yves Chibon wrote:
Is the validator you have in mind the |callback| used for the |--url|
argument? If not then I need to look further for this validator as I
think I didn't find it then :s
Yeah it's the callback system.
I took a little bit of a different approach in the mean while, I've
added the |--debug| argument to the |cli()| method, so all actions have
it, but it needs to be specified at the beginning of the argument list,
for example:
|bodhi --debug updates waive python-arrow-0.8.0-5.fc28 --show --staging|
works while:
|bodhi updates waive python-arrow-0.8.0-5.fc28 --show --staging --debug|
does not.
Again, if you prefer the validator approach I'll look into it some more :)
I think I prefer the validator approach since it will be more consistent
with how the rest of Bodhi's flags work, unless you can find a way to
make it work both ways (I don't know a way to do it off the top of my
head, but it might be possible.)
|
I've pushed a commit porting |
Rebased to fix the conflict |
--hm these tests are definitively passing locally :(-- Nevermind the last comment from jenkins confused me, they are also passing on jenkins now it seems :) |
bodhi/client/__init__.py
Outdated
client = bindings.BodhiClient(base_url=url, staging=kwargs['staging']) | ||
|
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 is an unrelated style change, so let's leave it as it is.
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
bodhi/client/__init__.py
Outdated
@@ -295,7 +327,7 @@ def new(user, password, url, **kwargs): | |||
True. | |||
kwargs (dict): Other keyword arguments passed to us by click. | |||
""" | |||
|
|||
kwargs.pop('debug') |
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.
Is this what you meant by being a larger change? If so, a cleaner way to do this is to add debug
as a parameter to each of these functions so it doesn't end up in kwargs
.
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.
Good idea, will fix
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.
Just a few more minor changes.
@@ -244,7 +274,8 @@ def composes(): | |||
@staging_option | |||
@click.option('-v', '--verbose', is_flag=True, default=False, help='Display more information.') | |||
@url_option | |||
def list_composes(url, staging, verbose): | |||
@debug_option | |||
def list_composes(url, staging, verbose, debug): |
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.
Note that we still document parameters in the "developer docs" section below, here and elsewhere in the file.
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.
Will add
bodhi/client/__init__.py
Outdated
@@ -295,7 +327,6 @@ def new(user, password, url, **kwargs): | |||
True. | |||
kwargs (dict): Other keyword arguments passed to us by click. | |||
""" | |||
|
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 is an unrelated style change.
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.
will remove
bodhi/client/__init__.py
Outdated
@add_options(pagination_options) | ||
@handle_errors | ||
def query(url, mine=False, rows=None, **kwargs): | ||
def query(url, mine=False, rows=None, debug=False, **kwargs): |
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.
Let's not define the default for debug
in two places. If you move this to be after url
, you don't need to give it a default.
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.
Will fix
bodhi/tests/client/test___init__.py
Outdated
mock.MagicMock(return_value='a_csrf_token')) | ||
@mock.patch('bodhi.client.bindings.BodhiClient.send_request', | ||
return_value=client_test_data.EXAMPLE_UPDATE_MUNCH, autospec=True) | ||
def test_severity_and_debug_flags(self, send_request): |
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 test is really about testing the debug flag, so let's name it test_debug_flag
for simplicity.
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.
Will adjust
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.
thanks for the review
@@ -244,7 +274,8 @@ def composes(): | |||
@staging_option | |||
@click.option('-v', '--verbose', is_flag=True, default=False, help='Display more information.') | |||
@url_option | |||
def list_composes(url, staging, verbose): | |||
@debug_option | |||
def list_composes(url, staging, verbose, debug): |
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.
Will add
bodhi/client/__init__.py
Outdated
@@ -295,7 +327,6 @@ def new(user, password, url, **kwargs): | |||
True. | |||
kwargs (dict): Other keyword arguments passed to us by click. | |||
""" | |||
|
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.
will remove
bodhi/client/__init__.py
Outdated
@add_options(pagination_options) | ||
@handle_errors | ||
def query(url, mine=False, rows=None, **kwargs): | ||
def query(url, mine=False, rows=None, debug=False, **kwargs): |
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.
Will fix
bodhi/tests/client/test___init__.py
Outdated
mock.MagicMock(return_value='a_csrf_token')) | ||
@mock.patch('bodhi.client.bindings.BodhiClient.send_request', | ||
return_value=client_test_data.EXAMPLE_UPDATE_MUNCH, autospec=True) | ||
def test_severity_and_debug_flags(self, send_request): |
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.
Will adjust
I think I got all of your comments, I also merged the new approach into the old one making the history cleaner. |
I forgot to mention when reviewing this one - can you also squash your
commits into 1? Thanks!
|
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.
Just 3 small things I'd like to fix, then we'll be good to merge.
bodhi/client/__init__.py
Outdated
Args: | ||
ctx (click.core.Context): The Click context. Unused. | ||
param (click.core.Option): The option being handled. Unused. | ||
value (unicode): The value of the --debug flag. |
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 is a bool
, not a unicode
.
bodhi/client/__init__.py
Outdated
param (click.core.Option): The option being handled. Unused. | ||
value (unicode): The value of the --debug flag. | ||
Returns: | ||
unicode: The value of the --debug flag. |
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 is also a bool
.
bodhi/client/__init__.py
Outdated
url_option = click.option('--url', envvar='BODHI_URL', default=bindings.BASE_URL, | ||
help=('URL of a Bodhi server. Ignored if --staging is set. Can be set ' | ||
'with BODHI_URL environment variable'), | ||
callback=_warn_if_url_and_staging_set) | ||
staging_option = click.option('--staging', help='Use the staging bodhi instance', | ||
is_flag=True, default=False) | ||
|
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.
Unrelated style change.
I will fix these three things myself. |
This creates a stream handler to the log and set its level to 'DEBUG'. This way we can use more log.info()/log.debug() in the binding files and ask users to run the CLI with --debug to give us more context as to what is going on. Signed-off-by: Pierre-Yves Chibon <[email protected]>
This way when running with --debug, we should be able to have more clues as to what is going on (if anything). Signed-off-by: Pierre-Yves Chibon <[email protected]>
Signed-off-by: Pierre-Yves Chibon <[email protected]>
Thanks @bowlofeggs :) |
These patches are planned to be included in the upcoming 3.10.0 release: #2556. |
These patches are available in Copr: https://copr.fedorainfracloud.org/coprs/bowlofeggs/bodhi-pre-release/ |
No description provided.