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

[python][R-package] removed duplicated code from language wrappers #2606

Merged
merged 6 commits into from
Feb 3, 2020

Conversation

StrikerRUS
Copy link
Collaborator

Removed checks from language wrappers that are handled at cpp side.

LightGBM/src/c_api.cpp

Lines 176 to 187 in bbc45fe

void ResetConfig(const char* parameters) {
std::lock_guard<std::mutex> lock(mutex_);
auto param = Config::Str2Map(parameters);
if (param.count("num_class")) {
Log::Fatal("Cannot change num_class during training");
}
if (param.count("boosting")) {
Log::Fatal("Cannot change boosting during training");
}
if (param.count("metric")) {
Log::Fatal("Cannot change metric during training");
}

@StrikerRUS StrikerRUS changed the title removed duplicated code from language wrappers [python][R-package] removed duplicated code from language wrappers Dec 2, 2019
@StrikerRUS
Copy link
Collaborator Author

StrikerRUS commented Dec 2, 2019

@guolinke According to this commit, seems that metric cannot be reset anymore, right?
714c673
So, this code is outdated too.

if any(metric_alias in params for metric_alias in _ConfigAliases.get("metric")):
self.__need_reload_eval_info = True

Copy link
Collaborator

@jameslamb jameslamb 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! I'm glad we can push more of this logic into the cpp side. Thank you!

@StrikerRUS
Copy link
Collaborator Author

@guolinke Can you please confirm this #2606 (comment)?

@guolinke
Copy link
Collaborator

guolinke commented Dec 6, 2019

@StrikerRUS it seems you are right. but I don't remember why __need_reload_eval_info is there...

@StrikerRUS
Copy link
Collaborator Author

@guolinke

it seems you are right. but I don't remember why __need_reload_eval_info is there...

Maybe in some point in the past it was possible to reset metric param? __need_reload_eval_info is used only once here:

def __get_eval_info(self):
"""Get inner evaluation count and names."""
if self.__need_reload_eval_info:
self.__need_reload_eval_info = False

Anyway, as at present resetting metric leads to fatal error, keeping that code seems to be unreasonable.

@jameslamb jameslamb self-requested a review December 23, 2019 20:24
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-reviewed since some time has passed since the PR was opened. R side still looks good to me!

@StrikerRUS
Copy link
Collaborator Author

Thanks @jameslamb !

I'm about to merge this PR, but want to make sure that @guolinke hasn't accidentally remembered why self.__need_reload_eval_info = True was here.

@guolinke
Copy link
Collaborator

guolinke commented Feb 2, 2020

@StrikerRUS I think you can remove the __need_reload_eval_info

@StrikerRUS StrikerRUS merged commit bef8359 into master Feb 3, 2020
@StrikerRUS StrikerRUS deleted the clean_code branch February 3, 2020 02:57
@lock lock bot locked as resolved and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants