@@ -50,6 +50,46 @@ def renamed_warning(phrase):
50
50
_warn (f"{ phrase } has been renamed" )
51
51
52
52
53
+ def deprecation_warn (name , date , msg = None ):
54
+ """Raise a warning for soon to be deprecated feature in sagemaker>=2
55
+
56
+ Args:
57
+ name (str): Name of the feature
58
+ date (str): the date when the feature will be deprecated
59
+ msg (str): the prefix phrase of the warning message.
60
+ """
61
+ _warn (f"{ name } will be deprecated on { date } .{ msg } " )
62
+
63
+
64
+ def deprecation_warning (date , msg = None ):
65
+ """Decorator for raising deprecation warning for a feature in sagemaker>=2
66
+
67
+ Args:
68
+ date (str): the date when the feature will be deprecated
69
+ msg (str): the prefix phrase of the warning message.
70
+
71
+ Usage:
72
+ @deprecation_warning(msg="message", date="date")
73
+ def sample_function():
74
+ print("xxxx....")
75
+
76
+ @deprecation_warning(msg="message", date="date")
77
+ class SampleClass():
78
+ def __init__(self):
79
+ print("xxxx....")
80
+
81
+ """
82
+
83
+ def deprecate (obj ):
84
+ def wrapper (* args , ** kwargs ):
85
+ deprecation_warn (obj .__name__ , date , msg )
86
+ return obj (* args , ** kwargs )
87
+
88
+ return wrapper
89
+
90
+ return deprecate
91
+
92
+
53
93
def renamed_kwargs (old_name , new_name , value , kwargs ):
54
94
"""Checks if the deprecated argument is in kwargs
55
95
@@ -106,6 +146,28 @@ def func(*args, **kwargs): # pylint: disable=W0613
106
146
return func
107
147
108
148
149
+ def deprecated (obj ):
150
+ """Decorator for raising deprecated warning for a feature in sagemaker>=2
151
+
152
+ Usage:
153
+ @deprecated
154
+ def sample_function():
155
+ print("xxxx....")
156
+
157
+ @deprecated
158
+ class SampleClass():
159
+ def __init__(self):
160
+ print("xxxx....")
161
+
162
+ """
163
+
164
+ def wrapper (* args , ** kwargs ):
165
+ removed_warning (obj .__name__ )
166
+ return obj (* args , ** kwargs )
167
+
168
+ return wrapper
169
+
170
+
109
171
def deprecated_function (func , name ):
110
172
"""Wrap a function with a deprecation warning.
111
173
0 commit comments