-
Notifications
You must be signed in to change notification settings - Fork 8
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 logger and update the config handling #85
Conversation
6c2fd29
to
f154a71
Compare
baldrick/github/github_api.py
Outdated
if not branch: | ||
branch = 'master' | ||
def get_file_contents(self, path_to_file, branch='master'): | ||
global file_cache |
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.
Why the global? You don't need it since you are modifying it inplace
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.
Explicit is better than implicit? 😀
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.
Well I still prefer to avoid this if possible and would prefer to use e.g. uppercase notation, but I'll leave it up to you
Codecov Report
@@ Coverage Diff @@
## master #85 +/- ##
=========================================
Coverage ? 82.06%
=========================================
Files ? 17
Lines ? 864
Branches ? 0
=========================================
Hits ? 709
Misses ? 155
Partials ? 0
Continue to review full report at Codecov.
|
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.
Looks great to me!
baldrick/github/github_api.py
Outdated
if not branch: | ||
branch = 'master' | ||
def get_file_contents(self, path_to_file, branch='master'): | ||
global file_cache |
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.
Well I still prefer to avoid this if possible and would prefer to use e.g. uppercase notation, but I'll leave it up to you
@astrofrog I have changed it to |
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.
As long as it works for you, looks fine by me. I'll defer to @astrofrog for final approval.
And I guess the pretty logs are not for the eyes with Heroku admin access?
I was having some issues with my config on Giles, so this is a two pronged attempt at fixing it.
Firstly, this adds
loguru
as a nice and easy way for us to do proper logging in Baldrick, which will hopefully make debugging things easier in the future. I had to do some trickery with redirecting the loguru logs back to python stdlib logging for pytest, but it seems to be working fine.Secondly, I have changed the way we cache the config for a repo/branch. Previously we were caching the config keys after all the files had been read. I have changed this so that we cache all github file accesses for one minute. In my opinion this moves the cache to where the requests we want to avoid getting rate limited on and makes the flow of the config functions easier to understand.
I have also tried to make the ordering of the config files more explicit, the three different configs are read in the following order:
bot_name
as the keyI have also made it log at trace and debug the configs it reads from where to make debugging misconfigurations possible.