| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6b212f5 commit a754cfd
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ | |||
| 12 | 12 | import pyarrow as pa | |
| 13 | 13 | import ray | |
| 14 | 14 | from ray.data import Dataset | |
| 15 | - from ray.data.context import DatasetContext | ||
| 15 | + from ray.data.context import DatasetContext, ShuffleStrategy | ||
| 16 | 16 | ||
| 17 | 17 | from feast.data_source import DataSource | |
| 18 | 18 | from feast.dataframe import DataFrameEngine, FeastDataFrame | |
@@ -460,7 +460,7 @@ def configure_ray_context(self) -> None: | |||
| 460 | 460 | else 2 | |
| 461 | 461 | ) | |
| 462 | 462 | ctx.max_parallelism = self.available_cpus * multiplier | |
| 463 | - ctx.shuffle_strategy = "sort" # type: ignore | ||
| 463 | + ctx.shuffle_strategy = ShuffleStrategy.SORT_SHUFFLE_PULL_BASED | ||
| 464 | 464 | ctx.enable_tensor_extension_casting = False | |
| 465 | 465 | ||
| 466 | 466 | if not getattr(self.config, "enable_ray_logging", False): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ | |||
| 25 | 25 | from typing import Any, Dict, List, Optional, Union | |
| 26 | 26 | ||
| 27 | 27 | import ray | |
| 28 | - from ray.data.context import DatasetContext | ||
| 28 | + from ray.data.context import DatasetContext, ShuffleStrategy | ||
| 29 | 29 | ||
| 30 | 30 | logger = logging.getLogger(__name__) | |
| 31 | 31 | ||
@@ -698,7 +698,7 @@ def _initialize_local_ray(config: Any, enable_logging: bool = False) -> None: | |||
| 698 | 698 | ||
| 699 | 699 | # Configure DatasetContext | |
| 700 | 700 | ctx = DatasetContext.get_current() | |
| 701 | - ctx.shuffle_strategy = "sort" # type: ignore | ||
| 701 | + ctx.shuffle_strategy = ShuffleStrategy.SORT_SHUFFLE_PULL_BASED | ||
| 702 | 702 | ctx.enable_tensor_extension_casting = False | |
| 703 | 703 | if hasattr(ctx, "enable_arrow_backed_pandas_conversion"): | |
| 704 | 704 | ctx.enable_arrow_backed_pandas_conversion = False | |
@@ -760,7 +760,7 @@ def _initialize_remote_ray(config: Any, enable_logging: bool = False) -> None: | |||
| 760 | 760 | ||
| 761 | 761 | # Configure DatasetContext | |
| 762 | 762 | ctx = DatasetContext.get_current() | |
| 763 | - ctx.shuffle_strategy = "sort" # type: ignore | ||
| 763 | + ctx.shuffle_strategy = ShuffleStrategy.SORT_SHUFFLE_PULL_BASED | ||
| 764 | 764 | ctx.enable_tensor_extension_casting = False | |
| 765 | 765 | if hasattr(ctx, "enable_arrow_backed_pandas_conversion"): | |
| 766 | 766 | ctx.enable_arrow_backed_pandas_conversion = False | |
@@ -855,7 +855,7 @@ def ensure_ray_initialized( | |||
| 855 | 855 | logger.info("Ray is already initialized externally, using existing cluster") | |
| 856 | 856 | # Configure DatasetContext even if Ray is already initialized | |
| 857 | 857 | ctx = DatasetContext.get_current() | |
| 858 | - ctx.shuffle_strategy = "sort" # type: ignore | ||
| 858 | + ctx.shuffle_strategy = ShuffleStrategy.SORT_SHUFFLE_PULL_BASED | ||
| 859 | 859 | ctx.enable_tensor_extension_casting = False | |
| 860 | 860 | if hasattr(ctx, "enable_arrow_backed_pandas_conversion"): | |
| 861 | 861 | ctx.enable_arrow_backed_pandas_conversion = False | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ | |||
| 20 | 20 | import pyarrow as pa | |
| 21 | 21 | import pytest | |
| 22 | 22 | import ray | |
| 23 | + from ray.data.context import DatasetContext, ShuffleStrategy | ||
| 23 | 24 | ||
| 24 | 25 | from feast.infra.compute_engines.dag.model import DAGFormat | |
| 25 | 26 | from feast.infra.compute_engines.dag.node import DAGNode | |
@@ -31,7 +32,7 @@ | |||
| 31 | 32 | RayOfflineStoreConfig, | |
| 32 | 33 | RayResourceManager, | |
| 33 | 34 | ) | |
| 34 | - from feast.infra.ray_initializer import CodeFlareRayWrapper | ||
| 35 | + from feast.infra.ray_initializer import CodeFlareRayWrapper, ensure_ray_initialized | ||
| 35 | 36 | from feast.infra.ray_shared_utils import RemoteDatasetProxy | |
| 36 | 37 | ||
| 37 | 38 | # --------------------------------------------------------------------------- | |
@@ -492,6 +493,43 @@ def test_available_gpus_zero_when_ray_not_initialized(self): | |||
| 492 | 493 | assert mgr.available_gpus == 0 | |
| 493 | 494 | ||
| 494 | 495 | ||
| 496 | + # --------------------------------------------------------------------------- | ||
| 497 | + # DatasetContext shuffle strategy — must be a valid ShuffleStrategy member | ||
| 498 | + # (Ray >= 2.59 rejects unknown values such as "sort") | ||
| 499 | + # --------------------------------------------------------------------------- | ||
| 500 | + | ||
| 501 | + | ||
| 502 | + @pytest.fixture | ||
| 503 | + def restore_shuffle_strategy(): | ||
| 504 | + ctx = DatasetContext.get_current() | ||
| 505 | + original = ctx.shuffle_strategy | ||
| 506 | + yield | ||
| 507 | + ctx.shuffle_strategy = original | ||
| 508 | + | ||
| 509 | + | ||
| 510 | + class TestShuffleStrategy: | ||
| 511 | + def test_configure_ray_context_sets_sort_shuffle(self, restore_shuffle_strategy): | ||
| 512 | + with patch("ray.is_initialized", return_value=False): | ||
| 513 | + mgr = RayResourceManager() | ||
| 514 | + mgr.configure_ray_context() | ||
| 515 | + assert ( | ||
| 516 | + DatasetContext.get_current().shuffle_strategy | ||
| 517 | + == ShuffleStrategy.SORT_SHUFFLE_PULL_BASED | ||
| 518 | + ) | ||
| 519 | + | ||
| 520 | + def test_ensure_ray_initialized_sets_sort_shuffle(self, restore_shuffle_strategy): | ||
| 521 | + with ( | ||
| 522 | + patch("feast.infra.ray_initializer._ray_initialized", False), | ||
| 523 | + patch("feast.infra.ray_initializer.ray") as mock_ray, | ||
| 524 | + ): | ||
| 525 | + mock_ray.is_initialized.return_value = True | ||
| 526 | + ensure_ray_initialized(RayComputeEngineConfig()) | ||
| 527 | + assert ( | ||
| 528 | + DatasetContext.get_current().shuffle_strategy | ||
| 529 | + == ShuffleStrategy.SORT_SHUFFLE_PULL_BASED | ||
| 530 | + ) | ||
| 531 | + | ||
| 532 | + | ||
| 495 | 533 | # --------------------------------------------------------------------------- | |
| 496 | 534 | # safe_batch_processor / _is_empty_batch — format-aware empty detection | |
| 497 | 535 | # Regression tests for AttributeError when gpu_batch_format is "numpy"/"pyarrow" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments