Skip to content

Commit 16cefac

Browse files
fix __file__ value inside components
Differential Revision: D73793210 Pull Request resolved: #1056
1 parent 4345ef9 commit 16cefac

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

torchx/specs/finder.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# pyre-strict
88

99
import abc
10+
import copy
1011
import importlib
1112
import inspect
1213
import logging
@@ -281,7 +282,9 @@ def find(
281282
)
282283

283284
file_source = read_conf_file(self._filepath)
284-
namespace = globals()
285+
namespace = copy.copy(globals())
286+
# so that __file__ used inside the component points to the correct file
287+
namespace["__file__"] = os.path.abspath(self._filepath)
285288
exec(file_source, namespace) # noqa: P204
286289
if self._function_name not in namespace:
287290
raise ComponentNotFoundException(

0 commit comments

Comments
 (0)