Skip to content

Commit ce3bea9

Browse files
Daniel Ohayonfacebook-github-bot
Daniel Ohayon
authored andcommitted
fix __file__ value inside components
Summary: Currently when we exec a component, we pass it the caller file's namespace. As a result, `__file__` resolves to `.../torchx/specs/finder.py` inside the compoennt at runtime, which is confusing. This fixes that. Differential Revision: D73793210
1 parent 41be1d8 commit ce3bea9

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

torchx/specs/finder.py

+2
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ def find(
282282

283283
file_source = read_conf_file(self._filepath)
284284
namespace = globals()
285+
# so that __file__ used inside the component points to the correct file
286+
namespace["__file__"] = self._filepath
285287
exec(file_source, namespace) # noqa: P204
286288
if self._function_name not in namespace:
287289
raise ComponentNotFoundException(

0 commit comments

Comments
 (0)