Lazy import cuDF and Dask (#6522)
* Lazy import cuDF * Lazy import Dask Co-authored-by: PSEUDOTENSOR / Jonathan McKinney <pseudotensor@gmail.com> * Fix lint Co-authored-by: PSEUDOTENSOR / Jonathan McKinney <pseudotensor@gmail.com>
This commit is contained in:
parent
ad1a527709
commit
125b3c0f2d
@ -41,12 +41,6 @@ except ImportError:
|
||||
pandas_concat = None
|
||||
PANDAS_INSTALLED = False
|
||||
|
||||
# cudf
|
||||
try:
|
||||
from cudf import concat as CUDF_concat
|
||||
except ImportError:
|
||||
CUDF_concat = None
|
||||
|
||||
# sklearn
|
||||
try:
|
||||
from sklearn.base import BaseEstimator
|
||||
@ -104,9 +98,10 @@ except ImportError:
|
||||
|
||||
# dask
|
||||
try:
|
||||
import dask
|
||||
import pkg_resources
|
||||
pkg_resources.get_distribution('dask')
|
||||
DASK_INSTALLED = True
|
||||
except ImportError:
|
||||
except pkg_resources.DistributionNotFound:
|
||||
dask = None
|
||||
DASK_INSTALLED = False
|
||||
|
||||
|
||||
@ -27,7 +27,6 @@ from . import rabit, config
|
||||
from .compat import LazyLoader
|
||||
from .compat import sparse, scipy_sparse
|
||||
from .compat import PANDAS_INSTALLED, DataFrame, Series, pandas_concat
|
||||
from .compat import CUDF_concat
|
||||
from .compat import lazy_isinstance
|
||||
|
||||
from .core import DMatrix, DeviceQuantileDMatrix, Booster, _expect, DataIter
|
||||
@ -121,6 +120,7 @@ def concat(value): # pylint: disable=too-many-return-statements
|
||||
return pandas_concat(value, axis=0)
|
||||
if lazy_isinstance(value[0], 'cudf.core.dataframe', 'DataFrame') or \
|
||||
lazy_isinstance(value[0], 'cudf.core.series', 'Series'):
|
||||
from cudf import concat as CUDF_concat # pylint: disable=import-error
|
||||
return CUDF_concat(value, axis=0)
|
||||
if lazy_isinstance(value[0], 'cupy.core.core', 'ndarray'):
|
||||
import cupy # pylint: disable=import-error
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user