-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
suppress alias warnings with verbosity<0 (fixes #4518) #5253
Changes from 4 commits
c5b7e36
e99946a
36631f8
feb3b86
620c6bd
8b36983
a224553
6a96366
88dcf59
b42781b
d26cb59
96a11fd
56474ad
c10f4aa
eb55c47
956f936
e9a7a0f
e216e43
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -42,6 +42,19 @@ std::unordered_map<std::string, std::string> Config::Str2Map(const char* paramet | |||||||
for (auto arg : args) { | ||||||||
KV2Map(¶ms, Common::Trim(arg).c_str()); | ||||||||
} | ||||||||
// define verbosity and set logging level | ||||||||
int verbosity = Config().verbosity; | ||||||||
jmoralez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
GetInt(params, "verbose", &verbosity); | ||||||||
GetInt(params, "verbosity", &verbosity); | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If params have both LightGBM/include/LightGBM/config.h Lines 1145 to 1147 in 1cc9f9d
to inform user that verbosity has higher precedence over verbose .
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is done in the
jmoralez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
if (verbosity < 0) { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Fatal); | ||||||||
} else if (verbosity == 0) { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Warning); | ||||||||
} else if (verbosity == 1) { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Info); | ||||||||
} else { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Debug); | ||||||||
} | ||||||||
ParameterAlias::KeyAliasTransform(¶ms); | ||||||||
return params; | ||||||||
} | ||||||||
|
@@ -240,16 +253,6 @@ void Config::Set(const std::unordered_map<std::string, std::string>& params) { | |||||||
save_binary = true; | ||||||||
} | ||||||||
|
||||||||
if (verbosity == 1) { | ||||||||
jmoralez marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Info); | ||||||||
} else if (verbosity == 0) { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Warning); | ||||||||
} else if (verbosity >= 2) { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Debug); | ||||||||
} else { | ||||||||
LightGBM::Log::ResetLogLevel(LightGBM::LogLevel::Fatal); | ||||||||
} | ||||||||
|
||||||||
// check for conflicts | ||||||||
CheckParamConflict(); | ||||||||
} | ||||||||
|
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 like the following warnings in
KV2Map()
function are still cannot be suppressed by passingverbosity
param because// define verbosity and set logging level
happens later in the codeLightGBM/src/io/config.cpp
Lines 28 to 35 in 1cc9f9d
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 warnings come from duplicated parameters, not aliases. I can try to address them as well in this PR if its in the scope.
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 believe it's related.
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.
Second thought on this, maybe we should leave the duplicates warning? I think it helps the user more than being annoying, since you can remove the warnings by removing the duplicate argument or you can confirm that the argument passed through the CLI is overriding the one on the config file.
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 agree with you. I believe each warning is helpful, but unfortunately LightGBM users want to completely silence their program (according to the issues they create in the repo).
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.
Addressed by having an unordered_map of vectors where we store all parameters for as many times as they're defined, set the verbosity taking the first values of
verbose
andverbosity
and then de-duplicating with theKeepFirstValues
function, where warning level logs are printed but after the verbosity has been set, so these can be disabled as well.