add a wrap_decorator decorator to keep the __doc__ attr #45773
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
Others
Describe
try to fix the missing docstring of paddle.jit.save, the details describe in PaddlePaddle/docs#5243 (comment)
目前通过
paddle.jit.save.__doc__
无法获取到 docstring,原因是装饰器没有传递内层函数的__doc__
属性Paddle/python/paddle/fluid/dygraph/jit.py
Lines 682 to 687 in fd56f08
其中
switch_to_static_graph
已经使用wrap_decorator
装饰过,因此不会造成__doc__
等属性的丢失,而_run_save_pre_hooks
没有,因此使用wrap_decorator
装饰下,尝试下效果