fix: only set logging level when explicitly requested#1551
Open
haoyu-haoyu wants to merge 1 commit intostanfordnlp:devfrom
Open
fix: only set logging level when explicitly requested#1551haoyu-haoyu wants to merge 1 commit intostanfordnlp:devfrom
haoyu-haoyu wants to merge 1 commit intostanfordnlp:devfrom
Conversation
download(), install_corenlp(), and Pipeline.__init__ all called set_logging_level() unconditionally, even when the caller passed neither logging_level nor verbose. This caused set_logging_level() to reset the logger to INFO as a side effect, overriding any logging configuration the user had set up. Guard all three call sites so set_logging_level() is only invoked when the caller explicitly passes logging_level or verbose. When both are None (the default), the user's existing logging setup is left untouched. Closes stanfordnlp#1418
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
download(),install_corenlp(), andPipeline.__init__()all calledset_logging_level()unconditionally, even when the caller passed neitherlogging_levelnorverbose. This causedset_logging_level(None, None)to reset the stanza logger toINFOas a side effect, overriding any logging configuration the user had set up.Closes #1418
Problem
Fix
Guard all three call sites so
set_logging_level()is only invoked when the caller explicitly passeslogging_levelorverbose:Files changed
stanza/resources/common.pydownload()stanza/resources/installation.pyinstall_corenlp()stanza/pipeline/core.pyPipeline.__init__()Backward compatibility
logging_level='DEBUG'orverbose=Trueget the same behavior as beforestanza.download('en', logging_level='ERROR')still works