Skip to content

Commit 0d48e35

Browse files
committed
Specify src path for isort.
1 parent c6db15f commit 0d48e35

39 files changed

+62
-51
lines changed

Diff for: demo/dask/cpu_survival.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import dask.dataframe as dd
1010
from dask.distributed import Client, LocalCluster
11-
from xgboost.dask import DaskDMatrix
1211

1312
import xgboost as xgb
13+
from xgboost.dask import DaskDMatrix
1414

1515

1616
def main(client):

Diff for: demo/dask/cpu_training.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"""
66
from dask import array as da
77
from dask.distributed import Client, LocalCluster
8-
from xgboost.dask import DaskDMatrix
98

109
import xgboost as xgb
10+
from xgboost.dask import DaskDMatrix
1111

1212

1313
def main(client):

Diff for: demo/dask/dask_callbacks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from dask.distributed import Client, LocalCluster
77
from dask_ml.datasets import make_regression
88
from dask_ml.model_selection import train_test_split
9-
from xgboost.dask import DaskDMatrix
109

1110
import xgboost as xgb
11+
from xgboost.dask import DaskDMatrix
1212

1313

1414
def probability_for_going_backward(epoch):

Diff for: demo/dask/gpu_training.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
from dask import dataframe as dd
88
from dask.distributed import Client
99
from dask_cuda import LocalCUDACluster
10-
from xgboost.dask import DaskDMatrix
1110

1211
import xgboost as xgb
1312
from xgboost import dask as dxgb
13+
from xgboost.dask import DaskDMatrix
1414

1515

1616
def using_dask_matrix(client: Client, X, y):

Diff for: demo/guide-python/spark_estimator_examples.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pyspark.sql import SparkSession
1111
from pyspark.sql.functions import rand
1212
from sklearn.model_selection import train_test_split
13+
1314
from xgboost.spark import SparkXGBClassifier, SparkXGBRegressor
1415

1516
spark = SparkSession.builder.master("local[*]").getOrCreate()

Diff for: demo/nvflare/custom/controller.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"""
55
import multiprocessing
66

7-
import xgboost.federated
87
from nvflare.apis.client import Client
98
from nvflare.apis.fl_context import FLContext
109
from nvflare.apis.impl.controller import Controller, Task
1110
from nvflare.apis.shareable import Shareable
1211
from nvflare.apis.signal import Signal
1312
from trainer import SupportedTasks
1413

14+
import xgboost.federated
15+
1516

1617
class XGBoostController(Controller):
1718
def __init__(self, port: int, world_size: int, server_key_path: str,

Diff for: python-package/xgboost/spark/core.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
ShortType,
3535
)
3636
from scipy.special import expit, softmax # pylint: disable=no-name-in-module
37-
from xgboost.compat import is_cudf_available
38-
from xgboost.core import Booster
39-
from xgboost.training import train as worker_train
4037

4138
import xgboost
4239
from xgboost import XGBClassifier, XGBRanker, XGBRegressor
40+
from xgboost.compat import is_cudf_available
41+
from xgboost.core import Booster
42+
from xgboost.training import train as worker_train
4343

