-
Notifications
You must be signed in to change notification settings - Fork 968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 [Feature] Add deprecated Decorator #3161
base: main
Are you sure you want to change the base?
Conversation
Maybe not relevant, but Python added its own |
Hello @BenjaminBossan, thank you for the insightful review! I wasn’t aware of the That said, the name overlap could indeed be confusing. Would using an alternative name for the decorator help clarify things? I’d be glad to make adjustments if needed! |
As to the Python version, 3.8 is going to be end of life by the end of the month, so the containers will be updated soon. Still, it will be quite some time before 3.13 will be the lowest supported Python version, so we can't assume that the decorator exists. More importantly, I wonder if we can "borrow" some of the implementation details of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I think what I'd like to see done here is we keep the same namings, and if we are on the upper-bound python version that has it (3.13), we use that one instead. How does that sound? Otherwise this looks good to me
(Sorry it took a bit to get to this PR!)
Thank you for your feedback, I agree with your suggestions regarding naming and compatibility! Using Python’s I’ve resolved the conflicts in the code for now, and I’ll be sure to apply any further adjustments based on additional feedback. Thanks again! |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. I only have a nit left, no blocker.
Using Python’s warnings.deprecated decorator in 3.13 and above, while defaulting to our custom decorator in lower versions
I don't think we really need to switch over come Python 3.13, since the Python decorator works quite differently from this one.
removed_in (`str`): | ||
The version when the function will be removed. | ||
instructions (`str`): | ||
The action users should take. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit: I'd find it more intuitive if the instructions
was renamed instruction
and if the "Please "
was not added in front, as I would assume as a caller that I need to pass a full sentence here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi folks, Could we consider using the implementation from |
@matthewdouglas AFAICT, that implementation is a backport of |
What does this PR do?
Summary
This PR introduces a
deprecated
decorator, designed to mark functions as deprecated with detailed warnings, following the approach in torch/onnx/_deprecation.py. The decorator provides a standard way to issue deprecation warnings and update docstrings, informing users of the version when a function was deprecated, its removal target, and recommended alternative actions.Changes
deprecated
decorator: Adds a decorator that marks functions as deprecated, integrates a warning when the function is called, and updates docstrings accordingly.FindTiedParametersResult
: Applied thedeprecated
decorator to thevalues
method in theFindTiedParametersResult
class, signaling to users that this method will be removed in Accelerate v1.3.0 and suggesting alternative approaches.Example Usage
After this PR, the following usage:
will produce output similar to:
Testing
Included a test for
deprecated
to validate: