Skip to content

Commit

Permalink
Specify src path for isort.
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis committed Mar 3, 2023
1 parent c6db15f commit 0d48e35
Show file tree
Hide file tree
Showing 39 changed files with 62 additions and 51 deletions.
2 changes: 1 addition & 1 deletion demo/dask/cpu_survival.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import dask.dataframe as dd
from dask.distributed import Client, LocalCluster
from xgboost.dask import DaskDMatrix

import xgboost as xgb
from xgboost.dask import DaskDMatrix


def main(client):
Expand Down
2 changes: 1 addition & 1 deletion demo/dask/cpu_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"""
from dask import array as da
from dask.distributed import Client, LocalCluster
from xgboost.dask import DaskDMatrix

import xgboost as xgb
from xgboost.dask import DaskDMatrix


def main(client):
Expand Down
2 changes: 1 addition & 1 deletion demo/dask/dask_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from dask.distributed import Client, LocalCluster
from dask_ml.datasets import make_regression
from dask_ml.model_selection import train_test_split
from xgboost.dask import DaskDMatrix

import xgboost as xgb
from xgboost.dask import DaskDMatrix


def probability_for_going_backward(epoch):
Expand Down
2 changes: 1 addition & 1 deletion demo/dask/gpu_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from dask import dataframe as dd
from dask.distributed import Client
from dask_cuda import LocalCUDACluster
from xgboost.dask import DaskDMatrix

import xgboost as xgb
from xgboost import dask as dxgb
from xgboost.dask import DaskDMatrix


def using_dask_matrix(client: Client, X, y):
Expand Down
1 change: 1 addition & 0 deletions demo/guide-python/spark_estimator_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pyspark.sql import SparkSession
from pyspark.sql.functions import rand
from sklearn.model_selection import train_test_split

from xgboost.spark import SparkXGBClassifier, SparkXGBRegressor

spark = SparkSession.builder.master("local[*]").getOrCreate()
Expand Down
3 changes: 2 additions & 1 deletion demo/nvflare/custom/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
"""
import multiprocessing

import xgboost.federated
from nvflare.apis.client import Client
from nvflare.apis.fl_context import FLContext
from nvflare.apis.impl.controller import Controller, Task
from nvflare.apis.shareable import Shareable
from nvflare.apis.signal import Signal
from trainer import SupportedTasks

import xgboost.federated


class XGBoostController(Controller):
def __init__(self, port: int, world_size: int, server_key_path: str,
Expand Down
6 changes: 3 additions & 3 deletions python-package/xgboost/spark/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
ShortType,
)
from scipy.special import expit, softmax # pylint: disable=no-name-in-module
from xgboost.compat import is_cudf_available
from xgboost.core import Booster
from xgboost.training import train as worker_train

import xgboost
from xgboost import XGBClassifier, XGBRanker, XGBRegressor
from xgboost.compat import is_cudf_available
from xgboost.core import Booster
from xgboost.training import train as worker_train

