Skip to content

Commit 2176e51

Browse files
authored
Disable pytest-timeout for now. (dmlc#8348)
1 parent fcddbc9 commit 2176e51

13 files changed

+102
-53
lines changed

python-package/xgboost/testing.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import socket
44
from platform import system
5-
from typing import TypedDict
5+
from typing import Any, TypedDict
66

77
PytestSkip = TypedDict("PytestSkip", {"condition": bool, "reason": str})
88

@@ -39,3 +39,26 @@ def has_ipv6() -> bool:
3939
def skip_ipv6() -> PytestSkip:
4040
"""PyTest skip mark for IPv6."""
4141
return {"condition": not has_ipv6(), "reason": "IPv6 is required to be enabled."}
42+
43+
44+
def timeout(sec: int, *args: Any, enable: bool = False, **kwargs: Any) -> Any:
45+
"""Make a pytest mark for the `pytest-timeout` package.
46+
47+
Parameters
48+
----------
49+
sec :
50+
Timeout seconds.
51+
enable :
52+
Control whether timeout should be applied, used for debugging.
53+
54+
Returns
55+
-------
56+
pytest.mark.timeout
57+
"""
58+
import pytest # pylint: disable=import-error
59+
60+
# This is disabled for now due to regression caused by conflicts between federated
61+
# learning build and the CI container environment.
62+
if enable:
63+
return pytest.mark.timeout(sec, *args, **kwargs)
64+
return pytest.mark.timeout(None, *args, **kwargs)

tests/python-gpu/test_gpu_linear.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import sys
2-
from hypothesis import strategies, given, settings, assume, note
2+
33
import pytest
4+
from hypothesis import assume, given, note, settings, strategies
5+
46
import xgboost as xgb
7+
from xgboost import testing
8+
59
sys.path.append("tests/python")
610
import testing as tm
711

8-
9-
pytestmark = pytest.mark.timeout(10)
12+
pytestmark = testing.timeout(10)
1013

1114
parameter_strategy = strategies.fixed_dictionaries({
1215
'booster': strategies.just('gblinear'),

tests/python-gpu/test_gpu_pickling.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
'''Test model IO with pickle.'''
2+
import json
3+
import os
24
import pickle
3-
import numpy as np
45
import subprocess
5-
import os
66
import sys
7-
import json
7+
8+
import numpy as np
89
import pytest
10+
911
import xgboost as xgb
10-
from xgboost import XGBClassifier
12+
from xgboost import XGBClassifier, testing
1113

1214
sys.path.append("tests/python")
1315
import testing as tm
1416

1517
model_path = './model.pkl'
1618

19+
pytestmark = testing.timeout(30)
1720

18-
pytestmark = pytest.mark.timeout(30)
1921

2022
def build_dataset():
2123
N = 10

tests/python-gpu/test_gpu_prediction.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import sys
2-
import pytest
32

43
import numpy as np
5-
import xgboost as xgb
4+
import pytest
5+
from hypothesis import assume, given, settings, strategies
66
from xgboost.compat import PANDAS_INSTALLED
77

8-
from hypothesis import given, strategies, assume, settings
8+
import xgboost as xgb
9+
from xgboost import testing
910

1011
if PANDAS_INSTALLED:
1112
from hypothesis.extra.pandas import column, data_frames, range_indexes
@@ -16,8 +17,8 @@ def noop(*args, **kwargs):
1617

1718
sys.path.append("tests/python")
1819
import testing as tm
20+
from test_predict import run_predict_leaf # noqa
1921
from test_predict import run_threaded_predict # noqa
20-
from test_predict import run_predict_leaf # noqa
2122

2223
rng = np.random.RandomState(1994)
2324

@@ -32,7 +33,8 @@ def noop(*args, **kwargs):
3233
'num_parallel_tree': strategies.sampled_from([1, 4]),
3334
})
3435

35-
pytestmark = pytest.mark.timeout(20)
36+
pytestmark = testing.timeout(20)
37+
3638

3739
class TestGPUPredict:
3840
def test_predict(self):

tests/python-gpu/test_gpu_ranking.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import numpy as np
2-
import xgboost
3-
import os
41
import itertools
2+
import os
53
import shutil
4+
import sys
65
import urllib.request
76
import zipfile
8-
import sys
9-
import pytest
7+
8+
import numpy as np
9+
10+
import xgboost
11+
from xgboost import testing
12+
1013
sys.path.append("tests/python")
1114

12-
import testing as tm # noqa
15+
import testing as tm # noqa
16+
17+
pytestmark = testing.timeout(10)
1318

14-
pytestmark = pytest.mark.timeout(10)
1519

1620
class TestRanking:
1721
@classmethod

tests/python-gpu/test_gpu_updaters.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
from typing import Dict, Any
2-
import numpy as np
31
import sys
2+
from typing import Any, Dict
3+
4+
import numpy as np
45
import pytest
6+
from hypothesis import assume, given, note, settings, strategies
7+
58
import xgboost as xgb
6-
from hypothesis import given, strategies, assume, settings, note
9+
from xgboost import testing
710

811
sys.path.append("tests/python")
9-
import testing as tm
1012
import test_updaters as test_up
13+
import testing as tm
1114

12-
pytestmark = pytest.mark.timeout(30)
15+
pytestmark = testing.timeout(30)
1316

1417
parameter_strategy = strategies.fixed_dictionaries({
1518
'max_depth': strategies.integers(0, 11),

tests/python/test_data_iterator.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import xgboost as xgb
2-
from xgboost.data import SingleBatchInternalIter as SingleBatch
31
import numpy as np
4-
from testing import IteratorForTest, non_increasing, make_batches
52
import pytest
6-
from hypothesis import given, strategies, settings
3+
from hypothesis import given, settings, strategies
74
from scipy.sparse import csr_matrix
5+
from testing import IteratorForTest, make_batches, non_increasing
6+
from xgboost.data import SingleBatchInternalIter as SingleBatch
7+
8+
import xgboost as xgb
9+
from xgboost import testing
10+
11+
pytestmark = testing.timeout(30)
812

9-
pytestmark = pytest.mark.timeout(30)
1013

1114
def test_single_batch(tree_method: str = "approx") -> None:
1215
from sklearn.datasets import load_breast_cancer

tests/python/test_demos.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import os
22
import subprocess
3+
import sys
4+
35
import pytest
46
import testing as tm
5-
import sys
67

7-
pytestmark = pytest.mark.timeout(30)
8+
from xgboost import testing
9+
10+
pytestmark = testing.timeout(30)
811

912
ROOT_DIR = tm.PROJECT_ROOT
1013
DEMO_DIR = os.path.join(ROOT_DIR, 'demo')

tests/python/test_linear.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import testing as tm
2-
import pytest
3-
from hypothesis import strategies, given, settings, note
2+
from hypothesis import given, note, settings, strategies
3+
44
import xgboost as xgb
5+
from xgboost import testing
6+
7+
pytestmark = testing.timeout(10)
58

6-
pytestmark = pytest.mark.timeout(10)
79

810
parameter_strategy = strategies.fixed_dictionaries({
911
'booster': strategies.just('gblinear'),

tests/python/test_openmp.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import os
2-
import tempfile
32
import subprocess
3+
import tempfile
44

5-
import xgboost as xgb
65
import numpy as np
76
import pytest
8-
97
import testing as tm
108

11-
pytestmark = pytest.mark.timeout(10)
9+
import xgboost as xgb
10+
from xgboost import testing
11+
12+
pytestmark = testing.timeout(10)
13+
1214

1315
class TestOMP:
1416
def test_omp(self):

0 commit comments

Comments
 (0)