Specify the task-based compute strategy for a Dataset transform. TaskPoolStrategy executes dataset transformations using Ray tasks that are scheduled through a pool. Provide ``size`` to cap the number of concurrent tasks; leave it unset to allow Ray Data to scale the task count auto
| 30 | |
| 31 | @PublicAPI |
| 32 | class TaskPoolStrategy(ComputeStrategy): |
| 33 | """Specify the task-based compute strategy for a Dataset transform. |
| 34 | |
| 35 | TaskPoolStrategy executes dataset transformations using Ray tasks that are |
| 36 | scheduled through a pool. Provide ``size`` to cap the number of concurrent |
| 37 | tasks; leave it unset to allow Ray Data to scale the task count |
| 38 | automatically. |
| 39 | """ |
| 40 | |
| 41 | def __init__( |
| 42 | self, |
| 43 | size: Optional[int] = None, |
| 44 | ): |
| 45 | """Construct TaskPoolStrategy for a Dataset transform. |
| 46 | |
| 47 | Args: |
| 48 | size: Specify the maximum size of the task pool. |
| 49 | """ |
| 50 | |
| 51 | if size is not None and size < 1: |
| 52 | raise ValueError("`size` must be >= 1", size) |
| 53 | self.size = size |
| 54 | |
| 55 | def __eq__(self, other: Any) -> bool: |
| 56 | return (isinstance(other, TaskPoolStrategy) and self.size == other.size) or ( |
| 57 | other == "tasks" and self.size is None |
| 58 | ) |
| 59 | |
| 60 | def __repr__(self) -> str: |
| 61 | return f"TaskPoolStrategy(size={self.size})" |
| 62 | |
| 63 | |
| 64 | @PublicAPI |
no outgoing calls
searching dependent graphs…