Skip to content

Commit 7f4eeba

Browse files
authored
Fix issue handling function with decorator
Differential Revision: D82132556 Pull Request resolved: #1111
1 parent 456bde8 commit 7f4eeba

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

torchx/specs/finder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ def _get_path_to_function_decl(
287287
my_component defined in some_file.py, imported in other_file.py
288288
and the component is invoked as other_file.py:my_component
289289
"""
290-
path_to_function_decl = inspect.getabsfile(function)
290+
# Unwrap decorated functions to get the original function
291+
unwrapped_function = inspect.unwrap(function)
292+
path_to_function_decl = inspect.getabsfile(unwrapped_function)
291293
if path_to_function_decl is None or not os.path.isfile(path_to_function_decl):
292294
return self._filepath
293295
return path_to_function_decl

0 commit comments

Comments
 (0)