|
14 | 14 | import numpy as np |
15 | 15 | import pandas as pd |
16 | 16 |
|
17 | | -import xgboost as xgb |
| 17 | +from xgboost_ray.xgb import xgboost as xgb |
18 | 18 | from xgboost.core import XGBoostError, EarlyStopException |
19 | 19 |
|
20 | 20 | from xgboost_ray.callback import DistributedCallback, \ |
|
76 | 76 | ELASTIC_RESTART_GRACE_PERIOD_S = int( |
77 | 77 | os.getenv("RXGB_ELASTIC_RESTART_GRACE_PERIOD_S", 10)) |
78 | 78 |
|
| 79 | +xgboost_version = xgb.__version__ if xgb else "0.0.0" |
| 80 | + |
79 | 81 | LEGACY_WARNING = ( |
80 | 82 | f"You are using `xgboost_ray` with a legacy XGBoost version " |
81 | | - f"(version {xgb.__version__}). While we try to support " |
| 83 | + f"(version {xgboost_version}). While we try to support " |
82 | 84 | f"older XGBoost versions, please note that this library is only " |
83 | 85 | f"fully tested and supported for XGBoost >= 1.4. Please consider " |
84 | 86 | f"upgrading your XGBoost version (`pip install -U xgboost`).") |
85 | 87 |
|
86 | 88 | # XGBoost version as an int tuple for comparisions |
87 | 89 | XGBOOST_VERSION_TUPLE = tuple( |
88 | | - int(x) for x in re.sub(r"[^\.0-9]", "", xgb.__version__).split(".")) |
| 90 | + int(x) for x in re.sub(r"[^\.0-9]", "", xgboost_version).split(".")) |
89 | 91 |
|
90 | 92 |
|
91 | 93 | class RayXGBoostTrainingError(RuntimeError): |
@@ -1144,6 +1146,11 @@ def train( |
1144 | 1146 | """ |
1145 | 1147 | os.environ.setdefault("RAY_IGNORE_UNHANDLED_ERRORS", "1") |
1146 | 1148 |
|
| 1149 | + if xgb is None: |
| 1150 | + raise ImportError( |
| 1151 | + "xgboost package is not installed. XGBoost-Ray WILL NOT WORK. " |
| 1152 | + "FIX THIS by running `pip install \"xgboost-ray[default]\"`.") |
| 1153 | + |
1147 | 1154 | if _remote is None: |
1148 | 1155 | _remote = _is_client_connected() and \ |
1149 | 1156 | not is_session_enabled() |
@@ -1528,6 +1535,11 @@ def predict(model: xgb.Booster, |
1528 | 1535 | """ |
1529 | 1536 | os.environ.setdefault("RAY_IGNORE_UNHANDLED_ERRORS", "1") |
1530 | 1537 |
|
| 1538 | + if xgb is None: |
| 1539 | + raise ImportError( |
| 1540 | + "xgboost package is not installed. XGBoost-Ray WILL NOT WORK. " |
| 1541 | + "FIX THIS by running `pip install \"xgboost-ray[default]\"`.") |
| 1542 | + |
1531 | 1543 | if _remote is None: |
1532 | 1544 | _remote = _is_client_connected() and \ |
1533 | 1545 | not is_session_enabled() |
|
0 commit comments