Skip to content

Commit a9dab3a

Browse files
[CI] Convert isort config to ruff config (#52869)
Convert isort config in .isort.cfg to ruff config in pyproject.toml. Conversion strategy: known_local_folder -> known-local-folder known_third_party -> known-third-party known_afterray -> Created a new section afterray sections -> section_order skip_glob -> If already exists in tool.ruff.extend-exclude then do nothing. Otherwise add a rule to per-file-ignores to ignore the I rule. Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com> Co-authored-by: Lonnie Liu <95255098+aslonnie@users.noreply.github.com>
1 parent 2c1b283 commit a9dab3a

File tree

15 files changed

+47
-52
lines changed

15 files changed

+47
-52
lines changed

.isort.cfg

Lines changed: 0 additions & 27 deletions
This file was deleted.

pyproject.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,36 @@ avoid-escape = false
4545

4646
[tool.ruff.lint.isort]
4747
combine-as-imports = true
48+
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder", "afterray"]
49+
known-local-folder = ["ray"]
50+
known-third-party = ["grpc"]
51+
52+
[tool.ruff.lint.isort.sections]
53+
afterray = ["psutil", "setproctitle"]
54+
55+
# Some of the directories need to be kept in the blacklist for isort ("I" rule):
56+
# python/ray/cloudpickle/*
57+
# doc/*
58+
# python/ray/__init__.py
59+
# python/ray/setup-dev.py
60+
# For the rest we will gradually remove them from the blacklist as we
61+
# reformat the code to follow the style guide.
62+
[tool.ruff.lint.per-file-ignores]
63+
"doc/*" = ["I"]
64+
"python/ray/__init__.py" = ["I"]
65+
"python/ray/setup-dev.py" = ["I"]
66+
"python/ray/cloudpickle/*" = ["I"]
67+
"python/ray/dag/*.py" = ["I"]
68+
"ci/*" = ["I"]
69+
"python/ray/includes/*" = ["I"]
70+
"python/ray/internal/*" = ["I"]
71+
"python/ray/ray_operator/*" = ["I"]
72+
"python/ray/scripts/*" = ["I"]
73+
"python/ray/serve/generated/serve_pb2.py" = ["I"]
74+
"python/ray/streaming/*" = ["I"]
75+
"python/ray/tests/*" = ["I"]
76+
"python/ray/util/*" = ["I"]
77+
"python/ray/workers/*" = ["I"]
78+
"python/ray/workflow/*" = ["I"]
79+
"rllib/*" = ["I"]
80+
"release/*" = ["I"]

python/ray/data/_internal/datasource/tfrecords_datasink.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
import numpy as np
55

6+
from .tfrecords_datasource import _get_single_true_type
67
from ray.data._internal.util import _check_import
78
from ray.data.block import BlockAccessor
89
from ray.data.datasource.file_datasink import BlockBasedFileDatasink
910

10-
from .tfrecords_datasource import _get_single_true_type
11-
1211
if TYPE_CHECKING:
1312
import pyarrow
1413
import tensorflow as tf

python/ray/data/_internal/execution/autoscaler/default_autoscaler.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
from typing import TYPE_CHECKING, Dict, Optional, Tuple
55

66
import ray
7+
from .autoscaler import Autoscaler
8+
from .autoscaling_actor_pool import AutoscalingActorPool
79
from ray.data._internal.execution.autoscaling_requester import (
810
get_or_create_autoscaling_requester_actor,
911
)
1012
from ray.data._internal.execution.interfaces.execution_options import ExecutionResources
1113

12-
from .autoscaler import Autoscaler
13-
from .autoscaling_actor_pool import AutoscalingActorPool
14-
1514
if TYPE_CHECKING:
1615
from ray.data._internal.execution.interfaces import PhysicalOperator
1716
from ray.data._internal.execution.resource_manager import ResourceManager

python/ray/data/_internal/execution/backpressure_policy/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from typing import TYPE_CHECKING
22

33
import ray
4-
54
from .backpressure_policy import BackpressurePolicy
65
from .concurrency_cap_backpressure_policy import ConcurrencyCapBackpressurePolicy
76

python/ray/data/_internal/execution/backpressure_policy/concurrency_cap_backpressure_policy.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import logging
22
from typing import TYPE_CHECKING
33

4+
from .backpressure_policy import BackpressurePolicy
45
from ray.data._internal.execution.operators.task_pool_map_operator import (
56
TaskPoolMapOperator,
67
)
78

8-
from .backpressure_policy import BackpressurePolicy
9-
109
if TYPE_CHECKING:
1110
from ray.data._internal.execution.interfaces.physical_operator import (
1211
PhysicalOperator,

python/ray/data/_internal/execution/interfaces/execution_options.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import os
22
from typing import Dict, List, Optional, Union
33

4+
from .common import NodeIdStr
45
from ray.data._internal.execution.util import memory_string
56
from ray.util.annotations import DeveloperAPI
67

7-
from .common import NodeIdStr
8-
98

109
class ExecutionResources:
1110
"""Specifies resources usage or resource limits for execution.

python/ray/data/_internal/execution/interfaces/executor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from abc import ABC, abstractmethod
22
from typing import ContextManager, Iterator, Optional
33

4-
from ray.data._internal.stats import DatasetStats
5-
64
from .execution_options import ExecutionOptions
75
from .physical_operator import PhysicalOperator
86
from .ref_bundle import RefBundle
7+
from ray.data._internal.stats import DatasetStats
98

109

1110
class OutputIterator(Iterator[RefBundle], ABC):

python/ray/data/_internal/execution/interfaces/physical_operator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, Union
66

77
import ray
8+
from .ref_bundle import RefBundle
89
from ray._raylet import ObjectRefGenerator
910
from ray.data._internal.execution.autoscaler.autoscaling_actor_pool import (
1011
AutoscalingActorPool,
@@ -19,8 +20,6 @@
1920
from ray.data._internal.stats import StatsDict, Timer
2021
from ray.data.context import DataContext
2122

22-
from .ref_bundle import RefBundle
23-
2423
logger = logging.getLogger(__name__)
2524

2625

python/ray/data/_internal/execution/interfaces/ref_bundle.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
from typing import Dict, Iterator, List, Optional, Tuple
44

55
import ray
6+
from .common import NodeIdStr
67
from ray.data._internal.memory_tracing import trace_deallocation
78
from ray.data.block import Block, BlockMetadata
89
from ray.data.context import DataContext
910
from ray.types import ObjectRef
1011

11-
from .common import NodeIdStr
12-
1312

1413
@dataclass
1514
class RefBundle:

python/ray/data/_internal/execution/interfaces/transform_fn.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
from typing import Callable, List, Tuple
22

3-
from ray.data._internal.stats import StatsDict
4-
53
from .ref_bundle import RefBundle
64
from .task_context import TaskContext
5+
from ray.data._internal.stats import StatsDict
76

87
# Block transform function applied in AllToAllOperator.
98
AllToAllTransformFn = Callable[

python/ray/data/_internal/logical/interfaces/logical_operator.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from typing import TYPE_CHECKING, Callable, Iterator, List, Optional
22

3-
from ray.data.block import BlockMetadata
4-
53
from .operator import Operator
4+
from ray.data.block import BlockMetadata
65

76
if TYPE_CHECKING:
87
from ray.data._internal.execution.interfaces import RefBundle

python/ray/data/_internal/logical/optimizers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List
22

3+
from .ruleset import Ruleset
34
from ray.data._internal.logical.interfaces import (
45
LogicalPlan,
56
Optimizer,
@@ -21,8 +22,6 @@
2122
)
2223
from ray.util.annotations import DeveloperAPI
2324

24-
from .ruleset import Ruleset
25-
2625
_LOGICAL_RULESET = Ruleset(
2726
[
2827
ReorderRandomizeBlocksRule,

python/ray/data/_internal/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@
2626
)
2727

2828
import numpy as np
29-
import psutil
3029
import pyarrow
3130
from packaging.version import parse as parse_version
3231

3332
import ray
3433
from ray._private.arrow_utils import get_pyarrow_version
3534
from ray.data.context import DEFAULT_READ_OP_MIN_NUM_BLOCKS, WARN_PREFIX, DataContext
3635

36+
import psutil
37+
3738
if TYPE_CHECKING:
3839
import pandas
3940

python/ray/train/v2/_internal/execution/worker_group/worker.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import ray
1010
import ray._private.ray_constants as ray_constants
11+
from .thread_runner import ThreadRunner
1112
from ray.actor import ActorHandle
1213
from ray.data.iterator import DataIterator
1314
from ray.train import Checkpoint
@@ -35,8 +36,6 @@
3536
from ray.train.v2._internal.util import ObjectRefWrapper
3637
from ray.types import ObjectRef
3738

38-
from .thread_runner import ThreadRunner
39-
4039
T = TypeVar("T")
4140

4241
logger = logging.getLogger(__name__)

0 commit comments

Comments
 (0)