Commit Graph

4 Commits

Author SHA1 Message Date
Ralf Gommers
48ddc9762b Upgrade mypy to version 0.812 (#55712)
Summary:
Fixes https://github.com/pytorch/pytorch/issues/54211

This was a little more annoying than expected, because the `exclude = ` key in `mypy.ini` is weird. I'll file an upstream issue about that.

I ignored one file, `torch/distributed/elastic/agent/server/api.py` that had ~8 errors that were hard to figure out. This can be done in a follow-up.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/55712

Reviewed By: walterddr

Differential Revision: D27694976

Pulled By: malfet

fbshipit-source-id: 228d8be6af040343ce46595dabaca212e69ccc68
2021-04-12 18:08:28 -07:00
Philip Meier
255494c2aa torch.testing allclose -> close (#54781)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54781

Right now the functions have divergent names with one postfixed `_equal` and the other `_allclose`. I've opted to use `_(equal|close)` over `_all(equal|close)` think it is a reasonable assumption that all values need to be equal or close for this pass even without explicitly naming the function this way.

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D27438957

Pulled By: mruberry

fbshipit-source-id: 2951dac06d1430e15119ae94eafa234f3eb02f09
2021-04-10 13:35:38 -07:00
Philip Meier
c9b94a85e9 change torch.testing helper asserts to checks (#54780)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54780

- In #53152 we opted to use `tb=native`. Thus, regardless if we use `pytest` to run the tests `__tracebackhide__` is not honored. and additional layers of helper functions make the traceback harder to parse. To overcome this, we change the internal helpers to return `ok: bool, msg: Optional[str]` and only raise the error in the top level function. We do that already in the current implementation that we are trying to replace:
    36ce673f16/torch/testing/__init__.py (L92-L93)
    36ce673f16/torch/testing/__init__.py (L112)

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D27438849

Pulled By: mruberry

fbshipit-source-id: 3e7a33dabb45463c29e8b9736fad09efb523f18d
2021-04-10 13:12:09 -07:00
Philip Meier
f4967d68f5 make torch.testing asserts importable (#54769)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/54769

Follow-up to #53820. This

- makes the `asserts.py` module private as per suggestion from rgommers in https://github.com/pytorch/pytorch/pull/53820#issuecomment-802661387. With this the functions should only be accessible through `torch.testing`, giving us the option the change the underlying structure later.
- moves the code from `torch/testing/__init__.py` to `torch/testing/_core.py` (happy to accept other name suggestions). Otherwise we can't import the new `_asserts.py` in `torch/testing/__init__.py` due to circular imports.

Test Plan: Imported from OSS

Reviewed By: mrshenli

Differential Revision: D27438451

Pulled By: mruberry

fbshipit-source-id: c7292b4d5709185b42b4aac8016648562688040e
2021-04-07 23:53:02 -07:00