-
Notifications
You must be signed in to change notification settings - Fork 25.7k
introduce TestingErrorMeta for internal use #58917
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
Conversation
In #54780 we opted to return `Optional[Exception]` from all internal helper functions. Since then multiple PRs added functionality that needs to amend the error message. For this we recreate the error https://github.com/pytorch/pytorch/blob/09a1b1cf87fb8724e644693f2c00318ed2637095/torch/testing/_asserts.py#L417-L430 To untangle this a little, this PR introduces the `_TestingErrorMeta`, which carries the exception type and the message. The idiom ```python exc = check_foo(): if exc: return exc ``` is still valid although `exc` should be renamed to `error_meta` to reflect the new nature. In the top-level functions `assert_(equal|close)` ```python exc = check_foo(): if exc: raise exc ``` changes to ```python error_meta = check_foo(): if error_meta: raise error_meta.to_error() ``` [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit d1cbf1b (more details on the Dr. CI page and at hud.pytorch.org/pr/58917):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
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.
OK
In #54780 we opted to return `Optional[Exception]` from all internal helper functions. Since then multiple PRs added functionality that needs to amend the error message. For this we recreate the error https://github.com/pytorch/pytorch/blob/09a1b1cf87fb8724e644693f2c00318ed2637095/torch/testing/_asserts.py#L417-L430 To untangle this a little, this PR introduces the `_TestingErrorMeta`, which carries the exception type and the message. The idiom ```python exc = check_foo(): if exc: return exc ``` is still valid although `exc` should be renamed to `error_meta` to reflect the new nature. In the top-level functions `assert_(equal|close)` ```python exc = check_foo(): if exc: raise exc ``` changes to ```python error_meta = check_foo(): if error_meta: raise error_meta.to_error() ``` [ghstack-poisoned]
In #54780 we opted to return `Optional[Exception]` from all internal helper functions. Since then multiple PRs added functionality that needs to amend the error message. For this we recreate the error https://github.com/pytorch/pytorch/blob/09a1b1cf87fb8724e644693f2c00318ed2637095/torch/testing/_asserts.py#L417-L430 To untangle this a little, this PR introduces the `_TestingErrorMeta`, which carries the exception type and the message. The idiom ```python exc = check_foo(): if exc: return exc ``` is still valid although `exc` should be renamed to `error_meta` to reflect the new nature. In the top-level functions `assert_(equal|close)` ```python exc = check_foo(): if exc: raise exc ``` changes to ```python error_meta = check_foo(): if error_meta: raise error_meta.to_error() ``` [ghstack-poisoned]
In #54780 we opted to return `Optional[Exception]` from all internal helper functions. Since then multiple PRs added functionality that needs to amend the error message. For this we recreate the error https://github.com/pytorch/pytorch/blob/09a1b1cf87fb8724e644693f2c00318ed2637095/torch/testing/_asserts.py#L417-L430 To untangle this a little, this PR introduces the `_TestingErrorMeta`, which carries the exception type and the message. The idiom ```python exc = check_foo(): if exc: return exc ``` is still valid although `exc` should be renamed to `error_meta` to reflect the new nature. In the top-level functions `assert_(equal|close)` ```python exc = check_foo(): if exc: raise exc ``` changes to ```python error_meta = check_foo(): if error_meta: raise error_meta.to_error() ``` [ghstack-poisoned]
|
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Stack from ghstack:
msgintorch.testing.assert_close#60254 tests for diagnostics in callablemsgintorch.testing.assert_closetorch.testing.assert_close#60163 update docstring examples oftorch.testing.assert_closetorch.testing.assert_closein case of mismatching values #60091 Improve error messages oftorch.testing.assert_closein case of mismatching valuestorch.testing.assert_close#58918 make assert_equal an example how to partialtorch.testing.assert_closeIn #54780 we opted to return
Optional[Exception]from all internalhelper functions. Since then multiple PRs added functionality that needs
to amend the error message. For this we recreate the error
pytorch/torch/testing/_asserts.py
Lines 417 to 430 in 09a1b1c
To untangle this a little, this PR introduces the
_TestingErrorMeta,which carries the exception type and the message. The idiom
is still valid although
excshould be renamed toerror_metatoreflect the new nature. In the top-level functions
assert_(equal|close)changes to
Differential Revision: D29259405