diff --git a/.github/scripts/m1_script.sh b/.github/scripts/m1_script.sh index fd374bf79..cddc40035 100644 --- a/.github/scripts/m1_script.sh +++ b/.github/scripts/m1_script.sh @@ -1,3 +1,3 @@ #!/bin/bash -export TENSORDICT_BUILD_VERSION=0.4.0 +export TENSORDICT_BUILD_VERSION=0.5.0 diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index c67317d42..4ab4adb81 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -38,7 +38,7 @@ jobs: run: | export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH" python3 -mpip install wheel - TENSORDICT_BUILD_VERSION=0.4.0 python3 setup.py bdist_wheel + TENSORDICT_BUILD_VERSION=0.5.0 python3 setup.py bdist_wheel # NB: wheels have the linux_x86_64 tag so we rename to manylinux1 # find . -name 'dist/*whl' -exec bash -c ' mv $0 ${0/linux/manylinux1}' {} \; # pytorch/pytorch binaries are also manylinux_2_17 compliant but they @@ -84,7 +84,7 @@ jobs: shell: bash run: | python3 -mpip install wheel setuptools - TENSORDICT_BUILD_VERSION=0.4.0 python3 setup.py bdist_wheel + TENSORDICT_BUILD_VERSION=0.5.0 python3 setup.py bdist_wheel - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: diff --git a/benchmarks/distributed/dataloading.py b/benchmarks/distributed/dataloading.py index 5d1777b57..0c8b03cdf 100644 --- a/benchmarks/distributed/dataloading.py +++ b/benchmarks/distributed/dataloading.py @@ -28,8 +28,7 @@ import torch import tqdm -from tensordict import MemoryMappedTensor -from tensordict.prototype import tensorclass +from tensordict import MemoryMappedTensor, tensorclass from torch import multiprocessing as mp, nn from torch.distributed import rpc from torch.utils.data import DataLoader diff --git a/benchmarks/tensorclass/test_tensorclass_speed.py b/benchmarks/tensorclass/test_tensorclass_speed.py index 0c8bf8c7d..452f6b86a 100644 --- a/benchmarks/tensorclass/test_tensorclass_speed.py +++ b/benchmarks/tensorclass/test_tensorclass_speed.py @@ -9,7 +9,7 @@ import pytest import torch -from tensordict.prototype import tensorclass +from tensordict import tensorclass @tensorclass diff --git a/benchmarks/tensorclass/test_torch_functions.py b/benchmarks/tensorclass/test_torch_functions.py index 0dc3c560c..7ed717872 100644 --- a/benchmarks/tensorclass/test_torch_functions.py +++ b/benchmarks/tensorclass/test_torch_functions.py @@ -6,7 +6,7 @@ import pytest import torch -from tensordict.prototype import tensorclass +from tensordict import tensorclass @tensorclass diff --git a/tensordict/_lazy.py b/tensordict/_lazy.py index 4d08ce4cd..70c456931 100644 --- a/tensordict/_lazy.py +++ b/tensordict/_lazy.py @@ -27,6 +27,7 @@ Tuple, Type, ) +from warnings import warn import numpy as np @@ -1695,8 +1696,18 @@ def _apply_nest( ) for i, (td, *oth) in enumerate(zip(self.tensordicts, *others)) ] - if filter_empty and all(r is None for r in results): - return + if all(r is None for r in results): + if filter_empty is None: + warn( + "Your resulting tensordict has no leaves but you did not specify filter_empty=True. " + "This now returns None (filter_empty=True). " + "To silence this warning, set filter_empty to the desired value in your call to `apply`. " + "This warning will be removed in v0.6.", + category=DeprecationWarning, + ) + return + elif filter_empty: + return if not inplace: out = type(self)( *results, diff --git a/tensordict/_td.py b/tensordict/_td.py index d2df70d11..d1f5aacff 100644 --- a/tensordict/_td.py +++ b/tensordict/_td.py @@ -1237,12 +1237,13 @@ def make_result(names=names, batch_size=batch_size): # After we introduce the new behaviour, we will have to consider what happens # to empty tensordicts by default: will they disappear or stay? warn( - "Your resulting tensordict has no leaves but you did not specify filter_empty=False. " - "Currently, this returns an empty tree (filter_empty=True), but from v0.5 it will return " - "a None unless filter_empty=False. " - "To silence this warning, set filter_empty to the desired value in your call to `apply`.", + "Your resulting tensordict has no leaves but you did not specify filter_empty=True. " + "This now returns None (filter_empty=True). " + "To silence this warning, set filter_empty to the desired value in your call to `apply`. " + "This warning will be removed in v0.6.", category=DeprecationWarning, ) + return if result is None: result = make_result() diff --git a/tensordict/functional.py b/tensordict/functional.py index 23367f998..ea11d0423 100644 --- a/tensordict/functional.py +++ b/tensordict/functional.py @@ -141,7 +141,8 @@ def pad_sequence( ) if batch_first is not None: warnings.warn( - "The batch_first argument is deprecated and will be removed in a future release. The output will always be batch_first.", + "The batch_first argument is deprecated and will be removed in v0.6. " + "The output will always be batch_first.", category=DeprecationWarning, ) diff --git a/tensordict/nn/common.py b/tensordict/nn/common.py index cc53aaef7..77862465e 100644 --- a/tensordict/nn/common.py +++ b/tensordict/nn/common.py @@ -1163,7 +1163,8 @@ def forward( # special rule for TensorDictModule that states that the second arg is # likely to be the module params. warnings.warn( - "tensordict_out will be deprecated soon.", + "tensordict_out will be deprecated in v0.6. " + "Make sure you have removed any such arg by then.", category=DeprecationWarning, ) if len(args): diff --git a/tensordict/nn/probabilistic.py b/tensordict/nn/probabilistic.py index bf8ac049c..1066f4a3c 100644 --- a/tensordict/nn/probabilistic.py +++ b/tensordict/nn/probabilistic.py @@ -64,7 +64,7 @@ def _insert_interaction_mode_deprecation_warning( ) -> Callable[[str, Warning, int], None]: return warn( ( - f"{prefix}interaction_mode is deprecated for naming clarity. " + f"{prefix}interaction_mode is deprecated for naming clarity and will be removed in v0.6. " f"Please use {prefix}interaction_type with InteractionType enum instead." ), DeprecationWarning, @@ -413,7 +413,7 @@ def log_prob(self, tensordict): @property def SAMPLE_LOG_PROB_KEY(self): warnings.warn( - "SAMPLE_LOG_PROB_KEY will be deprecated soon." + "SAMPLE_LOG_PROB_KEY will be deprecated in v0.6." "Use 'obj.log_prob_key' instead", category=DeprecationWarning, ) diff --git a/tensordict/prototype/__init__.py b/tensordict/prototype/__init__.py index 352ee63d0..a30550412 100644 --- a/tensordict/prototype/__init__.py +++ b/tensordict/prototype/__init__.py @@ -3,10 +3,7 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from tensordict.prototype.fx import symbolic_trace -from tensordict.prototype.tensorclass import is_tensorclass, tensorclass __all__ = [ - "is_tensorclass", "symbolic_trace", - "tensorclass", ] diff --git a/tensordict/prototype/tensorclass.py b/tensordict/prototype/tensorclass.py deleted file mode 100644 index bf1b958e5..000000000 --- a/tensordict/prototype/tensorclass.py +++ /dev/null @@ -1,23 +0,0 @@ -import warnings -from functools import wraps - -from tensordict._td import is_tensorclass as is_tensorclass_true # no_qa -from tensordict.tensorclass import tensorclass as tensorclass_true # no_qa - - -@wraps(tensorclass_true) -def tensorclass(*args, **kwargs): # noqa: D103 - warnings.warn( - "tensorclass is not a prototype anymore and can be imported directly from tensordict root.", - category=DeprecationWarning, - ) - return tensorclass_true(*args, **kwargs) - - -@wraps(is_tensorclass_true) -def is_tensorclass(*args, **kwargs): # noqa: D103 - warnings.warn( - "is_tensorclass is not a prototype anymore and can be imported directly from tensordict root.", - category=DeprecationWarning, - ) - return is_tensorclass_true(*args, **kwargs) diff --git a/tensordict/utils.py b/tensordict/utils.py index 6a1ff2db7..554dbecd3 100644 --- a/tensordict/utils.py +++ b/tensordict/utils.py @@ -715,7 +715,7 @@ def _get_item(tensor: Tensor, index: IndexType) -> Tensor: if index.dtype is torch.bool: warnings.warn( "Indexing a tensor with a nested list of boolean values is " - "going to be deprecated as this functionality is not supported " + "going to be deprecated in v0.6 as this functionality is not supported " f"by PyTorch. (follows error: {err})", category=DeprecationWarning, ) diff --git a/tutorials/sphinx_tuto/tensorclass_fashion.py b/tutorials/sphinx_tuto/tensorclass_fashion.py index b69d4a60c..bfcd6265b 100644 --- a/tutorials/sphinx_tuto/tensorclass_fashion.py +++ b/tutorials/sphinx_tuto/tensorclass_fashion.py @@ -16,8 +16,7 @@ import torch import torch.nn as nn -from tensordict import MemoryMappedTensor -from tensordict.prototype import tensorclass +from tensordict import MemoryMappedTensor, tensorclass from torch.utils.data import DataLoader from torchvision import datasets from torchvision.transforms import ToTensor diff --git a/tutorials/sphinx_tuto/tensorclass_imagenet.py b/tutorials/sphinx_tuto/tensorclass_imagenet.py index 5899748f1..ba3023189 100644 --- a/tutorials/sphinx_tuto/tensorclass_imagenet.py +++ b/tutorials/sphinx_tuto/tensorclass_imagenet.py @@ -37,8 +37,7 @@ import torch.nn as nn import tqdm -from tensordict import MemoryMappedTensor -from tensordict.prototype import tensorclass +from tensordict import MemoryMappedTensor, tensorclass from tensordict.utils import strtobool from torch.utils.data import DataLoader from torchvision import datasets, transforms diff --git a/version.txt b/version.txt index 1d0ba9ea1..8f0916f76 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.4.0 +0.5.0