Skip to content

[python-package] make Booster and Dataset 'handle' attributes private (fixes #5313) - #5947

Merged
jameslamb merged 3 commits into
masterfrom
internalize-handle
Jun 29, 2023
Merged

jameslamb merged 3 commits into
masterfrom
internalize-handle

Conversation

@jameslamb

@jameslamb jameslamb commented Jun 27, 2023 •

Copy link
Copy Markdown
Member

Fixes #5313.

Removes handle attribute from the public API in the Python package, with the following changes:

  • Booster.handle -> Booster._handle
  • Dataset.handle -> Dataset._handle
  • _InnerPredictor.handle -> _InnerPredictor._handle

Why?

Making this implementation detail private allows changing it in the future without breaking user code.

@StrikerRUS originally recommended this, and I agree: #5313 (comment)

What about the R package?

Handles are already private there.

https://github.com/microsoft/LightGBM/blob/9edea60edc5db7785508d0f5981890ac1e1b430a/R-package/R/lgb.Booster.R#L107

https://github.com/microsoft/LightGBM/blob/9edea60edc5db7785508d0f5981890ac1e1b430a/R-package/R/lgb.Dataset.R#L285

How impactful will this be?

I don't know for sure what uses cases are out there where people are relying on the handle attribute being public in the Python package. But I did a quick check of popular open source projects relying on lightgbm (https://www.wheelodex.org/projects/lightgbm/rdepends/) and didn't find any uses there:

@jameslamb jameslamb changed the title WIP: [python-package] make Booster and Dataset 'handle' attributes private (fixes #5313) [python-package] make Booster and Dataset 'handle' attributes private (fixes #5313) Jun 27, 2023
@jameslamb
jameslamb marked this pull request as ready for review June 27, 2023 02:56
@jameslamb
jameslamb requested a review from guolinke June 27, 2023 19:55
@jameslamb jameslamb mentioned this pull request Jun 28, 2023
31 of 60 tasks
@jameslamb
jameslamb merged commit b8cc873 into master Jun 29, 2023
@jameslamb
jameslamb deleted the internalize-handle branch June 29, 2023 13:02
@github-actions

github-actions Bot commented Oct 4, 2023

Copy link
Copy Markdown
Contributor

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 Oct 4, 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.

[python-package] prefix all internal object names with "_"

2 participants