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

[R-package] remove broken default for file in readRDS / saveRDS functions #3664

Merged
merged 8 commits into from
Jan 3, 2021

Conversation

jameslamb
Copy link
Collaborator

@jameslamb jameslamb commented Dec 20, 2020

The functions readRDS.lgb.Booster() and saveRDS.lgb.Booster() in the R package take a keyword argument file, which indicates the .rds file to use.

Those functions use default file = "", but this isn't a valid value for that parameter.

readRDS.lgb.Booster():

Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file '', probable reason 'No such file or directory'

saveRDS.lgb.Booster(list(raw = 1))

Error in saveRDS(object, file = file, ascii = ascii, version = version, :
'file' must be non-empty string

This PR proposes just removing the default value, and forcing users to choose a filepath. I think this is preferable to changing the default value to something like "model.rds", because it makes code using these functions more explicit, and thus less at risk of errors.

While testing this, I created some .rds files and noticed they weren't ignore by git. This PR also changes .gitignore to ignore R's binary formats (.rda, .rds, .RData) so such files aren't accidentally checked into source control.

@jameslamb jameslamb merged commit 85b9daa into microsoft:master Jan 3, 2021
@jameslamb jameslamb deleted the r/rds-defaults branch January 3, 2021 16:58
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants