-
Notifications
You must be signed in to change notification settings - Fork 130
fix __file__ value inside components #1056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix __file__ value inside components #1056
Conversation
ce3bea9
to
c5a1bf9
Compare
This pull request was exported from Phabricator. Differential Revision: D73793210 |
c5a1bf9
to
099d3e8
Compare
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. Reviewed By: crassirostris Differential Revision: D73793210
099d3e8
to
1ecedf7
Compare
This pull request was exported from Phabricator. Differential Revision: D73793210 |
Summary: Pull Request resolved: pytorch#1056 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. Reviewed By: crassirostris Differential Revision: D73793210
1ecedf7
to
5cb116c
Compare
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. Reviewed By: crassirostris Differential Revision: D73793210
5cb116c
to
3b8a7ed
Compare
Summary: Pull Request resolved: pytorch#1056 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. Reviewed By: crassirostris Differential Revision: D73793210
This pull request was exported from Phabricator. Differential Revision: D73793210 |
3b8a7ed
to
250790a
Compare
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) |
There was a problem hiding this comment.
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)
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