Skip to content

Commit

Permalink
Improved deprecation warnings. (#9347)
Browse files Browse the repository at this point in the history
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: #9347
  • Loading branch information
bdice authored Oct 5, 2021
1 parent 88eefe5 commit 25f8363
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
13 changes: 6 additions & 7 deletions python/cudf/cudf/core/column/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/cudf/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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():
Expand Down
8 changes: 4 additions & 4 deletions python/dask_cudf/dask_cudf/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. "
Expand Down
3 changes: 2 additions & 1 deletion python/dask_cudf/dask_cudf/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 25f8363

Please sign in to comment.