Skip to content

Commit 0f8c3f4

Browse files
TEST-#7598: Allow xgboost to log to root. (#7599)
Our tests use older versions of xgboost that [log to the root logger](https://github.com/dmlc/xgboost/blob/36eb41c960483c8b52b44082663c99e6a0de440a/python-package/xgboost/tracker.py#L382). Resolves #7598 This PR won't trigger the xgboost tests on github actions, so I checked that `pytest modin/tests/experimental/xgboost/ -n 12` passed locally. Signed-off-by: sfc-gh-mvashishtha <mahesh.vashishtha@snowflake.com>
1 parent 8276d01 commit 0f8c3f4

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

modin/conftest.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,12 @@ def clean_up_auto_backend_switching():
797797

798798
@pytest.fixture(autouse=True)
799799
def assert_no_root_logging(caplog):
800+
try:
801+
import xgboost
802+
except ImportError:
803+
xgboost_path = None
804+
else:
805+
xgboost_path = os.path.dirname(xgboost.__file__)
800806
root_logger = logging.getLogger()
801807
# Capture logs at any level, i.e. at level >= logging.NOTSET.
802808
with caplog.at_level(logging.NOTSET):
@@ -805,5 +811,11 @@ def assert_no_root_logging(caplog):
805811
# caplog.get_records(when="call") instead of caplog.records:
806812
# https://github.com/pytest-dev/pytest/issues/4033
807813
assert not any(
808-
record.name == root_logger.name for record in caplog.get_records(when="call")
814+
record.name == root_logger.name
815+
# Allow xgboost to log to root.
816+
# TODO(https://github.com/modin-project/modin/issues/5194): Check
817+
# whether we can remove this exception once we use a newer version of
818+
# xgboost.
819+
and not (xgboost_path is not None and record.pathname.startswith(xgboost_path))
820+
for record in caplog.get_records(when="call")
809821
)

0 commit comments

Comments
 (0)