-
Notifications
You must be signed in to change notification settings - Fork 87
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
Update our Logger to use python's logging package, revised #763
Conversation
Codecov Report
@@ Coverage Diff @@
## master #763 +/- ##
==========================================
+ Coverage 99.42% 99.51% +0.08%
==========================================
Files 150 150
Lines 5709 5718 +9
==========================================
+ Hits 5676 5690 +14
+ Misses 33 28 -5
Continue to review full report at Codecov.
|
assert "EvalML version:" in caplog.text | ||
assert "EvalML installation directory:" in caplog.text | ||
assert "SYSTEM INFO" in caplog.text | ||
assert "INSTALLED VERSIONS" in caplog.text |
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.
Shouldn't this still use capsys
, since this is testing a CLI?
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.
Seems like caplog
grabs the output of the logger--which has a handler to stdout and hence prints to stdout. Similar to the other comment about capsys/caplog
def test_logger_critical(caplog): | ||
logger.critical("Test critical") | ||
assert "Test critical" in caplog.text | ||
assert "CRITICAL" in caplog.text |
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.
@angela97lin these tests are helpful! Love it.
I suggest you also add capsys
to them, and add another similar test for DEBUG
-level. That way, we can ensure everything goes into the log file, and that INFO
and above make it into stdout while DEBUG
doesn't.
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.
@dsherry I thought about this, but I don't think I'm able to add capsys fixture for logging. I can share screenshots of what I've tried:
So oddly, it's printed out in the "Captured stdout call" but out returns an empty string. I can keep poking around though!
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.
Ah, got it. No problem! That's so weird.
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 saw a potentially related issue: pytest-dev/pytest#5997
I manually tested by removing one handler and checking that tests still passed but 🤷♀️
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.
@angela97lin , this rocks!! 😁 So happy this is coming in time for the release too. Great stuff. I left one testing request and some other minor comments. Go ahead and merge once you feel those are addressed!
@angela97lin : I responded to a few of your comments. This is still ready to go from my perspective! |
elif self.max_pipelines: | ||
if num_pipelines >= self.max_pipelines: | ||
return False | ||
elif self.max_time and elapsed >= self.max_time: | ||
logger.log("\n\nMax time elapsed. Stopping search early.") |
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 the elif and cleaned this up because I don't this this was reachable code (would have hit the first if statement)
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.
Nice! I saw this in codecov a couple weeks ago and tried to clean it up and it kept failing unit tests. Cool that you got it passing
Closes #690, continuation of work in #694
Note:
log_subtitle
andlog_title
will log using name=logger.py
since that's where the call to logger.info is.