from .data import (
_read_csr_matrix_from_unwrapped_spark_vec,
Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/spark/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import numpy as np
import pandas as pd
from scipy.sparse import csr_matrix
from xgboost.compat import concat

from xgboost import DataIter, DMatrix, QuantileDMatrix, XGBModel
from xgboost.compat import concat

from .._typing import ArrayLike
from ..core import _convert_ntree_limit
Expand Down
1 change: 1 addition & 0 deletions python-package/xgboost/spark/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pyspark import SparkFiles, cloudpickle
from pyspark.ml.util import DefaultParamsReader, DefaultParamsWriter, MLReader, MLWriter
from pyspark.sql import SparkSession

from xgboost.core import Booster

from .utils import get_class_name, get_logger
Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/spark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import pyspark
from pyspark import BarrierTaskContext, SparkContext
from pyspark.sql.session import SparkSession
from xgboost.tracker import RabitTracker

from xgboost import collective
from xgboost.tracker import RabitTracker


def get_class_name(cls: Type) -> str:
Expand Down
4 changes: 2 additions & 2 deletions python-package/xgboost/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
import numpy as np
import pytest
from scipy import sparse
from xgboost.core import ArrayLike
from xgboost.sklearn import SklObjective

import xgboost as xgb
from xgboost.core import ArrayLike
from xgboost.sklearn import SklObjective

hypothesis = pytest.importorskip("hypothesis")

Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/testing/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import numpy as np
from dask import array as da
from distributed import Client
from xgboost.testing.updater import get_basescore

import xgboost as xgb
from xgboost.testing.updater import get_basescore


def check_init_estimation_clf(tree_method: str, client: Client) -> None:
Expand Down
1 change: 1 addition & 0 deletions python-package/xgboost/testing/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any, Generator, Tuple, Union

import numpy as np

from xgboost.data import pandas_pyarrow_mapper


Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/testing/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from typing import Any, Callable, Dict, Type

import numpy as np
from xgboost._typing import ArrayLike

import xgboost as xgb
from xgboost._typing import ArrayLike


def validate_leaf_output(leaf: np.ndarray, num_parallel_tree: int) -> None:
Expand Down
3 changes: 2 additions & 1 deletion python-package/xgboost/testing/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from typing import Dict

import numpy as np
import xgboost.testing as tm

import xgboost as xgb
import xgboost.testing as tm


def get_basescore(model: xgb.XGBModel) -> float:
Expand Down Expand Up @@ -78,6 +78,7 @@ def check_quantile_loss(tree_method: str, weighted: bool) -> None:
"""Test for quantile loss."""
from sklearn.datasets import make_regression
from sklearn.metrics import mean_pinball_loss

from xgboost.sklearn import _metric_decorator

n_samples = 4096
Expand Down
7 changes: 5 additions & 2 deletions tests/ci_build/lint_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
import subprocess
import sys
from multiprocessing import Pool, cpu_count
from typing import Dict, Tuple
from typing import Dict, Optional, Tuple

from pylint import epylint
from test_utils import PY_PACKAGE, ROOT, cd, print_time, record_time

CURDIR = os.path.normpath(os.path.abspath(os.path.dirname(__file__)))
SRCPATH = os.path.normpath(
os.path.join(CURDIR, os.path.pardir, os.path.pardir, "python-package")
)


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

@record_time
def run_isort(rel_path: str) -> bool:
cmd = ["isort", "--check", "--profile=black", rel_path]
cmd = ["isort", f"--src={SRCPATH}", "--profile=black", rel_path]
ret = subprocess.run(cmd).returncode
if ret != 0:
subprocess.run(["isort", "--version"])
Expand Down
1 change: 1 addition & 0 deletions tests/python-gpu/test_gpu_data_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from hypothesis import given, settings, strategies

from xgboost.testing import no_cupy

sys.path.append("tests/python")
Expand Down
2 changes: 1 addition & 1 deletion tests/python-gpu/test_gpu_eval_metrics.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sys

import pytest
from xgboost.testing.metrics import check_quantile_error

import xgboost
from xgboost import testing as tm
from xgboost.testing.metrics import check_quantile_error

sys.path.append("tests/python")
import test_eval_metrics as test_em # noqa
Expand Down
2 changes: 1 addition & 1 deletion tests/python-gpu/test_gpu_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import numpy as np
import pytest
from hypothesis import assume, given, settings, strategies
from xgboost.compat import PANDAS_INSTALLED

import xgboost as xgb
from xgboost import testing as tm
from xgboost.compat import PANDAS_INSTALLED

if PANDAS_INSTALLED:
from hypothesis.extra.pandas import column, data_frames, range_indexes
Expand Down
4 changes: 2 additions & 2 deletions tests/python-gpu/test_gpu_updaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import numpy as np
import pytest
from hypothesis import assume, given, note, settings, strategies
from xgboost.testing.params import cat_parameter_strategy, hist_parameter_strategy
from xgboost.testing.updater import check_init_estimation, check_quantile_loss

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.params import cat_parameter_strategy, hist_parameter_strategy
from xgboost.testing.updater import check_init_estimation, check_quantile_loss

sys.path.append("tests/python")
import test_updaters as test_up
Expand Down
2 changes: 1 addition & 1 deletion tests/python-gpu/test_gpu_with_sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import numpy as np
import pytest
from xgboost.testing.ranking import run_ranking_qid_df

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.ranking import run_ranking_qid_df

sys.path.append("tests/python")
import test_with_sklearn as twskl # noqa
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_data_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import pytest
from hypothesis import given, settings, strategies
from scipy.sparse import csr_matrix
from xgboost.data import SingleBatchInternalIter as SingleBatch
from xgboost.testing import IteratorForTest, make_batches, non_increasing

import xgboost as xgb
from xgboost import testing as tm
from xgboost.data import SingleBatchInternalIter as SingleBatch
from xgboost.testing import IteratorForTest, make_batches, non_increasing

pytestmark = tm.timeout(30)

Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_dmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import scipy.sparse
from hypothesis import given, settings, strategies
from scipy.sparse import csr_matrix, rand
from xgboost.testing.data import np_dtypes

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.data import np_dtypes

rng = np.random.RandomState(1)

Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_early_stopping.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import pytest
from xgboost.testing.updater import get_basescore

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.updater import get_basescore

rng = np.random.RandomState(1994)

Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_eval_metrics.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import pytest
from xgboost.testing.metrics import check_quantile_error

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.metrics import check_quantile_error

rng = np.random.RandomState(1337)

Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import pandas as pd
import pytest
from scipy import sparse
from xgboost.testing.data import np_dtypes, pd_dtypes
from xgboost.testing.shared import validate_leaf_output

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.data import np_dtypes, pd_dtypes
from xgboost.testing.shared import validate_leaf_output


def run_threaded_predict(X, rows, predict_func):
Expand Down
4 changes: 2 additions & 2 deletions tests/python/test_quantile_dmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import pytest
from hypothesis import given, settings, strategies
from scipy import sparse

import xgboost as xgb
from xgboost.testing import (
IteratorForTest,
make_batches,
Expand All @@ -15,8 +17,6 @@
)
from xgboost.testing.data import np_dtypes

import xgboost as xgb


class TestQuantileDMatrix:
def test_basic(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_ranking.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import pytest
from hypothesis import given, note, settings
from scipy.sparse import csr_matrix
from xgboost.testing.params import lambdarank_parameter_strategy

import xgboost
from xgboost import testing as tm
from xgboost.testing.params import lambdarank_parameter_strategy


def test_ranking_with_unweighted_data():
Expand Down
6 changes: 3 additions & 3 deletions tests/python/test_updaters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
import numpy as np
import pytest
from hypothesis import given, note, settings, strategies

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.params import (
cat_parameter_strategy,
exact_parameter_strategy,
hist_parameter_strategy,
)
from xgboost.testing.updater import check_init_estimation, check_quantile_loss

import xgboost as xgb
from xgboost import testing as tm


def train_result(param, dmat, num_rounds):
result = {}
Expand Down
2 changes: 1 addition & 1 deletion tests/python/test_with_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import numpy as np
import pytest
from test_dmatrix import set_base_margin_info
from xgboost.testing.data import pd_arrow_dtypes, pd_dtypes

import xgboost as xgb
from xgboost import testing as tm
from xgboost.testing.data import pd_arrow_dtypes, pd_dtypes

try:
import pandas as pd
Expand Down
Loading

0 comments on commit 0d48e35

Please sign in to comment.