Deprecate
deprecate_param(deprecated_param_name, new_param_name='', deprecated_since='', removed_from='', reason='')
Utility function to warn about a deprecated parameter (or dictionary key).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deprecated_param_name |
str
|
Name of the deprecated parameter. |
required |
new_param_name |
str
|
Name of the new parameter/key that should replace the deprecated one. |
''
|
deprecated_since |
str
|
Version number when the parameter was deprecated. |
''
|
removed_from |
str
|
Version number when the parameter will be removed. |
''
|
reason |
str
|
Additional information or reason for the deprecation. |
''
|
Source code in latest/src/super_gradients/common/deprecate.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
deprecated(deprecated_since, removed_from, target=None, reason='')
Decorator to mark a callable as deprecated. Works on functions and classes. It provides a clear and actionable warning message informing the user about the version in which the function was deprecated, the version in which it will be removed, and guidance on how to replace it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deprecated_since |
str
|
Version number when the function was deprecated. |
required |
removed_from |
str
|
Version number when the function will be removed. |
required |
target |
Optional[callable]
|
(Optional) The new function that should be used as a replacement. If provided, it will guide the user to the updated function. |
None
|
reason |
str
|
(Optional) Additional information or reason for the deprecation. Example usage: If a direct replacement function exists: >> from new.module.path import new_get_local_rank >> @deprecated(deprecated_since='3.2.0', removed_from='4.0.0', target=new_get_local_rank, reason="Replaced for optimization") >> def get_local_rank(): >> return new_get_local_rank() If there's no direct replacement: >> @deprecated(deprecated_since='3.2.0', removed_from='4.0.0', reason="Function is no longer needed due to XYZ reason") >> def some_old_function(): >> # ... function logic ... When calling a deprecated function: >> from some_module import get_local_rank >> get_local_rank() DeprecationWarning: Function |
''
|
Source code in latest/src/super_gradients/common/deprecate.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
deprecated_parameter(parameter_name, deprecated_since, removed_from, target=None, reason='')
Decorator to mark a parameter of a callable as deprecated. It provides a clear and actionable warning message informing the user about the version in which parameter was deprecated, the version in which it will be removed, and guidance on how to replace it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameter_name |
str
|
Name of the parameter |
required |
deprecated_since |
str
|
Version number when the function was deprecated. |
required |
removed_from |
str
|
Version number when the function will be removed. |
required |
target |
Optional[callable]
|
(Optional) The new function that should be used as a replacement. If provided, it will guide the user to the updated function. |
None
|
reason |
str
|
(Optional) Additional information or reason for the deprecation. Example usage: If a parameter removed with no replacement alternative: >>> @deprecated_parameter("c",deprecated_since='3.2.0', removed_from='4.0.0', reason="This argument is not used") >>> def do_some_work(a,b,c = None): >>> return a+b If a parameter has new name: >>> @deprecated_parameter("c", target="new_parameter", deprecated_since='3.2.0', removed_from='4.0.0', reason="This argument is not used") >>> def do_some_work(a,b,target,c = None): >>> return a+b+target |
''
|
Source code in latest/src/super_gradients/common/deprecate.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
deprecated_training_param(deprecated_tparam_name, deprecated_since, removed_from, new_arg_assigner, message='')
Decorator for deprecating training hyperparameters.
Recommended tp be used as a decorator on top of super_gradients.training.params.TrainingParams's override method:
class TrainingParams(HpmStruct):
def __init__(self, **entries):
# WE initialize by the default training params, overridden by the provided params
default_training_params = deepcopy(DEFAULT_TRAINING_PARAMS)
super().__init__(**default_training_params)
self.set_schema(TRAINING_PARAM_SCHEMA)
if len(entries) > 0:
self.override(**entries)
@deprecated_training_param( "criterion_params", "3.2.1", "3.3.0", new_arg_assigner=get_deprecated_nested_params_to_factory_format_assigner("loss", "criterion_params") ) def override(self, entries): super().override(entries) self.validate()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deprecated_tparam_name |
str
|
str, the name of the deprecated hyperparameter. |
required |
deprecated_since |
str
|
str, SG version of deprecation. |
required |
removed_from |
str
|
str, SG version of removal. |
required |
new_arg_assigner |
Callable
|
Callable, a handler to assign the deprecated parameter value to the updated hyperparameter entry. |
required |
message |
str
|
str, message to append to the deprecation warning (default="") |
''
|
Returns:
Type | Description |
---|---|
Source code in latest/src/super_gradients/common/deprecate.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|