-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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-package] Separately check whether pyarrow
and cffi
are installed
#6785
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
6b37b34
Implement code as suggested by @jameslamb
mlondschien 512550b
Add test.
mlondschien a85027b
Try pyarrow.cffi
mlondschien 5852ce6
Merge branch 'master' of github.com:microsoft/LightGBM into issue-6782
jameslamb acd5729
Merge branch 'master' of github.com:microsoft/LightGBM into issue-6782
jameslamb e72d5e2
fix compat.arrow_cffi, clarify log messages, fix tests
jameslamb a4a711d
keep fixtures in alphabetical order
jameslamb 8992344
Merge branch 'master' into issue-6782
jameslamb 56127f5
Update python-package/lightgbm/compat.py
jameslamb 7396613
update docstring, remove unnecessary class members, re-organize test
jameslamb 0526390
Merge branch 'issue-6782' of github.com:mlondschien/LightGBM into iss…
jameslamb 9b7a9e5
Merge branch 'master' into issue-6782
jameslamb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -454,3 +454,32 @@ def test_arrow_feature_name_manual(): | |
) | ||
booster = lgb.train({"num_leaves": 7}, dataset, num_boost_round=5) | ||
assert booster.feature_name() == ["c", "d"] | ||
|
||
|
||
def test_dataset_construction_from_pa_table_without_cffi_raises_informative_error(missing_module_cffi): | ||
with pytest.raises( | ||
lgb.basic.LightGBMError, match="Cannot init Dataset from Arrow without 'pyarrow' and 'cffi' installed." | ||
): | ||
lgb.Dataset( | ||
generate_dummy_arrow_table(), | ||
label=pa.array([0, 1, 0, 0, 1]), | ||
params=dummy_dataset_params(), | ||
).construct() | ||
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.
|
||
|
||
|
||
def test_predicting_from_pa_table_without_cffi_raises_informative_error(missing_module_cffi): | ||
data = generate_random_arrow_table(num_columns=3, num_datapoints=1_000, seed=42) | ||
labels = generate_random_arrow_array(num_datapoints=data.shape[0], seed=42) | ||
bst = lgb.train( | ||
params={"num_leaves": 7, "verbose": -1}, | ||
train_set=lgb.Dataset( | ||
data.to_pandas(), | ||
label=labels.to_pandas(), | ||
), | ||
num_boost_round=2, | ||
) | ||
|
||
with pytest.raises( | ||
lgb.basic.LightGBMError, match="Cannot predict from Arrow without 'pyarrow' and 'cffi' installed." | ||
): | ||
bst.predict(data) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need
class members?
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.
CData
is needed for type hinting:LightGBM/python-package/lightgbm/basic.py
Line 416 in 9f1af05
But I think the others could be safely removed. It's only showing up in the diff in this PR because this code is being moved around... so this was missed in earlier PRs (I guess #6034).
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.
Removed all but
CData
in 7396613There 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.
Guess that was my editor complaining when I originally added this... no good reason to keep it around though, thanks for removing :)