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

Add a logger and update the config handling #85

Merged
merged 18 commits into from
Sep 5, 2019

Conversation

Cadair
Copy link
Member

@Cadair Cadair commented Sep 3, 2019

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:

  1. repo config with bot_name as the key
  2. repo config with fallback name as the key if set on the app.
  3. app deployment config.

I have also made it log at trace and debug the configs it reads from where to make debugging misconfigurations possible.

@Cadair Cadair force-pushed the logging branch 2 times, most recently from 6c2fd29 to f154a71 Compare September 3, 2019 17:17
if not branch:
branch = 'master'
def get_file_contents(self, path_to_file, branch='master'):
global file_cache
Copy link
Collaborator

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

Copy link
Member Author

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? 😀

Copy link
Collaborator

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-io
Copy link

codecov-io commented Sep 4, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@f67c60f). Click here to learn what that means.
The diff coverage is 90.66%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master      #85   +/-   ##
=========================================
  Coverage          ?   82.06%           
=========================================
  Files             ?       17           
  Lines             ?      864           
  Branches          ?        0           
=========================================
  Hits              ?      709           
  Misses            ?      155           
  Partials          ?        0
Impacted Files Coverage Δ
baldrick/plugins/github_towncrier_changelog.py 85.71% <100%> (ø)
baldrick/plugins/github_pull_requests.py 79.71% <100%> (ø)
baldrick/plugins/circleci_artifacts.py 100% <100%> (ø)
baldrick/plugins/github_milestones.py 100% <100%> (ø)
baldrick/conftest.py 100% <100%> (ø)
baldrick/logging.py 81.81% <81.81%> (ø)
baldrick/github/github_api.py 64.13% <85.71%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f67c60f...101bf71. Read the comment docs.

Copy link
Collaborator

@astrofrog astrofrog left a 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!

if not branch:
branch = 'master'
def get_file_contents(self, path_to_file, branch='master'):
global file_cache
Copy link
Collaborator

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

@Cadair
Copy link
Member Author

Cadair commented Sep 4, 2019

@astrofrog I have changed it to FILE_CACHE and got rid of the global. I agree that makes more sense.

Copy link
Contributor

@pllim pllim left a 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?

baldrick/github/github_api.py Outdated Show resolved Hide resolved
baldrick/github/github_api.py Outdated Show resolved Hide resolved
doc/heroku.rst Outdated Show resolved Hide resolved
@Cadair Cadair merged commit f592c28 into OpenAstronomy:master Sep 5, 2019
@Cadair Cadair deleted the logging branch September 5, 2019 13:19
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.

4 participants