-
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
Changes from 3 commits
6b37b34
512550b
a85027b
5852ce6
acd5729
e72d5e2
a4a711d
8992344
56127f5
7396613
0526390
9b7a9e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -289,7 +289,6 @@ def __init__(self, *args: Any, **kwargs: Any): | |||
from pyarrow import ChunkedArray as pa_ChunkedArray | ||||
from pyarrow import Table as pa_Table | ||||
from pyarrow import chunked_array as pa_chunked_array | ||||
from pyarrow.cffi import ffi as arrow_cffi | ||||
from pyarrow.types import is_boolean as arrow_is_boolean | ||||
from pyarrow.types import is_floating as arrow_is_floating | ||||
from pyarrow.types import is_integer as arrow_is_integer | ||||
|
@@ -316,17 +315,6 @@ class pa_Table: # type: ignore | |||
def __init__(self, *args: Any, **kwargs: Any): | ||||
pass | ||||
|
||||
class arrow_cffi: # type: ignore | ||||
"""Dummy class for pyarrow.cffi.ffi.""" | ||||
|
||||
CData = None | ||||
addressof = None | ||||
cast = None | ||||
new = None | ||||
|
||||
def __init__(self, *args: Any, **kwargs: Any): | ||||
pass | ||||
|
||||
class pa_compute: # type: ignore | ||||
"""Dummy class for pyarrow.compute.""" | ||||
jameslamb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
|
@@ -338,6 +326,27 @@ class pa_compute: # type: ignore | |||
arrow_is_integer = None | ||||
arrow_is_floating = None | ||||
|
||||
|
||||
"""cffi""" | ||||
try: | ||||
from pyarrow.cffi import ffi as arrow_cffi | ||||
|
||||
CFFI_INSTALLED = True | ||||
except ImportError: | ||||
CFFI_INSTALLED = False | ||||
|
||||
class arrow_cffi: # type: ignore | ||||
"""Dummy class for pyarrow.cffi.ffi.""" | ||||
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. Why do we need
class members? 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.
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 commentThe reason will be displayed to describe this comment to others. Learn more. Removed all but 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. Guess that was my editor complaining when I originally added this... no good reason to keep it around though, thanks for removing :) |
||||
|
||||
CData = None | ||||
addressof = None | ||||
cast = None | ||||
new = None | ||||
|
||||
def __init__(self, *args: Any, **kwargs: Any): | ||||
pass | ||||
jameslamb marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
|
||||
"""cpu_count()""" | ||||
try: | ||||
from joblib import cpu_count | ||||
|
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.
This really should be
Dataset
, notdataframe
... I'll make that change when I push testing changes.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.
Fixed in e72d5e2.
In that commit, I also removed backticks from these log messages, in favor of single quotes. Special characters in log messages can occasionally be problematic.
I know these things were already there before this PR, but might as well fix them right here while we're touching these lines.