kartothek.utils.migration_helpers module

kartothek.utils.migration_helpers.deprecate_parameters(warning: str, *parameters: str)Callable[source]

Decorator, raising warnings that specified parameters of the decorated function are deprecated and will be removed or changed in the future.

Note

Please only use this decorator before other decorators preserving the function __name__ and __signature__. And note, that the correct call origin can not be returned if this decorator is nested inside others. If you absolutely have to use it with other decorators, best add it last.

..note:: You may stack deprecate_parameters and deprecate_parameters_if_set decorators interchanigibly.

Examples

>>> from kartothek.utils.migration_helpers import deprecate_parameters
>>> message = 'Parameter {parameter} is deprecated due to reason X!'
>>> message2 = 'Parameter {parameter} is deprecated due to reason Y!'
>>> @deprecate_parameters(message, 'param1', 'param2')
... @deprecate_parameters(message2, 'param4')
... def func(param1: str, param2: int, param3: float, param4: float):
...    return param1, param2, param3, param4
...
>>> # Warnings will be generated for `param1`, `param2` and `param4` with a different message
>>> func('example', 0, 5.0, 10.0)
('example', 0, 5.0, 10.0)
Parameters
  • warning (str) – Warning, the DeprecationWarnings will be raised with. Please make sure to include the substring ‘{parameter}’ that will be replaced by the parameter name in the warning.

  • *parameters (Tuple [str]) – Tuple of strings denoting the parameters to be marked deprecated.

Raises
  • DeprecationWarning – One deprecation warning per parameter containing the formatted passed warning string.

  • ValueError – If the validation routines in plave for the decorator are not passed. Possible issues: No param specified; Duplicate param definition; Declared param does not match underlying function signature.

kartothek.utils.migration_helpers.deprecate_parameters_if_set(warning, *parameters: str)Callable[source]

Decorator, raising warnings that specified parameters of the decorated function are deprecated and will be removed or changed in the future. This warning is only raised for optional parameters, if the parameter is actually set when called in order to avoid confusion and limit the users visibility of the change process they are not affected by.

Note

Please only use this decorator before other decorators preserving the function __name__ and __signature__. And note, that the correct call origin can not be returned if this decorator is nested inside others. If you absolutely have to use it with other decorators, best add it last.

Note

Do not decorate parameters hiding behind *args or **kwargs!

..note:: You may stack deprecate_parameters and deprecate_parameters_if_set decorators interchanigibly.

Examples

>>> from kartothek.utils.migration_helpers import deprecate_parameters_if_set
>>> message = 'Parameter {parameter} is deprecated due to reason X!'
>>> message2 = 'Parameter {parameter} is deprecated due to reason Y!'
>>> @deprecate_parameters_if_set(message, 'param2', 'param3')
... @deprecate_parameters_if_set(message2, 'param4')
... def func(param1: str, param2: int, param3: float=None, param4: float=None):
...     return param1, param2, param3, param4
...
>>> # Deprecation warnings for parameters: `param2` and `param3`. No warning for `param4` since `param4` has not
>>> # been specified in the function call.
>>> func('example', 0, param3=5.0)
('example', 0, 5.0, None)
Parameters
  • warning (str) – Warning, the DeprecationWarnings will be raised with. Please make sure to include the substring ‘{parameter}’ that will be replaced by the parameter name in the warning.

  • *parameters (str) – Tuple of strings denoting the parameters to be marked deprecated.

Raises
  • DeprecationWarning – One deprecation warning per set parameter containing the formatted passed warning string.

  • ValueError – If the validation routines in place for the decorator are not passed. Possible issues: 1) No param specified; 2) Duplicate param definition; 3) Declared param does not match underlying function signature.

kartothek.utils.migration_helpers.get_deprecation_warning_parameter_non_optional(deprecated_in: str, changed_in: str)str[source]
kartothek.utils.migration_helpers.get_deprecation_warning_remove_dict_multi_table(deprecated_in: str, changed_in: str)str[source]
kartothek.utils.migration_helpers.get_deprecation_warning_remove_parameter_multi_table(deprecated_in: str, removed_in: str)str[source]
kartothek.utils.migration_helpers.get_generic_function_deprecation_waring(function_name: str)str[source]
kartothek.utils.migration_helpers.get_parameter_default_value_deprecation_warning(from_value: str, to_value: str, deprecated_in: str, changed_in: str)str[source]
kartothek.utils.migration_helpers.get_parameter_generic_replacement_deprecation_warning(replacing_parameter: str, deprecated_in: str, changed_in: str)str[source]
kartothek.utils.migration_helpers.get_parameter_replaced_by_deprecation_warning(replaced_by: str, deprecated_in: str, changed_in: str)str[source]
kartothek.utils.migration_helpers.get_parameter_type_change_deprecation_warning(from_type: str, to_type: str, deprecated_in: str, changed_in: str)str[source]
kartothek.utils.migration_helpers.get_specific_function_deprecation_warning(function_name: str, deprecated_in: str, removed_in: Optional[str] = None, reason: Optional[str] = None)[source]
kartothek.utils.migration_helpers.get_specific_function_deprecation_warning_multi_table(function_name: str, deprecated_in: str, removed_in: Optional[str] = None)[source]
kartothek.utils.migration_helpers.raise_warning(parameter: str, warning: str, func_name: str, stacklevel: int)None[source]