Repository navigation
[R-package] Ensure print.lgb.Booster() works when objective is not explicitly set - #6850
Conversation
β¦s out of method tests, creating unique tests for different method situations
jameslamb
left a comment
There was a problem hiding this comment.
Thanks very much! Please see my first round of suggestions.
Also... I noticed that you pushed multiple commits to fix linter errors. That's totally fine to do, but you might find it easier to run the linting yourself locally.
For R code:
# install {lintr} (you only need to do this once)
Rscript -e "install.packages('lintr', repos = 'https://cran.r-project.org')"
# run the R linting
Rscript .ci/lint-r-code.R $(pwd)For other things like trailing whitespace and newlines, you can run that linting locally too. You just need to install pre-commit (https://pre-commit.com/)... for example:
pip install pre-commit
pre-commit run --all-files| }) | ||
| .have_same_handle(ret, model) | ||
| .has_expected_content_for_finalized_model(log_txt) | ||
| } |
There was a problem hiding this comment.
Thanks for pulling these out! But could you please move them down to right before the first test case using them?
If they were more generically useful or used in more places I'd agree with putting helper functions like this at the top of the file, but in this case they're highly specific to the {print,show,summary}.lgb.Booster() test cases.
There was a problem hiding this comment.
For sure! I will get on that.
|
Some other notes I meant to add:
|
| , params = list(num_threads = .LGB_MAX_THREADS) | ||
| ) | ||
|
|
||
| log_txt <- capture.output(print(model)) |
There was a problem hiding this comment.
I am checking that the output of print() for a booster is "Objective: (default)" before .check_methods_work() is called. My rationale for this order of operations is that the model is finalized in .check_methods_work() and .has_expected_content_for_finalized_model() checks that the printout is correctly modified to "Booster handle is invalid" which removes "Objective: (default)" from the output. So we can first check that "Objective: (default)" is reported and then run .check_methods_work().
There was a problem hiding this comment.
ohhhhh I forgot about that. Ok makes sense to me! Thanks for the explanation.
|
Could we restart the CI workflow? The failing check does not appear to be related to this issue: qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/LightGBM/.ci/setup.sh: line 146: 15 Segmentation fault sudo yum update -y
##[error]Bash exited with code '1'.
Finishing: Setup and run tests |
|
Hmm I am still not sure this is related to my PR. Is it best practice for me to continue periodically requesting a CI run in instances such as this? |
|
Could we run the CI workflow for this PR? Thanks! |
|
I think the CI workflow failed for something unrelated to my PR. Should we try again? Linting PowerShell code
RuleName Severity ScriptName Line Message
-------- -------- ---------- ---- -------
PSUseCorrectCasing Information test-windo 21 Keyword 'Exit
ws.ps1 ' does not ma
tch the expec
ted case 'exi
t'.
PSUseCorrectCasing Information test-windo 28 Keyword 'Exit
ws.ps1 ' does not ma
tch the expec
ted case 'exi
t'.
PSUseCorrectCasing Information test-windo 62 Keyword 'Exit
ws.ps1 ' does not ma
tch the expec
ted case 'exi
t'.
Error: Process completed with exit code 1. |
Thanks for your effort here! I agree that this looks unrelated to your changes. You don't need to ask for any more re-runs, we'll try to get this fixed separately and come back to update your PR. Sorry for the inconvenience. |
Thanks James, I appreciate it. Iβll sit tight for now. |
|
/AzurePipelines run |
jameslamb
left a comment
There was a problem hiding this comment.
Looks great, thanks so much for this!!
|
/AzurePipelines run |
|
@shiyu1994 Could you please restart VM for CUDA CI? Seems that it's stuck. |
|
Kindly ping @shiyu1994 |
|
/AzurePipelines run |
|
Thanks for fixing CUDA CI @shiyu1994, for getting this merged @StrikerRUS , and for taking the time to contribute @walkerjameschris ! |
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
Fixes #6848
This PR fixes an issue where
lgb.train()creates a booster, the booster is printed, and no objective is specified. This led to an error due to aNULLvalue. I have handled this by extracting the default objective (looks to bel2) and printing that in the event a built-in or custom objective is not provided.