Skip to content

Commit

Permalink
[2.1 API] Enable printing deprecated warning info. (PaddlePaddle#32712)
Browse files Browse the repository at this point in the history
* Add deprecated warning info.

* Add unittest for deprecated decorator.

* Add warning info for tensor.grad
  • Loading branch information
xiemoyuan committed May 6, 2021
1 parent 0bb079c commit e1425c1
Show file tree
Hide file tree
Showing 16 changed files with 130 additions and 14 deletions.
5 changes: 5 additions & 0 deletions python/paddle/dataset/cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Cifar100",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train100():
"""
Expand All @@ -98,6 +99,7 @@ def train100():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Cifar100",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test100():
"""
Expand All @@ -117,6 +119,7 @@ def test100():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Cifar10",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train10(cycle=False):
"""
Expand All @@ -139,6 +142,7 @@ def train10(cycle=False):
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Cifar10",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test10(cycle=False):
"""
Expand All @@ -161,6 +165,7 @@ def test10(cycle=False):
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Cifar10",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(CIFAR10_URL, 'cifar', CIFAR10_MD5)
Expand Down
4 changes: 4 additions & 0 deletions python/paddle/dataset/conll05.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Conll05st",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def get_dict():
"""
Expand All @@ -223,6 +224,7 @@ def get_dict():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Conll05st",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def get_embedding():
"""
Expand All @@ -234,6 +236,7 @@ def get_embedding():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Conll05st",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test():
"""
Expand All @@ -258,6 +261,7 @@ def test():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Conll05st",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(WORDDICT_URL, 'conll05st', WORDDICT_MD5)
Expand Down
3 changes: 3 additions & 0 deletions python/paddle/dataset/flowers.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Flowers",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train(mapper=train_mapper, buffered_size=1024, use_xmap=True, cycle=False):
'''
Expand Down Expand Up @@ -189,6 +190,7 @@ def train(mapper=train_mapper, buffered_size=1024, use_xmap=True, cycle=False):
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Flowers",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test(mapper=test_mapper, buffered_size=1024, use_xmap=True, cycle=False):
'''
Expand Down Expand Up @@ -222,6 +224,7 @@ def test(mapper=test_mapper, buffered_size=1024, use_xmap=True, cycle=False):
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.Flowers",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def valid(mapper=test_mapper, buffered_size=1024, use_xmap=True):
'''
Expand Down
5 changes: 5 additions & 0 deletions python/paddle/dataset/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def build_dict(pattern, cutoff):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imdb",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def reader_creator(pos_pattern, neg_pattern, word_idx):
UNK = word_idx['<unk>']
Expand All @@ -102,6 +103,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imdb",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train(word_idx):
"""
Expand All @@ -123,6 +125,7 @@ def train(word_idx):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imdb",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test(word_idx):
"""
Expand All @@ -144,6 +147,7 @@ def test(word_idx):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imdb",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def word_dict():
"""
Expand All @@ -159,6 +163,7 @@ def word_dict():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imdb",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(URL, 'imdb', MD5)
3 changes: 3 additions & 0 deletions python/paddle/dataset/imikolov.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imikolov",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train(word_idx, n, data_type=DataType.NGRAM):
"""
Expand All @@ -139,6 +140,7 @@ def train(word_idx, n, data_type=DataType.NGRAM):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imikolov",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test(word_idx, n, data_type=DataType.NGRAM):
"""
Expand All @@ -163,6 +165,7 @@ def test(word_idx, n, data_type=DataType.NGRAM):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Imikolov",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(URL, "imikolov", MD5)
3 changes: 3 additions & 0 deletions python/paddle/dataset/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.MNIST",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train():
"""
Expand All @@ -114,6 +115,7 @@ def train():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.MNIST",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test():
"""
Expand All @@ -134,6 +136,7 @@ def test():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.MNIST",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(TRAIN_IMAGE_URL, 'mnist', TRAIN_IMAGE_MD5)
Expand Down
9 changes: 9 additions & 0 deletions python/paddle/dataset/movielens.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __reader__(rand_seed=0, test_ratio=0.1, is_test=False):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def __reader_creator__(**kwargs):
return lambda: __reader__(**kwargs)
Expand All @@ -180,6 +181,7 @@ def __reader_creator__(**kwargs):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def get_movie_title_dict():
"""
Expand All @@ -199,6 +201,7 @@ def __max_index_info__(a, b):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def max_movie_id():
"""
Expand All @@ -211,6 +214,7 @@ def max_movie_id():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def max_user_id():
"""
Expand All @@ -230,6 +234,7 @@ def __max_job_id_impl__(a, b):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def max_job_id():
"""
Expand All @@ -243,6 +248,7 @@ def max_job_id():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def movie_categories():
"""
Expand All @@ -255,6 +261,7 @@ def movie_categories():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def user_info():
"""
Expand All @@ -267,6 +274,7 @@ def user_info():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def movie_info():
"""
Expand All @@ -288,6 +296,7 @@ def unittest():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.Movielens",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(URL, "movielens", MD5)
Expand Down
4 changes: 4 additions & 0 deletions python/paddle/dataset/uci_housing.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def load_data(filename, feature_num=14, ratio=0.8):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.UCIHousing",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train():
"""
Expand All @@ -111,6 +112,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.UCIHousing",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test():
"""
Expand Down Expand Up @@ -146,6 +148,7 @@ def fluid_model():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.UCIHousing",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def predict_reader():
"""
Expand All @@ -162,6 +165,7 @@ def predict_reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.UCIHousing",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(URL, 'uci_housing', MD5)
3 changes: 3 additions & 0 deletions python/paddle/dataset/voc2012.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.VOC2012",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train():
"""
Expand All @@ -80,6 +81,7 @@ def train():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.VOC2012",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test():
"""
Expand All @@ -91,6 +93,7 @@ def test():
@deprecated(
since="2.0.0",
update_to="paddle.vision.datasets.VOC2012",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def val():
"""
Expand Down
5 changes: 5 additions & 0 deletions python/paddle/dataset/wmt14.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT14",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train(dict_size):
"""
Expand All @@ -134,6 +135,7 @@ def train(dict_size):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT14",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test(dict_size):
"""
Expand All @@ -154,6 +156,7 @@ def test(dict_size):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT14",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def gen(dict_size):
return reader_creator(
Expand All @@ -164,6 +167,7 @@ def gen(dict_size):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT14",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def get_dict(dict_size, reverse=True):
# if reverse = False, return dict = {'a':'001', 'b':'002', ...}
Expand All @@ -179,6 +183,7 @@ def get_dict(dict_size, reverse=True):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT14",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
paddle.dataset.common.download(URL_TRAIN, 'wmt14', MD5_TRAIN)
Expand Down
5 changes: 5 additions & 0 deletions python/paddle/dataset/wmt16.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ def reader():
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT16",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def train(src_dict_size, trg_dict_size, src_lang="en"):
"""
Expand Down Expand Up @@ -195,6 +196,7 @@ def train(src_dict_size, trg_dict_size, src_lang="en"):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT16",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def test(src_dict_size, trg_dict_size, src_lang="en"):
"""
Expand Down Expand Up @@ -248,6 +250,7 @@ def test(src_dict_size, trg_dict_size, src_lang="en"):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT16",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def validation(src_dict_size, trg_dict_size, src_lang="en"):
"""
Expand Down Expand Up @@ -299,6 +302,7 @@ def validation(src_dict_size, trg_dict_size, src_lang="en"):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT16",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def get_dict(lang, dict_size, reverse=False):
"""
Expand Down Expand Up @@ -333,6 +337,7 @@ def get_dict(lang, dict_size, reverse=False):
@deprecated(
since="2.0.0",
update_to="paddle.text.datasets.WMT16",
level=1,
reason="Please use new dataset API which supports paddle.io.DataLoader")
def fetch():
"""download the entire dataset.
Expand Down
Loading

0 comments on commit e1425c1

Please sign in to comment.