Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion torchx/specs/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# pyre-strict

import abc
import copy
import importlib
import inspect
import logging
Expand Down Expand Up @@ -281,7 +282,9 @@ def find(
)

file_source = read_conf_file(self._filepath)
namespace = globals()
namespace = copy.copy(globals())
# so that __file__ used inside the component points to the correct file
namespace["__file__"] = os.path.abspath(self._filepath)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be great to add a unittest assertion for this (either as a testcase or simply adding an assertion in an existing testcase here: https://github.com/pytorch/torchx/blob/main/torchx/specs/test/finder_test.py#L194)

exec(file_source, namespace) # noqa: P204
if self._function_name not in namespace:
raise ComponentNotFoundException(
Expand Down
Loading