-
Notifications
You must be signed in to change notification settings - Fork 75
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
Refactor Logging, Add GitHub Graph Backend #2131
Conversation
a715667
to
99b65b3
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #2131 +/- ##
==========================================
+ Coverage 73.21% 73.93% +0.72%
==========================================
Files 96 97 +1
Lines 9265 9435 +170
==========================================
+ Hits 6783 6976 +193
+ Misses 2482 2459 -23 ☔ View full report in Codecov by Sentry. |
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 mentioned below, I think supporting writes is pretty straightforward and would allow all changes to be diffed. Otherwise LGTM
@ytausch Can you please separate out the |
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 am still going through the PR but here are some initial comments.
bf72204
to
61372dc
Compare
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.
More comments. Sorry they are coming bit by bit. This diff makes non-trivial changes in more than one spot. A few suggestions.
-
It appears something like isort was run on some of the files? Can we add this to pre-commit in another PR?
-
Can the changes to the versions code and the lazyjson stuff be in two separate PRs?
-
Have you run this code live locally? There can be subtle issues with changes in how the code is structured causing new and destructive I/O patterns. Whenever you do any operation on the "payload" object (called "attrs" in much of the code), the lazy json backends will do things like download the json, read it into memory, make calls to a DB etc. So how those operations are structured in the code is pretty important.
@@ -1,16 +1,28 @@ | |||
import networkx as nx |
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.
These changes are pretty extensive. Is there a way we can add what you need without all of the refactoring here? The bot test suite is not good enough to detect bugs in the new code and I am worried this is going to fail once we run it live.
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 discussion now belongs to #2139 - but let me give a short reply here: Of course the refactoring is not necessary but my point is that the code is now more modular, more descriptive, generates more helpful debug output, and can also be tested rather well.
Also, I did not introduce big structural changes so it should be possible to verify the correctness of my changes in a code review. Unit tests now cover the entirety of my changes.
Actually it was the automatic
Do you mean separating the logic for updating a single package into another PR? I can do that, sure. As an explanation: I think the GitHub LazyJSON backend only makes sense if used for updating one single package. This is why I introduced both changes at once.
I did not test the code with the MongoDB backend, only with the file backend locally. I don't think my changes should break something if the MongoDB backend adheres to the LazyJsonBackend specification but I will test it nonetheless. It's understandable that you want to be extra-cautious to not break production. |
6f3c847
to
94fd022
Compare
c55bd87
to
1881825
Compare
A note about your comment "did you test this live locally": I will now look into the possibility to develop a basic integration test that ensures basic functionality for future changes. This will be a separate PR. |
4014edc
to
755fed1
Compare
handling of empty/nonexistent graph file
This reverts commit 02101bc.
99fb4a0
to
774aff0
Compare
I ran this though mypy and verified manually that my changes do not introduce new type issues. |
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.
LGTM! Nice work on the github backend!
def setup_logger(logger: logging.Logger, level: str = "INFO") -> None: | ||
"""Basic configuration for logging""" | ||
logger.setLevel(level.upper()) | ||
ch = logging.StreamHandler() | ||
ch.setLevel(level.upper()) | ||
ch.setFormatter( | ||
logging.Formatter("%(asctime)-15s %(levelname)-8s %(name)s || %(message)s"), | ||
def setup_logging(level: str = "INFO") -> None: | ||
logging.basicConfig( | ||
format="%(asctime)-15s %(levelname)-8s %(name)s || %(message)s", | ||
level=level.upper(), | ||
) | ||
logger.addHandler(ch) | ||
# this prevents duplicate logging messages | ||
logger.propagate = False | ||
logging.getLogger("urllib3").setLevel(logging.INFO) |
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.
It looks like this change broke the bot
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.
Bot is functioning fine. It broke ci tests on that repo which are there only to double check manual changes.
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.
That's fair. Wrote that kind of tersely
Am not seeing this function used in the org. Are we getting an old package?
Important
This PR is an extension of #2139. #2139 should be reviewed and merged first.
As part of my work on #2123, this PR adds the following changes:
setup_logging
instead of configuring each module-level logger individually--online
CLI option that downloads missing dependency graph files from GitHub on demand (uses the new GithubLazyJsonBackend)