4444
from .data import (
4545
_read_csr_matrix_from_unwrapped_spark_vec,

Diff for: python-package/xgboost/spark/data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import numpy as np
77
import pandas as pd
88
from scipy.sparse import csr_matrix
9-
from xgboost.compat import concat
109

1110
from xgboost import DataIter, DMatrix, QuantileDMatrix, XGBModel
11+
from xgboost.compat import concat
1212

1313
from .._typing import ArrayLike
1414
from ..core import _convert_ntree_limit

Diff for: python-package/xgboost/spark/model.py

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pyspark import SparkFiles, cloudpickle
99
from pyspark.ml.util import DefaultParamsReader, DefaultParamsWriter, MLReader, MLWriter
1010
from pyspark.sql import SparkSession
11+
1112
from xgboost.core import Booster
1213

1314
from .utils import get_class_name, get_logger

Diff for: python-package/xgboost/spark/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import pyspark
99
from pyspark import BarrierTaskContext, SparkContext
1010
from pyspark.sql.session import SparkSession
11-
from xgboost.tracker import RabitTracker
1211

1312
from xgboost import collective
13+
from xgboost.tracker import RabitTracker
1414

1515

1616
def get_class_name(cls: Type) -> str:

Diff for: python-package/xgboost/testing/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
import numpy as np
3535
import pytest
3636
from scipy import sparse
37-
from xgboost.core import ArrayLike
38-
from xgboost.sklearn import SklObjective
3937

4038
import xgboost as xgb
39+
from xgboost.core import ArrayLike
40+
from xgboost.sklearn import SklObjective
4141

4242
hypothesis = pytest.importorskip("hypothesis")
4343

Diff for: python-package/xgboost/testing/dask.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
import numpy as np
33
from dask import array as da
44
from distributed import Client
5-
from xgboost.testing.updater import get_basescore
65

76
import xgboost as xgb
7+
from xgboost.testing.updater import get_basescore
88

99

1010
def check_init_estimation_clf(tree_method: str, client: Client) -> None:

Diff for: python-package/xgboost/testing/data.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from typing import Any, Generator, Tuple, Union
33

44
import numpy as np
5+
56
from xgboost.data import pandas_pyarrow_mapper
67

78

Diff for: python-package/xgboost/testing/shared.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from typing import Any, Callable, Dict, Type
99

1010
import numpy as np
11-
from xgboost._typing import ArrayLike
1211

1312
import xgboost as xgb
13+
from xgboost._typing import ArrayLike
1414

1515

1616
def validate_leaf_output(leaf: np.ndarray, num_parallel_tree: int) -> None:

Diff for: python-package/xgboost/testing/updater.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from typing import Dict
55

66
import numpy as np
7-
import xgboost.testing as tm
87

98
import xgboost as xgb
9+
import xgboost.testing as tm
1010

1111

1212
def get_basescore(model: xgb.XGBModel) -> float:
@@ -78,6 +78,7 @@ def check_quantile_loss(tree_method: str, weighted: bool) -> None:
7878
"""Test for quantile loss."""
7979
from sklearn.datasets import make_regression
8080
from sklearn.metrics import mean_pinball_loss
81+
8182
from xgboost.sklearn import _metric_decorator
8283

8384
n_samples = 4096

Diff for: tests/ci_build/lint_python.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import subprocess
44
import sys
55
from multiprocessing import Pool, cpu_count
6-
from typing import Dict, Tuple
6+
from typing import Dict, Optional, Tuple
77

88
from pylint import epylint
99
from test_utils import PY_PACKAGE, ROOT, cd, print_time, record_time
1010

1111
CURDIR = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
12+
SRCPATH = os.path.normpath(
13+
os.path.join(CURDIR, os.path.pardir, os.path.pardir, "python-package")
14+
)
1215

1316

1417
@record_time
@@ -29,7 +32,7 @@ def run_black(rel_path: str) -> bool:
2932

3033
@record_time
3134
def run_isort(rel_path: str) -> bool:
32-
cmd = ["isort", "--check", "--profile=black", rel_path]
35+
cmd = ["isort", f"--src={SRCPATH}", "--profile=black", rel_path]
3336
ret = subprocess.run(cmd).returncode
3437
if ret != 0:
3538
subprocess.run(["isort", "--version"])

Diff for: tests/python-gpu/test_gpu_data_iterator.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import pytest
44
from hypothesis import given, settings, strategies
5+
56
from xgboost.testing import no_cupy
67

78
sys.path.append("tests/python")

Diff for: tests/python-gpu/test_gpu_eval_metrics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import sys
22

33
import pytest
4-
from xgboost.testing.metrics import check_quantile_error
54

65
import xgboost
76
from xgboost import testing as tm
7+
from xgboost.testing.metrics import check_quantile_error
88

99
sys.path.append("tests/python")
1010
import test_eval_metrics as test_em # noqa

Diff for: tests/python-gpu/test_gpu_prediction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import numpy as np
44
import pytest
55
from hypothesis import assume, given, settings, strategies
6-
from xgboost.compat import PANDAS_INSTALLED
76

87
import xgboost as xgb
98
from xgboost import testing as tm
9+
from xgboost.compat import PANDAS_INSTALLED
1010

1111
if PANDAS_INSTALLED:
1212
from hypothesis.extra.pandas import column, data_frames, range_indexes

Diff for: tests/python-gpu/test_gpu_updaters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import numpy as np
55
import pytest
66
from hypothesis import assume, given, note, settings, strategies
7-
from xgboost.testing.params import cat_parameter_strategy, hist_parameter_strategy
8-
from xgboost.testing.updater import check_init_estimation, check_quantile_loss
97

108
import xgboost as xgb
119
from xgboost import testing as tm
10+
from xgboost.testing.params import cat_parameter_strategy, hist_parameter_strategy
11+
from xgboost.testing.updater import check_init_estimation, check_quantile_loss
1212

1313
sys.path.append("tests/python")
1414
import test_updaters as test_up

Diff for: tests/python-gpu/test_gpu_with_sklearn.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
import numpy as np
77
import pytest
8-
from xgboost.testing.ranking import run_ranking_qid_df
98

109
import xgboost as xgb
1110
from xgboost import testing as tm
11+
from xgboost.testing.ranking import run_ranking_qid_df
1212

1313
sys.path.append("tests/python")
1414
import test_with_sklearn as twskl # noqa

Diff for: tests/python/test_data_iterator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import pytest
55
from hypothesis import given, settings, strategies
66
from scipy.sparse import csr_matrix
7-
from xgboost.data import SingleBatchInternalIter as SingleBatch
8-
from xgboost.testing import IteratorForTest, make_batches, non_increasing
97

108
import xgboost as xgb
119
from xgboost import testing as tm
10+
from xgboost.data import SingleBatchInternalIter as SingleBatch
11+
from xgboost.testing import IteratorForTest, make_batches, non_increasing
1212

1313
pytestmark = tm.timeout(30)
1414

Diff for: tests/python/test_dmatrix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import scipy.sparse
77
from hypothesis import given, settings, strategies
88
from scipy.sparse import csr_matrix, rand
9-
from xgboost.testing.data import np_dtypes
109

1110
import xgboost as xgb
1211
from xgboost import testing as tm
12+
from xgboost.testing.data import np_dtypes
1313

1414
rng = np.random.RandomState(1)
1515

Diff for: tests/python/test_early_stopping.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import numpy as np
22
import pytest
3-
from xgboost.testing.updater import get_basescore
43

54
import xgboost as xgb
65
from xgboost import testing as tm
6+
from xgboost.testing.updater import get_basescore
77

88
rng = np.random.RandomState(1994)
99

Diff for: tests/python/test_eval_metrics.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import numpy as np
22
import pytest
3-
from xgboost.testing.metrics import check_quantile_error
43

54
import xgboost as xgb
65
from xgboost import testing as tm
6+
from xgboost.testing.metrics import check_quantile_error
77

88
rng = np.random.RandomState(1337)
99

Diff for: tests/python/test_predict.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
import pandas as pd
66
import pytest
77
from scipy import sparse
8-
from xgboost.testing.data import np_dtypes, pd_dtypes
9-
from xgboost.testing.shared import validate_leaf_output
108

119
import xgboost as xgb
1210
from xgboost import testing as tm
11+
from xgboost.testing.data import np_dtypes, pd_dtypes
12+
from xgboost.testing.shared import validate_leaf_output
1313

1414

1515
def run_threaded_predict(X, rows, predict_func):

Diff for: tests/python/test_quantile_dmatrix.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pytest
55
from hypothesis import given, settings, strategies
66
from scipy import sparse
7+
8+
import xgboost as xgb
79
from xgboost.testing import (
810
IteratorForTest,
911
make_batches,
@@ -15,8 +17,6 @@
1517
)
1618
from xgboost.testing.data import np_dtypes
1719

18-
import xgboost as xgb
19-
2020

2121
class TestQuantileDMatrix:
2222
def test_basic(self) -> None:

Diff for: tests/python/test_ranking.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import pytest
77
from hypothesis import given, note, settings
88
from scipy.sparse import csr_matrix
9-
from xgboost.testing.params import lambdarank_parameter_strategy
109

1110
import xgboost
1211
from xgboost import testing as tm
12+
from xgboost.testing.params import lambdarank_parameter_strategy
1313

1414

1515
def test_ranking_with_unweighted_data():

Diff for: tests/python/test_updaters.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
import numpy as np
66
import pytest
77
from hypothesis import given, note, settings, strategies
8+
9+
import xgboost as xgb
10+
from xgboost import testing as tm
811
from xgboost.testing.params import (
912
cat_parameter_strategy,
1013
exact_parameter_strategy,
1114
hist_parameter_strategy,
1215
)
1316
from xgboost.testing.updater import check_init_estimation, check_quantile_loss
1417

15-
import xgboost as xgb
16-
from xgboost import testing as tm
17-
1818

1919
def train_result(param, dmat, num_rounds):
2020
result = {}

Diff for: tests/python/test_with_pandas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
import numpy as np
44
import pytest
55
from test_dmatrix import set_base_margin_info
6-
from xgboost.testing.data import pd_arrow_dtypes, pd_dtypes
76

87
import xgboost as xgb
98
from xgboost import testing as tm
9+
from xgboost.testing.data import pd_arrow_dtypes, pd_dtypes
1010

1111
try:
1212
import pandas as pd

0 commit comments

Comments
 (0)