From 25f8363b97e4f1c525b5b8d61878a070d012538e Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 5 Oct 2021 12:20:13 -0700 Subject: [PATCH] Improved deprecation warnings. (#9347) This PR improves deprecation warnings. I fixed some typos to make it easier to grep for deprecations, and added the warning type `DeprecationWarning` where appropriate. (Found these issues while looking for examples of deprecations for #9291.) Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Vyas Ramasubramani (https://github.com/vyasr) - Ashwin Srinath (https://github.com/shwina) - GALI PREM SAGAR (https://github.com/galipremsagar) URL: https://github.com/rapidsai/cudf/pull/9347 --- python/cudf/cudf/core/column/string.py | 13 ++++++------- python/cudf/cudf/core/index.py | 2 +- python/cudf/cudf/core/multiindex.py | 4 ++-- python/cudf/cudf/core/series.py | 12 ++++++------ python/dask_cudf/dask_cudf/core.py | 8 ++++---- python/dask_cudf/dask_cudf/io/parquet.py | 3 ++- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/python/cudf/cudf/core/column/string.py b/python/cudf/cudf/core/column/string.py index 07dc8743c00..476709a76f8 100644 --- a/python/cudf/cudf/core/column/string.py +++ b/python/cudf/cudf/core/column/string.py @@ -4595,7 +4595,7 @@ def subword_tokenize( This function requires about 21x the number of character bytes in the input strings column as working memory. - ``ser.str.subword_tokenize`` will be depreciated in future versions. + ``Series.str.subword_tokenize`` is deprecated and will be removed. Use ``cudf.core.subword_tokenizer.SubwordTokenizer`` instead. Parameters @@ -4669,14 +4669,13 @@ def subword_tokenize( array([[0, 0, 2], [1, 0, 1]], dtype=uint32) """ - warning_message = ( - "`ser.str.subword_tokenize` API will be depreciated" - " in future versions of cudf.\n" - "Use `cudf.core.subword_tokenizer.SubwordTokenizer` " - "instead" + warnings.warn( + "`Series.str.subword_tokenize` is deprecated and will be removed " + "in future versions of cudf. Use " + "`cudf.core.subword_tokenizer.SubwordTokenizer` instead.", + FutureWarning, ) - warnings.warn(warning_message, FutureWarning) tokens, masks, metadata = libstrings.subword_tokenize_vocab_file( self._column, hash_file, diff --git a/python/cudf/cudf/core/index.py b/python/cudf/cudf/core/index.py index 8e5a19a1867..7adb01a03bf 100644 --- a/python/cudf/cudf/core/index.py +++ b/python/cudf/cudf/core/index.py @@ -609,7 +609,7 @@ def deserialize(cls, header, frames): "21.10 or older will no longer be deserializable " "after version 21.12. Please load and resave any " "pickles before upgrading to version 22.02.", - DeprecationWarning, + FutureWarning, ) header["columns"] = [header.pop("index_column")] header["column_names"] = pickle.dumps( diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index eb729eaf8f9..e1274dc7758 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -867,7 +867,7 @@ def deserialize(cls, header, frames): "21.10 or older will no longer be deserializable " "after version 21.12. Please load and resave any " "pickles before upgrading to version 22.02.", - DeprecationWarning, + FutureWarning, ) header["column_names"] = header["names"] column_names = pickle.loads(header["column_names"]) @@ -877,7 +877,7 @@ def deserialize(cls, header, frames): "21.08 or older will no longer be deserializable " "after version 21.10. Please load and resave any " "pickles before upgrading to version 21.12.", - DeprecationWarning, + FutureWarning, ) df = cudf.DataFrame.deserialize(header["source_data"], frames) return cls.from_frame(df)._set_names(column_names) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 590ac077e97..8188290c392 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -378,7 +378,7 @@ def deserialize(cls, header, frames): "21.10 or older will no longer be deserializable " "after version 21.12. Please load and resave any " "pickles before upgrading to version 22.02.", - DeprecationWarning, + FutureWarning, ) header["columns"] = [header.pop("column")] header["column_names"] = pickle.dumps( @@ -790,7 +790,7 @@ def to_frame(self, name=None): def set_mask(self, mask, null_count=None): warnings.warn( "Series.set_mask is deprecated and will be removed in the future.", - DeprecationWarning, + FutureWarning, ) return self._from_data( {self.name: self._column.set_mask(mask)}, self._index @@ -3171,7 +3171,7 @@ def update(self, other): def reverse(self): warnings.warn( "Series.reverse is deprecated and will be removed in the future.", - DeprecationWarning, + FutureWarning, ) rinds = column.arange((self._column.size - 1), -1, -1, dtype=np.int32) return self._from_data( @@ -3295,9 +3295,9 @@ def label_encoding(self, cats, dtype=None, na_sentinel=-1): """ warnings.warn( - "Series.label_encoding is deprecated and will be removed in the future.\ - Consider using cuML's LabelEncoder instead", - DeprecationWarning, + "Series.label_encoding is deprecated and will be removed in the " + "future. Consider using cuML's LabelEncoder instead.", + FutureWarning, ) def _return_sentinel_series(): diff --git a/python/dask_cudf/dask_cudf/core.py b/python/dask_cudf/dask_cudf/core.py index d8037cadd7c..5040646f9f1 100644 --- a/python/dask_cudf/dask_cudf/core.py +++ b/python/dask_cudf/dask_cudf/core.py @@ -298,16 +298,16 @@ def var( return _parallel_var(self, meta, skipna, split_every, out) def repartition(self, *args, **kwargs): - """ Wraps dask.dataframe DataFrame.repartition method. + """Wraps dask.dataframe DataFrame.repartition method. Uses DataFrame.shuffle if `columns=` is specified. """ # TODO: Remove this function in future(0.17 release) columns = kwargs.pop("columns", None) if columns: warnings.warn( - "The column argument will be removed from repartition in " - " future versions of dask_cudf. Use DataFrame.shuffle().", - DeprecationWarning, + "The columns argument will be removed from repartition in " + "future versions of dask_cudf. Use DataFrame.shuffle().", + FutureWarning, ) warnings.warn( "Rearranging data by column hash. Divisions will lost. " diff --git a/python/dask_cudf/dask_cudf/io/parquet.py b/python/dask_cudf/dask_cudf/io/parquet.py index f5224681a1e..c82ed5bc375 100644 --- a/python/dask_cudf/dask_cudf/io/parquet.py +++ b/python/dask_cudf/dask_cudf/io/parquet.py @@ -371,7 +371,8 @@ def read_parquet( if row_groups_per_part: warnings.warn( "row_groups_per_part is deprecated. " - "Pass an integer value to split_row_groups instead." + "Pass an integer value to split_row_groups instead.", + FutureWarning, ) if split_row_groups is None: split_row_groups = row_groups_per_part