Skip to content

Commit e3dd460

Browse files
craymichaelfacebook-github-bot
authored andcommitted
Make Captum log_usage universal by supporting async functions (#1614)
Summary: Pull Request resolved: #1614 As title. Checks if function being wrapped is a coroutine and uses an async wrapper instead of sync when logging. Reviewed By: vivekmig Differential Revision: D76837949
1 parent ce452a2 commit e3dd460

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

captum/log/dummy_log.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,8 @@ def log_usage(*log_args: Any, **log_kwargs: Any):
3232
# pyre-fixme[3]: Return type must be annotated.
3333
# pyre-fixme[2]: Parameter must be annotated.
3434
def _log_usage(func):
35-
@wraps(func)
36-
# pyre-fixme[53]: Captured variable `func` is not annotated.
37-
# pyre-fixme[3]: Return type must be annotated.
38-
def wrapper(*args: Any, **kwargs: Any):
39-
return func(*args, **kwargs)
40-
41-
return wrapper
35+
# Apply functools.wraps decorator so func has `__wrapped__` attribute
36+
return wraps(func)(func)
4237

4338
return _log_usage
4439

0 commit comments

Comments
 (0)