Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Data] Deprecate to_torch #48692

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/source/data/api/dataset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ Deprecated API
:nosignatures:
:toctree: doc/

Dataset.iter_tf_batches
Dataset.iter_tf_batches
Dataset.to_torch
8 changes: 6 additions & 2 deletions python/ray/data/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4096,7 +4096,7 @@ def iter_tf_batches(
)

@ConsumptionAPI(pattern="Time complexity:")
@PublicAPI(api_group=IOC_API_GROUP)
@Deprecated
def to_torch(
self,
*,
Expand Down Expand Up @@ -4207,7 +4207,11 @@ def to_torch(
Returns:
A `Torch IterableDataset`_.
""" # noqa: E501

warnings.warn(
"`to_torch` is deprecated and will be removed after May 2025. Use "
"`iter_torch_batches` instead.",
DeprecationWarning,
)
return self.iterator().to_torch(
label_column=label_column,
feature_columns=feature_columns,
Expand Down
5 changes: 5 additions & 0 deletions python/ray/data/tests/test_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from ray.tests.conftest import * # noqa


def test_to_torch_emits_deprecation_warning(ray_start_10_cpus_shared):
with pytest.warns(DeprecationWarning):
ray.data.range(1).to_torch()


def test_to_torch(ray_start_10_cpus_shared):
import torch

Expand Down
Loading