Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/issue_detector.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/issue_detector_configuration.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/issue_detector_manager.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__init__.py +19 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/hanging_detector.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/hash_shuffle_detector.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/high_memory_detector.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/hanging_detector.py +163 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/hash_shuffle_detector.py +110 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/high_memory_detector.py +101 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/iterator/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/iterator/__pycache__/iterator_impl.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/iterator/__pycache__/stream_split_iterator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/optimizers.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/ruleset.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/util.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__init__.py +18 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/logical_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/logical_plan.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/optimizer.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/physical_plan.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/plan.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/source_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/logical_operator.py +88 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/logical_plan.py +31 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/operator.py +95 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/optimizer.py +47 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/physical_plan.py +34 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/plan.py +25 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/source_operator.py +17 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__init__.py +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/__init__.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/all_to_all_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/count_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/from_operators.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/input_data_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/join_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/map_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/n_ary_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/one_to_one_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/read_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/streaming_split_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/write_operator.cpython-312.pyc +0 -0
- tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/all_to_all_operator.py +205 -0
.gitattributes
CHANGED
|
@@ -4443,3 +4443,5 @@ tool_server/.venv/lib/python3.12/site-packages/ray/core/src/ray/raylet/raylet fi
|
|
| 4443 |
tool_server/.venv/lib/python3.12/site-packages/ray/dag/__pycache__/compiled_dag_node.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4444 |
tool_server/.venv/lib/python3.12/site-packages/ray/data/__pycache__/dataset.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4445 |
tool_server/.venv/lib/python3.12/site-packages/ray/data/__pycache__/read_api.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 4443 |
tool_server/.venv/lib/python3.12/site-packages/ray/dag/__pycache__/compiled_dag_node.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4444 |
tool_server/.venv/lib/python3.12/site-packages/ray/data/__pycache__/dataset.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4445 |
tool_server/.venv/lib/python3.12/site-packages/ray/data/__pycache__/read_api.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4446 |
+
tool_server/.venv/lib/python3.12/site-packages/ray/rllib/algorithms/__pycache__/algorithm.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
| 4447 |
+
tool_server/.venv/lib/python3.12/site-packages/ray/rllib/algorithms/__pycache__/algorithm_config.cpython-312.pyc filter=lfs diff=lfs merge=lfs -text
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (756 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/issue_detector.cpython-312.pyc
ADDED
|
Binary file (1.95 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/issue_detector_configuration.cpython-312.pyc
ADDED
|
Binary file (1.36 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/__pycache__/issue_detector_manager.cpython-312.pyc
ADDED
|
Binary file (3.78 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__init__.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from ray.data._internal.issue_detection.detectors.hanging_detector import (
|
| 2 |
+
HangingExecutionIssueDetector,
|
| 3 |
+
HangingExecutionIssueDetectorConfig,
|
| 4 |
+
)
|
| 5 |
+
from ray.data._internal.issue_detection.detectors.hash_shuffle_detector import (
|
| 6 |
+
HashShuffleAggregatorIssueDetector,
|
| 7 |
+
)
|
| 8 |
+
from ray.data._internal.issue_detection.detectors.high_memory_detector import (
|
| 9 |
+
HighMemoryIssueDetector,
|
| 10 |
+
HighMemoryIssueDetectorConfig,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
__all__ = [
|
| 14 |
+
"HangingExecutionIssueDetector",
|
| 15 |
+
"HangingExecutionIssueDetectorConfig",
|
| 16 |
+
"HighMemoryIssueDetector",
|
| 17 |
+
"HighMemoryIssueDetectorConfig",
|
| 18 |
+
"HashShuffleAggregatorIssueDetector",
|
| 19 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (715 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/hanging_detector.cpython-312.pyc
ADDED
|
Binary file (8.12 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/hash_shuffle_detector.cpython-312.pyc
ADDED
|
Binary file (5.42 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/__pycache__/high_memory_detector.cpython-312.pyc
ADDED
|
Binary file (5.29 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/hanging_detector.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
from collections import defaultdict
|
| 3 |
+
from dataclasses import dataclass, field
|
| 4 |
+
from typing import TYPE_CHECKING, Dict, List, Set
|
| 5 |
+
|
| 6 |
+
from ray.data._internal.issue_detection.issue_detector import (
|
| 7 |
+
Issue,
|
| 8 |
+
IssueDetector,
|
| 9 |
+
IssueType,
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
if TYPE_CHECKING:
|
| 13 |
+
from ray.data._internal.execution.interfaces.op_runtime_metrics import (
|
| 14 |
+
TaskDurationStats,
|
| 15 |
+
)
|
| 16 |
+
from ray.data._internal.execution.streaming_executor import StreamingExecutor
|
| 17 |
+
from ray.data.context import DataContext
|
| 18 |
+
|
| 19 |
+
# Default minimum count of tasks before using adaptive thresholds
|
| 20 |
+
DEFAULT_OP_TASK_STATS_MIN_COUNT = 10
|
| 21 |
+
# Default multiple of standard deviations to use as hanging threshold
|
| 22 |
+
DEFAULT_OP_TASK_STATS_STD_FACTOR = 10
|
| 23 |
+
# Default detection time interval.
|
| 24 |
+
DEFAULT_DETECTION_TIME_INTERVAL_S = 30.0
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
@dataclass
|
| 28 |
+
class HangingExecutionState:
|
| 29 |
+
operator_id: str
|
| 30 |
+
task_idx: int
|
| 31 |
+
bytes_output: int
|
| 32 |
+
start_time_hanging: float
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
@dataclass
|
| 36 |
+
class HangingExecutionIssueDetectorConfig:
|
| 37 |
+
op_task_stats_min_count: int = field(default=DEFAULT_OP_TASK_STATS_MIN_COUNT)
|
| 38 |
+
op_task_stats_std_factor: float = field(default=DEFAULT_OP_TASK_STATS_STD_FACTOR)
|
| 39 |
+
detection_time_interval_s: float = DEFAULT_DETECTION_TIME_INTERVAL_S
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class HangingExecutionIssueDetector(IssueDetector):
|
| 43 |
+
def __init__(self, executor: "StreamingExecutor", ctx: "DataContext"):
|
| 44 |
+
super().__init__(executor, ctx)
|
| 45 |
+
self._detector_cfg: HangingExecutionIssueDetectorConfig = (
|
| 46 |
+
ctx.issue_detectors_config.hanging_detector_config
|
| 47 |
+
)
|
| 48 |
+
self._op_task_stats_min_count = self._detector_cfg.op_task_stats_min_count
|
| 49 |
+
self._op_task_stats_std_factor_threshold = (
|
| 50 |
+
self._detector_cfg.op_task_stats_std_factor
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# Map of operator id to dict of task_idx to hanging execution info (bytes read and
|
| 54 |
+
# start time for hanging time calculation)
|
| 55 |
+
self._state_map: Dict[str, Dict[int, HangingExecutionState]] = defaultdict(dict)
|
| 56 |
+
# Map of operator id to set of task_idx that are hanging
|
| 57 |
+
self._hanging_op_tasks: Dict[str, Set[int]] = defaultdict(set)
|
| 58 |
+
# Map of operator id to operator name
|
| 59 |
+
self._op_id_to_name: Dict[str, str] = {}
|
| 60 |
+
|
| 61 |
+
def _create_issues(
|
| 62 |
+
self,
|
| 63 |
+
hanging_op_tasks: List[HangingExecutionState],
|
| 64 |
+
op_task_stats_map: Dict[str, "TaskDurationStats"],
|
| 65 |
+
) -> List[Issue]:
|
| 66 |
+
issues = []
|
| 67 |
+
for state in hanging_op_tasks:
|
| 68 |
+
if state.task_idx not in self._hanging_op_tasks[state.operator_id]:
|
| 69 |
+
op_name = self._op_id_to_name.get(state.operator_id, state.operator_id)
|
| 70 |
+
duration = time.perf_counter() - state.start_time_hanging
|
| 71 |
+
avg_duration = op_task_stats_map[state.operator_id].mean()
|
| 72 |
+
message = (
|
| 73 |
+
f"A task of operator {op_name} with task index "
|
| 74 |
+
f"{state.task_idx} has been running for {duration:.2f}s, which is longer"
|
| 75 |
+
f" than the average task duration of this operator ({avg_duration:.2f}s)."
|
| 76 |
+
f" If this message persists, please check the stack trace of the "
|
| 77 |
+
"task for potential hanging issues."
|
| 78 |
+
)
|
| 79 |
+
issues.append(
|
| 80 |
+
Issue(
|
| 81 |
+
dataset_name=self._executor._dataset_id,
|
| 82 |
+
operator_id=state.operator_id,
|
| 83 |
+
issue_type=IssueType.HANGING,
|
| 84 |
+
message=message,
|
| 85 |
+
)
|
| 86 |
+
)
|
| 87 |
+
self._hanging_op_tasks[state.operator_id].add(state.task_idx)
|
| 88 |
+
|
| 89 |
+
return issues
|
| 90 |
+
|
| 91 |
+
def detect(self) -> List[Issue]:
|
| 92 |
+
op_task_stats_map: Dict[str, "TaskDurationStats"] = {}
|
| 93 |
+
for operator, op_state in self._executor._topology.items():
|
| 94 |
+
op_metrics = operator.metrics
|
| 95 |
+
op_task_stats_map[operator.id] = op_metrics._op_task_duration_stats
|
| 96 |
+
self._op_id_to_name[operator.id] = operator.name
|
| 97 |
+
if op_state._finished:
|
| 98 |
+
# Remove finished operators / tasks from the state map
|
| 99 |
+
if operator.id in self._state_map:
|
| 100 |
+
del self._state_map[operator.id]
|
| 101 |
+
if operator.id in self._hanging_op_tasks:
|
| 102 |
+
del self._hanging_op_tasks[operator.id]
|
| 103 |
+
else:
|
| 104 |
+
active_tasks_idx = set()
|
| 105 |
+
for task in operator.get_active_tasks():
|
| 106 |
+
task_info = op_metrics._running_tasks.get(task.task_index(), None)
|
| 107 |
+
if task_info is None:
|
| 108 |
+
# if the task is not in the running tasks map, it has finished
|
| 109 |
+
# remove it from the state map and hanging op tasks, if present
|
| 110 |
+
self._state_map[operator.id].pop(task.task_index(), None)
|
| 111 |
+
self._hanging_op_tasks[operator.id].discard(task.task_index())
|
| 112 |
+
continue
|
| 113 |
+
|
| 114 |
+
active_tasks_idx.add(task.task_index())
|
| 115 |
+
bytes_output = task_info.bytes_outputs
|
| 116 |
+
|
| 117 |
+
prev_state_value = self._state_map[operator.id].get(
|
| 118 |
+
task.task_index(), None
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
if (
|
| 122 |
+
prev_state_value is None
|
| 123 |
+
or bytes_output != prev_state_value.bytes_output
|
| 124 |
+
):
|
| 125 |
+
self._state_map[operator.id][
|
| 126 |
+
task.task_index()
|
| 127 |
+
] = HangingExecutionState(
|
| 128 |
+
operator_id=operator.id,
|
| 129 |
+
task_idx=task.task_index(),
|
| 130 |
+
bytes_output=bytes_output,
|
| 131 |
+
start_time_hanging=time.perf_counter(),
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# Remove any tasks that are no longer active
|
| 135 |
+
task_idxs_to_remove = (
|
| 136 |
+
set(self._state_map[operator.id].keys()) - active_tasks_idx
|
| 137 |
+
)
|
| 138 |
+
for task_idx in task_idxs_to_remove:
|
| 139 |
+
del self._state_map[operator.id][task_idx]
|
| 140 |
+
|
| 141 |
+
hanging_op_tasks = []
|
| 142 |
+
for op_id, op_state_values in self._state_map.items():
|
| 143 |
+
op_task_stats = op_task_stats_map[op_id]
|
| 144 |
+
for task_idx, state_value in op_state_values.items():
|
| 145 |
+
curr_time = time.perf_counter() - state_value.start_time_hanging
|
| 146 |
+
if op_task_stats.count() > self._op_task_stats_min_count:
|
| 147 |
+
mean = op_task_stats.mean()
|
| 148 |
+
stddev = op_task_stats.stddev()
|
| 149 |
+
threshold = mean + self._op_task_stats_std_factor_threshold * stddev
|
| 150 |
+
|
| 151 |
+
if curr_time > threshold:
|
| 152 |
+
hanging_op_tasks.append(state_value)
|
| 153 |
+
|
| 154 |
+
# create issues for newly detected hanging tasks, then update the hanging task set
|
| 155 |
+
issues = self._create_issues(
|
| 156 |
+
hanging_op_tasks=hanging_op_tasks,
|
| 157 |
+
op_task_stats_map=op_task_stats_map,
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
return issues
|
| 161 |
+
|
| 162 |
+
def detection_time_interval_s(self) -> float:
|
| 163 |
+
return self._detector_cfg.detection_time_interval_s
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/hash_shuffle_detector.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
from typing import TYPE_CHECKING, List
|
| 3 |
+
|
| 4 |
+
import ray
|
| 5 |
+
from ray.data._internal.execution.operators.hash_shuffle import (
|
| 6 |
+
AggregatorHealthInfo,
|
| 7 |
+
HashShuffleOperator,
|
| 8 |
+
)
|
| 9 |
+
from ray.data._internal.issue_detection.issue_detector import (
|
| 10 |
+
Issue,
|
| 11 |
+
IssueDetector,
|
| 12 |
+
IssueType,
|
| 13 |
+
)
|
| 14 |
+
from ray.data._internal.util import GiB
|
| 15 |
+
|
| 16 |
+
if TYPE_CHECKING:
|
| 17 |
+
from ray.data._internal.execution.streaming_executor import StreamingExecutor
|
| 18 |
+
from ray.data.context import DataContext
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class HashShuffleAggregatorIssueDetector(IssueDetector):
|
| 22 |
+
"""Detector for hash shuffle aggregator health issues."""
|
| 23 |
+
|
| 24 |
+
def __init__(self, executor: "StreamingExecutor", ctx: "DataContext"):
|
| 25 |
+
super().__init__(executor, ctx)
|
| 26 |
+
self._last_warning_times = {} # Track per-operator warning times
|
| 27 |
+
|
| 28 |
+
def detect(self) -> List[Issue]:
|
| 29 |
+
issues = []
|
| 30 |
+
current_time = time.time()
|
| 31 |
+
|
| 32 |
+
# Find all hash shuffle operators in the topology
|
| 33 |
+
for op in self._executor._topology.keys():
|
| 34 |
+
if not isinstance(op, HashShuffleOperator):
|
| 35 |
+
continue
|
| 36 |
+
|
| 37 |
+
# Skip if operator doesn't have aggregator pool yet
|
| 38 |
+
if op._aggregator_pool is None:
|
| 39 |
+
continue
|
| 40 |
+
|
| 41 |
+
pool = op._aggregator_pool
|
| 42 |
+
aggregator_info = pool.check_aggregator_health()
|
| 43 |
+
|
| 44 |
+
if aggregator_info is None:
|
| 45 |
+
continue
|
| 46 |
+
|
| 47 |
+
# Check if we should emit a warning for this operator
|
| 48 |
+
should_warn = self._should_emit_warning(
|
| 49 |
+
op.id, current_time, aggregator_info
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
if should_warn:
|
| 53 |
+
message = self._format_health_warning(aggregator_info)
|
| 54 |
+
issues.append(
|
| 55 |
+
Issue(
|
| 56 |
+
dataset_name=self._executor._dataset_id,
|
| 57 |
+
operator_id=op.id,
|
| 58 |
+
issue_type=IssueType.HANGING,
|
| 59 |
+
message=message,
|
| 60 |
+
)
|
| 61 |
+
)
|
| 62 |
+
self._last_warning_times[op.id] = current_time
|
| 63 |
+
|
| 64 |
+
return issues
|
| 65 |
+
|
| 66 |
+
def detection_time_interval_s(self) -> float:
|
| 67 |
+
return self._ctx.hash_shuffle_aggregator_health_warning_interval_s
|
| 68 |
+
|
| 69 |
+
def _should_emit_warning(
|
| 70 |
+
self, op_id: str, current_time: float, info: AggregatorHealthInfo
|
| 71 |
+
) -> bool:
|
| 72 |
+
"""Check if we should emit a warning for this operator."""
|
| 73 |
+
if not info.has_unready_aggregators:
|
| 74 |
+
# Clear warning time if all aggregators are healthy
|
| 75 |
+
self._last_warning_times.pop(op_id, None)
|
| 76 |
+
return False
|
| 77 |
+
|
| 78 |
+
# Check if enough time has passed since start
|
| 79 |
+
if (
|
| 80 |
+
current_time - info.started_at
|
| 81 |
+
< self._ctx.min_hash_shuffle_aggregator_wait_time_in_s
|
| 82 |
+
):
|
| 83 |
+
return False
|
| 84 |
+
|
| 85 |
+
# Check if enough time has passed since last warning
|
| 86 |
+
last_warning = self._last_warning_times.get(op_id)
|
| 87 |
+
if last_warning is None:
|
| 88 |
+
return True
|
| 89 |
+
|
| 90 |
+
return current_time - last_warning >= self.detection_time_interval_s()
|
| 91 |
+
|
| 92 |
+
def _format_health_warning(self, info: AggregatorHealthInfo) -> str:
|
| 93 |
+
"""Format the health warning message."""
|
| 94 |
+
available_resources = ray.available_resources()
|
| 95 |
+
available_cpus = available_resources.get("CPU", 0)
|
| 96 |
+
cluster_resources = ray.cluster_resources()
|
| 97 |
+
total_memory = cluster_resources.get("memory", 0)
|
| 98 |
+
available_memory = available_resources.get("memory", 0)
|
| 99 |
+
|
| 100 |
+
return (
|
| 101 |
+
f"Only {info.ready_aggregators} out of {info.total_aggregators} "
|
| 102 |
+
f"hash-shuffle aggregators are ready after {info.wait_time:.1f} secs. "
|
| 103 |
+
f"This might indicate resource contention for cluster resources "
|
| 104 |
+
f"(available CPUs: {available_cpus}, required CPUs: {info.required_resources.cpu}). "
|
| 105 |
+
f"Cluster only has {available_memory / GiB:.2f} GiB available memory, required memory: {info.required_resources.memory / GiB:.2f} GiB. "
|
| 106 |
+
f"{total_memory / GiB:.2f} GiB total memory. "
|
| 107 |
+
f"Consider increasing cluster size or reducing the number of aggregators "
|
| 108 |
+
f"via `DataContext.max_hash_shuffle_aggregators`. "
|
| 109 |
+
f"Will continue checking every {self.detection_time_interval_s()}s."
|
| 110 |
+
)
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/issue_detection/detectors/high_memory_detector.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import textwrap
|
| 2 |
+
from dataclasses import dataclass
|
| 3 |
+
from typing import TYPE_CHECKING, Dict, List
|
| 4 |
+
|
| 5 |
+
from ray.data._internal.execution.operators.map_operator import MapOperator
|
| 6 |
+
from ray.data._internal.execution.util import memory_string
|
| 7 |
+
from ray.data._internal.issue_detection.issue_detector import (
|
| 8 |
+
Issue,
|
| 9 |
+
IssueDetector,
|
| 10 |
+
IssueType,
|
| 11 |
+
)
|
| 12 |
+
|
| 13 |
+
if TYPE_CHECKING:
|
| 14 |
+
from ray.data._internal.execution.streaming_executor import StreamingExecutor
|
| 15 |
+
from ray.data.context import DataContext
|
| 16 |
+
|
| 17 |
+
HIGH_MEMORY_PERIODIC_WARNING = """
|
| 18 |
+
Operator '{op_name}' uses {memory_per_task} of memory per task on average, but Ray
|
| 19 |
+
only requests {initial_memory_request} per task at the start of the pipeline.
|
| 20 |
+
|
| 21 |
+
To avoid out-of-memory errors, consider setting `memory={memory_per_task}` in the
|
| 22 |
+
appropriate function or method call. (This might be unnecessary if the number of
|
| 23 |
+
concurrent tasks is low.)
|
| 24 |
+
|
| 25 |
+
To change the frequency of this warning, set
|
| 26 |
+
`DataContext.get_current().issue_detectors_config.high_memory_detector_config.detection_time_interval_s`,
|
| 27 |
+
or disable the warning by setting value to -1. (current value:
|
| 28 |
+
{detection_time_interval_s})
|
| 29 |
+
""" # noqa: E501
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
@dataclass
|
| 33 |
+
class HighMemoryIssueDetectorConfig:
|
| 34 |
+
detection_time_interval_s: float = 30
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
class HighMemoryIssueDetector(IssueDetector):
|
| 38 |
+
|
| 39 |
+
# Many nodes have a 4 GiB : 1 core ratio, but this isn't always the case (e.g., for
|
| 40 |
+
# high memory nodes).
|
| 41 |
+
_MEMORY_PER_CORE_ESTIMATE = 4 * 1024**3
|
| 42 |
+
|
| 43 |
+
def __init__(self, executor: "StreamingExecutor", ctx: "DataContext"):
|
| 44 |
+
super().__init__(executor, ctx)
|
| 45 |
+
self._detector_cfg = ctx.issue_detectors_config.high_memory_detector_config
|
| 46 |
+
|
| 47 |
+
self._initial_memory_requests: Dict[MapOperator, int] = {}
|
| 48 |
+
for op in self._executor._topology.keys():
|
| 49 |
+
if isinstance(op, MapOperator):
|
| 50 |
+
self._initial_memory_requests[op] = (
|
| 51 |
+
op._get_runtime_ray_remote_args().get("memory") or 0
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
def detect(self) -> List[Issue]:
|
| 55 |
+
issues = []
|
| 56 |
+
for op in self._executor._topology.keys():
|
| 57 |
+
if not isinstance(op, MapOperator):
|
| 58 |
+
continue
|
| 59 |
+
|
| 60 |
+
if op.metrics.average_max_uss_per_task is None:
|
| 61 |
+
continue
|
| 62 |
+
|
| 63 |
+
remote_args = op._get_runtime_ray_remote_args()
|
| 64 |
+
num_cpus_per_task = remote_args.get("num_cpus", 1)
|
| 65 |
+
max_memory_per_task = self._MEMORY_PER_CORE_ESTIMATE * num_cpus_per_task
|
| 66 |
+
|
| 67 |
+
if (
|
| 68 |
+
op.metrics.average_max_uss_per_task > self._initial_memory_requests[op]
|
| 69 |
+
and op.metrics.average_max_uss_per_task >= max_memory_per_task
|
| 70 |
+
):
|
| 71 |
+
message = HIGH_MEMORY_PERIODIC_WARNING.format(
|
| 72 |
+
op_name=op.name,
|
| 73 |
+
memory_per_task=memory_string(op.metrics.average_max_uss_per_task),
|
| 74 |
+
initial_memory_request=memory_string(
|
| 75 |
+
self._initial_memory_requests[op]
|
| 76 |
+
),
|
| 77 |
+
detection_time_interval_s=self.detection_time_interval_s(),
|
| 78 |
+
)
|
| 79 |
+
issues.append(
|
| 80 |
+
Issue(
|
| 81 |
+
dataset_name=self._executor._dataset_id,
|
| 82 |
+
operator_id=op.id,
|
| 83 |
+
issue_type=IssueType.HIGH_MEMORY,
|
| 84 |
+
message=_format_message(message),
|
| 85 |
+
)
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
return issues
|
| 89 |
+
|
| 90 |
+
def detection_time_interval_s(self) -> float:
|
| 91 |
+
return self._detector_cfg.detection_time_interval_s
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def _format_message(message: str) -> str:
|
| 95 |
+
# Apply some formatting to make the message look nicer when printed.
|
| 96 |
+
formatted_paragraphs = []
|
| 97 |
+
for paragraph in message.split("\n\n"):
|
| 98 |
+
formatted_paragraph = textwrap.fill(paragraph, break_long_words=False).strip()
|
| 99 |
+
formatted_paragraphs.append(formatted_paragraph)
|
| 100 |
+
formatted_message = "\n\n".join(formatted_paragraphs)
|
| 101 |
+
return "\n\n" + formatted_message + "\n"
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/iterator/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (197 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/iterator/__pycache__/iterator_impl.cpython-312.pyc
ADDED
|
Binary file (2.58 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/iterator/__pycache__/stream_split_iterator.cpython-312.pyc
ADDED
|
Binary file (13.7 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (196 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/optimizers.cpython-312.pyc
ADDED
|
Binary file (3.53 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/ruleset.cpython-312.pyc
ADDED
|
Binary file (4.48 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/__pycache__/util.cpython-312.pyc
ADDED
|
Binary file (3.33 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__init__.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .logical_operator import LogicalOperator
|
| 2 |
+
from .logical_plan import LogicalPlan
|
| 3 |
+
from .operator import Operator
|
| 4 |
+
from .optimizer import Optimizer, Rule
|
| 5 |
+
from .physical_plan import PhysicalPlan
|
| 6 |
+
from .plan import Plan
|
| 7 |
+
from .source_operator import SourceOperator
|
| 8 |
+
|
| 9 |
+
__all__ = [
|
| 10 |
+
"LogicalOperator",
|
| 11 |
+
"LogicalPlan",
|
| 12 |
+
"Operator",
|
| 13 |
+
"Optimizer",
|
| 14 |
+
"PhysicalPlan",
|
| 15 |
+
"Plan",
|
| 16 |
+
"Rule",
|
| 17 |
+
"SourceOperator",
|
| 18 |
+
]
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (622 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/logical_operator.cpython-312.pyc
ADDED
|
Binary file (4.68 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/logical_plan.cpython-312.pyc
ADDED
|
Binary file (1.82 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/operator.cpython-312.pyc
ADDED
|
Binary file (4.62 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/optimizer.cpython-312.pyc
ADDED
|
Binary file (2.3 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/physical_plan.cpython-312.pyc
ADDED
|
Binary file (1.69 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/plan.cpython-312.pyc
ADDED
|
Binary file (1.28 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/__pycache__/source_operator.cpython-312.pyc
ADDED
|
Binary file (1.01 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/logical_operator.py
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional
|
| 2 |
+
|
| 3 |
+
from .operator import Operator
|
| 4 |
+
from ray.data.block import BlockMetadata
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from ray.data.block import Schema
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class LogicalOperator(Operator):
|
| 11 |
+
"""Abstract class for logical operators.
|
| 12 |
+
|
| 13 |
+
A logical operator describes transformation, and later is converted into
|
| 14 |
+
physical operator.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
def __init__(
|
| 18 |
+
self,
|
| 19 |
+
name: str,
|
| 20 |
+
input_dependencies: List["LogicalOperator"],
|
| 21 |
+
num_outputs: Optional[int] = None,
|
| 22 |
+
):
|
| 23 |
+
super().__init__(
|
| 24 |
+
name,
|
| 25 |
+
input_dependencies,
|
| 26 |
+
)
|
| 27 |
+
for x in input_dependencies:
|
| 28 |
+
assert isinstance(x, LogicalOperator), x
|
| 29 |
+
self._num_outputs = num_outputs
|
| 30 |
+
|
| 31 |
+
def estimated_num_outputs(self) -> Optional[int]:
|
| 32 |
+
"""Returns the estimated number of blocks that
|
| 33 |
+
would be outputted by this logical operator.
|
| 34 |
+
|
| 35 |
+
This method does not execute the plan, so it does not take into consideration
|
| 36 |
+
block splitting. This method only considers high-level block constraints like
|
| 37 |
+
`Dataset.repartition(num_blocks=X)`. A more accurate estimation can be given by
|
| 38 |
+
`PhysicalOperator.num_outputs_total()` during execution.
|
| 39 |
+
"""
|
| 40 |
+
if self._num_outputs is not None:
|
| 41 |
+
return self._num_outputs
|
| 42 |
+
elif len(self._input_dependencies) == 1:
|
| 43 |
+
return self._input_dependencies[0].estimated_num_outputs()
|
| 44 |
+
return None
|
| 45 |
+
|
| 46 |
+
# Override the following 3 methods to correct type hints.
|
| 47 |
+
|
| 48 |
+
@property
|
| 49 |
+
def input_dependencies(self) -> List["LogicalOperator"]:
|
| 50 |
+
return super().input_dependencies # type: ignore
|
| 51 |
+
|
| 52 |
+
@property
|
| 53 |
+
def output_dependencies(self) -> List["LogicalOperator"]:
|
| 54 |
+
return super().output_dependencies # type: ignore
|
| 55 |
+
|
| 56 |
+
def post_order_iter(self) -> Iterator["LogicalOperator"]:
|
| 57 |
+
return super().post_order_iter() # type: ignore
|
| 58 |
+
|
| 59 |
+
def _apply_transform(
|
| 60 |
+
self, transform: Callable[["LogicalOperator"], "LogicalOperator"]
|
| 61 |
+
) -> "LogicalOperator":
|
| 62 |
+
return super()._apply_transform(transform) # type: ignore
|
| 63 |
+
|
| 64 |
+
def _get_args(self) -> Dict[str, Any]:
|
| 65 |
+
"""This Dict must be serializable"""
|
| 66 |
+
return vars(self)
|
| 67 |
+
|
| 68 |
+
def infer_schema(self) -> Optional["Schema"]:
|
| 69 |
+
"""Returns the inferred schema of the output blocks."""
|
| 70 |
+
return None
|
| 71 |
+
|
| 72 |
+
def infer_metadata(self) -> "BlockMetadata":
|
| 73 |
+
"""A ``BlockMetadata`` that represents the aggregate metadata of the outputs.
|
| 74 |
+
|
| 75 |
+
This method is used by methods like :meth:`~ray.data.Dataset.schema` to
|
| 76 |
+
efficiently return metadata.
|
| 77 |
+
"""
|
| 78 |
+
return BlockMetadata(None, None, None, None)
|
| 79 |
+
|
| 80 |
+
def is_lineage_serializable(self) -> bool:
|
| 81 |
+
"""Returns whether the lineage of this operator can be serialized.
|
| 82 |
+
|
| 83 |
+
An operator is lineage serializable if you can serialize it on one machine and
|
| 84 |
+
deserialize it on another without losing information. Operators that store
|
| 85 |
+
object references (e.g., ``InputData``) aren't lineage serializable because the
|
| 86 |
+
objects aren't available on the deserialized machine.
|
| 87 |
+
"""
|
| 88 |
+
return True
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/logical_plan.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING, List
|
| 2 |
+
|
| 3 |
+
from .logical_operator import LogicalOperator
|
| 4 |
+
from .plan import Plan
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from ray.data import DataContext
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
class LogicalPlan(Plan):
|
| 11 |
+
"""The plan with a DAG of logical operators."""
|
| 12 |
+
|
| 13 |
+
def __init__(self, dag: LogicalOperator, context: "DataContext"):
|
| 14 |
+
super().__init__(context)
|
| 15 |
+
self._dag = dag
|
| 16 |
+
|
| 17 |
+
@property
|
| 18 |
+
def dag(self) -> LogicalOperator:
|
| 19 |
+
"""Get the DAG of logical operators."""
|
| 20 |
+
return self._dag
|
| 21 |
+
|
| 22 |
+
def sources(self) -> List[LogicalOperator]:
|
| 23 |
+
"""List of operators that are sources for this plan's DAG."""
|
| 24 |
+
# If an operator has no input dependencies, it's a source.
|
| 25 |
+
if not any(self._dag.input_dependencies):
|
| 26 |
+
return [self._dag]
|
| 27 |
+
|
| 28 |
+
sources = []
|
| 29 |
+
for op in self._dag.input_dependencies:
|
| 30 |
+
sources.extend(LogicalPlan(op, self._context).sources())
|
| 31 |
+
return sources
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/operator.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import Callable, Iterator, List
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class Operator:
|
| 5 |
+
"""Abstract class for operators.
|
| 6 |
+
|
| 7 |
+
Operators live on the driver side of the Dataset only.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
def __init__(
|
| 11 |
+
self,
|
| 12 |
+
name: str,
|
| 13 |
+
input_dependencies: List["Operator"],
|
| 14 |
+
):
|
| 15 |
+
self._name = name
|
| 16 |
+
self._input_dependencies = input_dependencies
|
| 17 |
+
self._output_dependencies = []
|
| 18 |
+
|
| 19 |
+
self._wire_output_deps(input_dependencies)
|
| 20 |
+
|
| 21 |
+
@property
|
| 22 |
+
def name(self) -> str:
|
| 23 |
+
return self._name
|
| 24 |
+
|
| 25 |
+
@property
|
| 26 |
+
def dag_str(self) -> str:
|
| 27 |
+
"""String representation of the whole DAG."""
|
| 28 |
+
if self.input_dependencies:
|
| 29 |
+
out_str = ", ".join([x.dag_str for x in self.input_dependencies])
|
| 30 |
+
out_str += " -> "
|
| 31 |
+
else:
|
| 32 |
+
out_str = ""
|
| 33 |
+
out_str += f"{self.__class__.__name__}[{self._name}]"
|
| 34 |
+
return out_str
|
| 35 |
+
|
| 36 |
+
@property
|
| 37 |
+
def input_dependencies(self) -> List["Operator"]:
|
| 38 |
+
"""List of operators that provide inputs for this operator."""
|
| 39 |
+
assert hasattr(
|
| 40 |
+
self, "_input_dependencies"
|
| 41 |
+
), "Operator.__init__() was not called."
|
| 42 |
+
return self._input_dependencies
|
| 43 |
+
|
| 44 |
+
@property
|
| 45 |
+
def output_dependencies(self) -> List["Operator"]:
|
| 46 |
+
"""List of operators that consume outputs from this operator."""
|
| 47 |
+
assert hasattr(
|
| 48 |
+
self, "_output_dependencies"
|
| 49 |
+
), "Operator.__init__() was not called."
|
| 50 |
+
return self._output_dependencies
|
| 51 |
+
|
| 52 |
+
def post_order_iter(self) -> Iterator["Operator"]:
|
| 53 |
+
"""Depth-first traversal of this operator and its input dependencies."""
|
| 54 |
+
for op in self.input_dependencies:
|
| 55 |
+
yield from op.post_order_iter()
|
| 56 |
+
yield self
|
| 57 |
+
|
| 58 |
+
def _apply_transform(
|
| 59 |
+
self, transform: Callable[["Operator"], "Operator"]
|
| 60 |
+
) -> "Operator":
|
| 61 |
+
"""Recursively applies transformation (in post-order) to the operators DAG
|
| 62 |
+
|
| 63 |
+
NOTE: This operation should be opting in to avoid in-place modifications,
|
| 64 |
+
instead creating new operations whenever any operator needs to be
|
| 65 |
+
updated.
|
| 66 |
+
"""
|
| 67 |
+
|
| 68 |
+
transformed_input_ops = []
|
| 69 |
+
new_ops = []
|
| 70 |
+
|
| 71 |
+
for input_op in self.input_dependencies:
|
| 72 |
+
transformed_input_op = input_op._apply_transform(transform)
|
| 73 |
+
transformed_input_ops.append(transformed_input_op)
|
| 74 |
+
# Keep track of new input ops
|
| 75 |
+
if transformed_input_op is not input_op:
|
| 76 |
+
new_ops.append(transformed_input_op)
|
| 77 |
+
|
| 78 |
+
if new_ops:
|
| 79 |
+
# NOTE: Only newly created ops need to have output deps
|
| 80 |
+
# wired in
|
| 81 |
+
self._wire_output_deps(new_ops)
|
| 82 |
+
self._input_dependencies = transformed_input_ops
|
| 83 |
+
|
| 84 |
+
return transform(self)
|
| 85 |
+
|
| 86 |
+
def _wire_output_deps(self, input_dependencies: List["Operator"]):
|
| 87 |
+
for x in input_dependencies:
|
| 88 |
+
assert isinstance(x, Operator), x
|
| 89 |
+
x._output_dependencies.append(self)
|
| 90 |
+
|
| 91 |
+
def __repr__(self) -> str:
|
| 92 |
+
return f"{self.__class__.__name__}[{self._name}]"
|
| 93 |
+
|
| 94 |
+
def __str__(self) -> str:
|
| 95 |
+
return repr(self)
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/optimizer.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import List, Type
|
| 2 |
+
|
| 3 |
+
from .plan import Plan
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
class Rule:
|
| 7 |
+
"""Abstract class for optimization rule."""
|
| 8 |
+
|
| 9 |
+
def apply(self, plan: Plan) -> Plan:
|
| 10 |
+
"""Apply the optimization rule to the execution plan."""
|
| 11 |
+
raise NotImplementedError
|
| 12 |
+
|
| 13 |
+
@classmethod
|
| 14 |
+
def dependencies(cls) -> List[Type["Rule"]]:
|
| 15 |
+
"""List of rules that must be applied before this rule."""
|
| 16 |
+
return []
|
| 17 |
+
|
| 18 |
+
@classmethod
|
| 19 |
+
def dependents(cls) -> List[Type["Rule"]]:
|
| 20 |
+
"""List of rules that must be applied after this rule."""
|
| 21 |
+
return []
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
class Optimizer:
|
| 25 |
+
"""Abstract class for optimizers.
|
| 26 |
+
|
| 27 |
+
An optimizers transforms a DAG of operators with a list of predefined rules.
|
| 28 |
+
"""
|
| 29 |
+
|
| 30 |
+
@property
|
| 31 |
+
def rules(self) -> List[Rule]:
|
| 32 |
+
"""List of predefined rules for this optimizer."""
|
| 33 |
+
raise NotImplementedError
|
| 34 |
+
|
| 35 |
+
def optimize(self, plan: Plan) -> Plan:
|
| 36 |
+
"""Optimize operators with a list of rules."""
|
| 37 |
+
# Apply rules until the plan is not changed
|
| 38 |
+
previous_plan = plan
|
| 39 |
+
while True:
|
| 40 |
+
for rule in self.rules:
|
| 41 |
+
plan = rule.apply(plan)
|
| 42 |
+
# TODO: Eventually we should implement proper equality.
|
| 43 |
+
# Using str to check equality seems brittle
|
| 44 |
+
if plan.dag.dag_str == previous_plan.dag.dag_str:
|
| 45 |
+
break
|
| 46 |
+
previous_plan = plan
|
| 47 |
+
return plan
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/physical_plan.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING, Dict
|
| 2 |
+
|
| 3 |
+
from .logical_operator import LogicalOperator
|
| 4 |
+
from .plan import Plan
|
| 5 |
+
|
| 6 |
+
if TYPE_CHECKING:
|
| 7 |
+
from ray.data import DataContext
|
| 8 |
+
from ray.data._internal.execution.interfaces import PhysicalOperator
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class PhysicalPlan(Plan):
|
| 12 |
+
"""The plan with a DAG of physical operators."""
|
| 13 |
+
|
| 14 |
+
def __init__(
|
| 15 |
+
self,
|
| 16 |
+
dag: "PhysicalOperator",
|
| 17 |
+
op_map: Dict["PhysicalOperator", LogicalOperator],
|
| 18 |
+
context: "DataContext",
|
| 19 |
+
):
|
| 20 |
+
super().__init__(context)
|
| 21 |
+
self._dag = dag
|
| 22 |
+
self._op_map = op_map
|
| 23 |
+
|
| 24 |
+
@property
|
| 25 |
+
def dag(self) -> "PhysicalOperator":
|
| 26 |
+
"""Get the DAG of physical operators."""
|
| 27 |
+
return self._dag
|
| 28 |
+
|
| 29 |
+
@property
|
| 30 |
+
def op_map(self) -> Dict["PhysicalOperator", LogicalOperator]:
|
| 31 |
+
"""
|
| 32 |
+
Get a mapping from physical operators to their corresponding logical operator.
|
| 33 |
+
"""
|
| 34 |
+
return self._op_map
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/plan.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING
|
| 2 |
+
|
| 3 |
+
from .operator import Operator
|
| 4 |
+
|
| 5 |
+
if TYPE_CHECKING:
|
| 6 |
+
from ray.data import DataContext
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class Plan:
|
| 10 |
+
"""Abstract class for logical/physical execution plans.
|
| 11 |
+
|
| 12 |
+
This plan should hold an operator representing the plan DAG and any auxiliary data
|
| 13 |
+
that's useful for plan optimization or execution.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
def __init__(self, context: "DataContext"):
|
| 17 |
+
self._context = context
|
| 18 |
+
|
| 19 |
+
@property
|
| 20 |
+
def dag(self) -> Operator:
|
| 21 |
+
raise NotImplementedError
|
| 22 |
+
|
| 23 |
+
@property
|
| 24 |
+
def context(self) -> "DataContext":
|
| 25 |
+
return self._context
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/interfaces/source_operator.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from abc import ABC, abstractmethod
|
| 2 |
+
from typing import TYPE_CHECKING, List, Optional
|
| 3 |
+
|
| 4 |
+
if TYPE_CHECKING:
|
| 5 |
+
|
| 6 |
+
from ray.data.dataset import RefBundle
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class SourceOperator(ABC):
|
| 10 |
+
"""Mixin for Logical operators that can be logical source nodes.
|
| 11 |
+
Subclasses: Read, InputData, FromAbstract.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
@abstractmethod
|
| 15 |
+
def output_data(self) -> Optional[List["RefBundle"]]:
|
| 16 |
+
"""The output data of this operator if already known, or ``None``."""
|
| 17 |
+
pass
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__init__.py
ADDED
|
File without changes
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/__init__.cpython-312.pyc
ADDED
|
Binary file (206 Bytes). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/all_to_all_operator.cpython-312.pyc
ADDED
|
Binary file (9.5 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/count_operator.cpython-312.pyc
ADDED
|
Binary file (1.17 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/from_operators.cpython-312.pyc
ADDED
|
Binary file (5.93 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/input_data_operator.cpython-312.pyc
ADDED
|
Binary file (4.03 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/join_operator.cpython-312.pyc
ADDED
|
Binary file (5.88 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/map_operator.cpython-312.pyc
ADDED
|
Binary file (15.8 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/n_ary_operator.cpython-312.pyc
ADDED
|
Binary file (2.83 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/one_to_one_operator.cpython-312.pyc
ADDED
|
Binary file (4.59 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/read_operator.cpython-312.pyc
ADDED
|
Binary file (5.8 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/streaming_split_operator.cpython-312.pyc
ADDED
|
Binary file (1.2 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/__pycache__/write_operator.cpython-312.pyc
ADDED
|
Binary file (1.65 kB). View file
|
|
|
tool_server/.venv/lib/python3.12/site-packages/ray/data/_internal/logical/operators/all_to_all_operator.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from typing import TYPE_CHECKING, Any, Dict, List, Optional
|
| 2 |
+
|
| 3 |
+
from ray.data._internal.logical.interfaces import LogicalOperator
|
| 4 |
+
from ray.data._internal.planner.exchange.interfaces import ExchangeTaskSpec
|
| 5 |
+
from ray.data._internal.planner.exchange.shuffle_task_spec import ShuffleTaskSpec
|
| 6 |
+
from ray.data._internal.planner.exchange.sort_task_spec import SortKey, SortTaskSpec
|
| 7 |
+
from ray.data.aggregate import AggregateFn
|
| 8 |
+
from ray.data.block import BlockMetadata
|
| 9 |
+
|
| 10 |
+
if TYPE_CHECKING:
|
| 11 |
+
|
| 12 |
+
from ray.data.block import Schema
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
class AbstractAllToAll(LogicalOperator):
|
| 16 |
+
"""Abstract class for logical operators should be converted to physical
|
| 17 |
+
AllToAllOperator.
|
| 18 |
+
"""
|
| 19 |
+
|
| 20 |
+
def __init__(
|
| 21 |
+
self,
|
| 22 |
+
name: str,
|
| 23 |
+
input_op: LogicalOperator,
|
| 24 |
+
num_outputs: Optional[int] = None,
|
| 25 |
+
sub_progress_bar_names: Optional[List[str]] = None,
|
| 26 |
+
ray_remote_args: Optional[Dict[str, Any]] = None,
|
| 27 |
+
):
|
| 28 |
+
"""
|
| 29 |
+
Args:
|
| 30 |
+
name: Name for this operator. This is the name that will appear when
|
| 31 |
+
inspecting the logical plan of a Dataset.
|
| 32 |
+
input_op: The operator preceding this operator in the plan DAG. The outputs
|
| 33 |
+
of `input_op` will be the inputs to this operator.
|
| 34 |
+
num_outputs: The number of expected output bundles outputted by this
|
| 35 |
+
operator.
|
| 36 |
+
ray_remote_args: Args to provide to :func:`ray.remote`.
|
| 37 |
+
"""
|
| 38 |
+
super().__init__(name, [input_op], num_outputs)
|
| 39 |
+
self._num_outputs = num_outputs
|
| 40 |
+
self._ray_remote_args = ray_remote_args or {}
|
| 41 |
+
self._sub_progress_bar_names = sub_progress_bar_names
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
class RandomizeBlocks(AbstractAllToAll):
|
| 45 |
+
"""Logical operator for randomize_block_order."""
|
| 46 |
+
|
| 47 |
+
def __init__(
|
| 48 |
+
self,
|
| 49 |
+
input_op: LogicalOperator,
|
| 50 |
+
seed: Optional[int] = None,
|
| 51 |
+
):
|
| 52 |
+
super().__init__(
|
| 53 |
+
"RandomizeBlockOrder",
|
| 54 |
+
input_op,
|
| 55 |
+
)
|
| 56 |
+
self._seed = seed
|
| 57 |
+
|
| 58 |
+
def infer_metadata(self) -> "BlockMetadata":
|
| 59 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 60 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 61 |
+
return self._input_dependencies[0].infer_metadata()
|
| 62 |
+
|
| 63 |
+
def infer_schema(
|
| 64 |
+
self,
|
| 65 |
+
) -> Optional["Schema"]:
|
| 66 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 67 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 68 |
+
return self._input_dependencies[0].infer_schema()
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
class RandomShuffle(AbstractAllToAll):
|
| 72 |
+
"""Logical operator for random_shuffle."""
|
| 73 |
+
|
| 74 |
+
def __init__(
|
| 75 |
+
self,
|
| 76 |
+
input_op: LogicalOperator,
|
| 77 |
+
name: str = "RandomShuffle",
|
| 78 |
+
seed: Optional[int] = None,
|
| 79 |
+
ray_remote_args: Optional[Dict[str, Any]] = None,
|
| 80 |
+
):
|
| 81 |
+
super().__init__(
|
| 82 |
+
name,
|
| 83 |
+
input_op,
|
| 84 |
+
sub_progress_bar_names=[
|
| 85 |
+
ExchangeTaskSpec.MAP_SUB_PROGRESS_BAR_NAME,
|
| 86 |
+
ExchangeTaskSpec.REDUCE_SUB_PROGRESS_BAR_NAME,
|
| 87 |
+
],
|
| 88 |
+
ray_remote_args=ray_remote_args,
|
| 89 |
+
)
|
| 90 |
+
self._seed = seed
|
| 91 |
+
|
| 92 |
+
def infer_metadata(self) -> "BlockMetadata":
|
| 93 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 94 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 95 |
+
return self._input_dependencies[0].infer_metadata()
|
| 96 |
+
|
| 97 |
+
def infer_schema(
|
| 98 |
+
self,
|
| 99 |
+
) -> Optional["Schema"]:
|
| 100 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 101 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 102 |
+
return self._input_dependencies[0].infer_schema()
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
class Repartition(AbstractAllToAll):
|
| 106 |
+
"""Logical operator for repartition."""
|
| 107 |
+
|
| 108 |
+
def __init__(
|
| 109 |
+
self,
|
| 110 |
+
input_op: LogicalOperator,
|
| 111 |
+
num_outputs: int,
|
| 112 |
+
shuffle: bool,
|
| 113 |
+
keys: Optional[List[str]] = None,
|
| 114 |
+
sort: bool = False,
|
| 115 |
+
):
|
| 116 |
+
if shuffle:
|
| 117 |
+
sub_progress_bar_names = [
|
| 118 |
+
ExchangeTaskSpec.MAP_SUB_PROGRESS_BAR_NAME,
|
| 119 |
+
ExchangeTaskSpec.REDUCE_SUB_PROGRESS_BAR_NAME,
|
| 120 |
+
]
|
| 121 |
+
else:
|
| 122 |
+
sub_progress_bar_names = [
|
| 123 |
+
ShuffleTaskSpec.SPLIT_REPARTITION_SUB_PROGRESS_BAR_NAME,
|
| 124 |
+
]
|
| 125 |
+
super().__init__(
|
| 126 |
+
"Repartition",
|
| 127 |
+
input_op,
|
| 128 |
+
num_outputs=num_outputs,
|
| 129 |
+
sub_progress_bar_names=sub_progress_bar_names,
|
| 130 |
+
)
|
| 131 |
+
self._shuffle = shuffle
|
| 132 |
+
self._keys = keys
|
| 133 |
+
self._sort = sort
|
| 134 |
+
|
| 135 |
+
def infer_metadata(self) -> "BlockMetadata":
|
| 136 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 137 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 138 |
+
return self._input_dependencies[0].infer_metadata()
|
| 139 |
+
|
| 140 |
+
def infer_schema(
|
| 141 |
+
self,
|
| 142 |
+
) -> Optional["Schema"]:
|
| 143 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 144 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 145 |
+
return self._input_dependencies[0].infer_schema()
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
class Sort(AbstractAllToAll):
|
| 149 |
+
"""Logical operator for sort."""
|
| 150 |
+
|
| 151 |
+
def __init__(
|
| 152 |
+
self,
|
| 153 |
+
input_op: LogicalOperator,
|
| 154 |
+
sort_key: SortKey,
|
| 155 |
+
batch_format: Optional[str] = "default",
|
| 156 |
+
):
|
| 157 |
+
super().__init__(
|
| 158 |
+
"Sort",
|
| 159 |
+
input_op,
|
| 160 |
+
sub_progress_bar_names=[
|
| 161 |
+
SortTaskSpec.SORT_SAMPLE_SUB_PROGRESS_BAR_NAME,
|
| 162 |
+
ExchangeTaskSpec.MAP_SUB_PROGRESS_BAR_NAME,
|
| 163 |
+
ExchangeTaskSpec.REDUCE_SUB_PROGRESS_BAR_NAME,
|
| 164 |
+
],
|
| 165 |
+
)
|
| 166 |
+
self._sort_key = sort_key
|
| 167 |
+
self._batch_format = batch_format
|
| 168 |
+
|
| 169 |
+
def infer_metadata(self) -> "BlockMetadata":
|
| 170 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 171 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 172 |
+
return self._input_dependencies[0].infer_metadata()
|
| 173 |
+
|
| 174 |
+
def infer_schema(
|
| 175 |
+
self,
|
| 176 |
+
) -> Optional["Schema"]:
|
| 177 |
+
assert len(self._input_dependencies) == 1, len(self._input_dependencies)
|
| 178 |
+
assert isinstance(self._input_dependencies[0], LogicalOperator)
|
| 179 |
+
return self._input_dependencies[0].infer_schema()
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
class Aggregate(AbstractAllToAll):
|
| 183 |
+
"""Logical operator for aggregate."""
|
| 184 |
+
|
| 185 |
+
def __init__(
|
| 186 |
+
self,
|
| 187 |
+
input_op: LogicalOperator,
|
| 188 |
+
key: Optional[str],
|
| 189 |
+
aggs: List[AggregateFn],
|
| 190 |
+
num_partitions: Optional[int] = None,
|
| 191 |
+
batch_format: Optional[str] = "default",
|
| 192 |
+
):
|
| 193 |
+
super().__init__(
|
| 194 |
+
"Aggregate",
|
| 195 |
+
input_op,
|
| 196 |
+
sub_progress_bar_names=[
|
| 197 |
+
SortTaskSpec.SORT_SAMPLE_SUB_PROGRESS_BAR_NAME,
|
| 198 |
+
ExchangeTaskSpec.MAP_SUB_PROGRESS_BAR_NAME,
|
| 199 |
+
ExchangeTaskSpec.REDUCE_SUB_PROGRESS_BAR_NAME,
|
| 200 |
+
],
|
| 201 |
+
)
|
| 202 |
+
self._key = key
|
| 203 |
+
self._aggs = aggs
|
| 204 |
+
self._num_partitions = num_partitions
|
| 205 |
+
self._batch_format = batch_format
|