Skip to content

Conversation

@driazati
Copy link
Contributor

@driazati driazati commented Jun 6, 2019

Keeping them in their own file lets us use Python3 syntax directly instead of going through the string frontend

This also deletes an assert added in #13250, cc @ezyang do you know why this check was added in the first place?

The test cases defined outside test_jit.py work fine with Python's unittest runner. Pytest doesn't find them though, so to use Pytest for those files you have to run the file directly instead of doing pytest test_jit.py

Differential Revision: D15704079

@pytorchbot pytorchbot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Jun 6, 2019
@pytorchbot pytorchbot added module: pybind Related to our Python bindings / interactions with other Python libraries module: tests Issues related to tests (not the torch.testing module) labels Jun 6, 2019
@driazati driazati changed the base branch from master to driazati/jitest June 6, 2019 21:28


@unittest.skipIf(PY2, "tuple printing in py2 is different than torchscript")
def test_string_print(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

This was deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

self.assertExpected(str(ast))

@unittest.skipIf(PY2, "Requires python 3")
def test_python_frontend_py3(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Also deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@unittest.skipIf(not PY35, "Python 3.5 needed")
def test_matmul_py3(self):
code = dedent("""
def fn(a, b):
Copy link
Contributor

Choose a reason for hiding this comment

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

Deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's moved, the _py3 was removed

pass


def check_test_defined_in_running_script(test_case):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this removed ?

Copy link
Contributor

@eellison eellison left a comment

Choose a reason for hiding this comment

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

Looks good but i think you need FBCode changes so the test runs internally

@ezyang
Copy link
Contributor

ezyang commented Jun 11, 2019

The assert exists because people sometimes imported test_foo from test_bar, and the net effect of this is that the foo tests run twice: once when we run test_foo.py, and then another time in test_bar.py. I'd prefer if you did not remove this assert, thanks!

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Please figure out why the assert was twinging.

facebook-github-bot pushed a commit that referenced this pull request Jun 12, 2019
Summary:
Class member annotations can be marked with `Final[T]` instead of adding them to `__constants__`. `Final` comes from the `typing_extensions` module (which will be used if it is present). If not, the polyfill from `_jit_internal` is exposed as `torch.jit.Final` for users that don't want to install `typing_extensions`.

This keeps around `__constants__` since a lot of code is still using it, but in documentation follow ups we should change the examples to all to use `Final`.

TODO: install typing_extensions on CI, move tests to a Python3 only file when #21489 lands
](https://our.intern.facebook.com/intern/diff/15746274/)
Pull Request resolved: #21603

Pulled By: driazati

Differential Revision: D15746274

fbshipit-source-id: d2c9b5643b4abba069b130c26fd42714c906ffac
@driazati driazati closed this Nov 6, 2019
@facebook-github-bot facebook-github-bot deleted the driazati/py3_tests branch July 13, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module: pybind Related to our Python bindings / interactions with other Python libraries module: tests Issues related to tests (not the torch.testing module) oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants