Skip to content

[ONNX] Modernize python syntax#77935

Closed
justinchuby wants to merge 2 commits intopytorch:masterfrom
justinchuby:chuby/upgrade-py
Closed

[ONNX] Modernize python syntax#77935
justinchuby wants to merge 2 commits intopytorch:masterfrom
justinchuby:chuby/upgrade-py

Conversation

@justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented May 20, 2022

Use pyupgrade(https://github.com/asottile/pyupgrade) and flynt to modernize python syntax

pyupgrade --py36-plus --keep-runtime-typing torch/onnx/**/*.py
pyupgrade --py36-plus --keep-runtime-typing test/onnx/**/*.py
flynt torch/onnx/ --line-length 120
  • Use f-strings for string formatting
  • Use the new super() syntax for class initialization
  • Use dictionary / set comprehension

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented May 20, 2022

🔗 Helpful links

❌ 2 New Failures

As of commit 0f86899 (more details on the Dr. CI page):

Expand to see more
  • 2/2 failures introduced in this PR

🕵️ 2 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages

See GitHub Actions build pull / linux-bionic-rocm5.1-py3.7 / test (default, 2, 2, linux.rocm.gpu) (1/2)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-05-20T05:31:40.0948721Z FAIL [0.131s]: test_Conv2d_groups_nobias_v2 (__main__.TestNN)
2022-05-20T05:31:39.9969254Z   test_xavier_normal (__main__.TestNNInit) ... ok (0.470s)
2022-05-20T05:31:39.9980334Z   test_xavier_normal_errors_on_inputs_smaller_than_2d (__main__.TestNNInit) ... ok (0.001s)
2022-05-20T05:31:40.0796988Z   test_xavier_uniform (__main__.TestNNInit) ... ok (0.081s)
2022-05-20T05:31:40.0807822Z   test_xavier_uniform_errors_on_inputs_smaller_than_2d (__main__.TestNNInit) ... ok (0.001s)
2022-05-20T05:31:40.0843677Z   test_load_state_dict_module_pre_hook (__main__.TestStateDictHooks) ... ok (0.003s)
2022-05-20T05:31:40.0880543Z   test_load_state_dict_post_hook (__main__.TestStateDictHooks) ... ok (0.004s)
2022-05-20T05:31:40.0916719Z   test_load_state_dict_post_hook_backward_compatibility (__main__.TestStateDictHooks) ... ok (0.004s)
2022-05-20T05:31:40.0946951Z   test_load_state_dict_pre_hook (__main__.TestStateDictHooks) ... ok (0.003s)
2022-05-20T05:31:40.0947613Z 
2022-05-20T05:31:40.0947924Z ======================================================================
2022-05-20T05:31:40.0948721Z FAIL [0.131s]: test_Conv2d_groups_nobias_v2 (__main__.TestNN)
2022-05-20T05:31:40.0951065Z ----------------------------------------------------------------------
2022-05-20T05:31:40.0951927Z Traceback (most recent call last):
2022-05-20T05:31:40.0952771Z   File "test_nn.py", line 6900, in test_Conv2d_groups_nobias_v2
2022-05-20T05:31:40.0958230Z     self.assertEqual(output, torch.cat([output1, output2], 1))
2022-05-20T05:31:40.0960469Z   File "/opt/conda/lib/python3.7/site-packages/torch/testing/_internal/common_utils.py", line 2261, in assertEqual
2022-05-20T05:31:40.0961565Z     msg=msg,
2022-05-20T05:31:40.0962838Z   File "/opt/conda/lib/python3.7/site-packages/torch/testing/_comparison.py", line 1086, in assert_equal
2022-05-20T05:31:40.0963824Z     raise error_metas[0].to_error()
2022-05-20T05:31:40.0964787Z AssertionError: Tensor-likes are not close!
2022-05-20T05:31:40.0965281Z 

See GitHub Actions build pull / linux-bionic-rocm5.1-py3.7 / test (default, 1, 2, linux.rocm.gpu) (2/2)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-05-20T05:55:26.6525247Z RuntimeError: test_sparse_csr failed!
2022-05-20T05:55:23.1115055Z 
2022-05-20T05:55:23.1115345Z Generating XML reports...
2022-05-20T05:55:23.3779052Z Generated XML report: test-reports/python-unittest/test_sparse_csr/TEST-TestSparseCSRCUDA-20220520055449.xml
2022-05-20T05:55:23.3781252Z Generated XML report: test-reports/python-unittest/test_sparse_csr/TEST-TestSparseCSRSampler-20220520055449.xml
2022-05-20T05:55:23.4353734Z Generated XML report: test-reports/python-unittest/test_sparse_csr/TEST-TestSparseCompressedCUDA-20220520055449.xml
2022-05-20T05:55:26.6513551Z Traceback (most recent call last):
2022-05-20T05:55:26.6514051Z   File "test/run_test.py", line 1074, in <module>
2022-05-20T05:55:26.6518078Z     main()
2022-05-20T05:55:26.6518512Z   File "test/run_test.py", line 1052, in main
2022-05-20T05:55:26.6524707Z     raise RuntimeError(err_message)
2022-05-20T05:55:26.6525247Z RuntimeError: test_sparse_csr failed!
2022-05-20T05:55:28.6070060Z 
2022-05-20T05:55:28.6070936Z real	87m22.331s
2022-05-20T05:55:28.6071575Z user	101m20.976s
2022-05-20T05:55:28.6072127Z sys	11m48.768s
2022-05-20T05:55:28.6072677Z + cleanup
2022-05-20T05:55:28.6073236Z + retcode=1
2022-05-20T05:55:28.6073752Z + set +x
2022-05-20T05:55:28.6205228Z ##[error]Process completed with exit code 1.
2022-05-20T05:55:28.6281548Z ##[group]Run # copy test results back to the mounted workspace, needed sudo, resulting permissions were correct
2022-05-20T05:55:28.6282530Z �[36;1m# copy test results back to the mounted workspace, needed sudo, resulting permissions were correct�[0m

This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@justinchuby justinchuby added module: onnx Related to torch.onnx release notes: onnx torch.onnx related changes that should show up in the release notes topic: improvements topic category topic: not user facing topic category and removed cla signed labels May 20, 2022
@justinchuby justinchuby marked this pull request as ready for review May 20, 2022 03:14
Copy link
Collaborator

@BowenBao BowenBao left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! It'd be great if you could add in description the summary of the type of changes in this PR.

@justinchuby
Copy link
Collaborator Author

LGTM, thanks! It'd be great if you could add in description the summary of the type of changes in this PR.

Done

@justinchuby
Copy link
Collaborator Author

@pytorchbot merge this please

facebook-github-bot pushed a commit that referenced this pull request May 26, 2022
Summary:
Use pyupgrade(https://github.com/asottile/pyupgrade) and flynt to modernize python syntax

```sh
pyupgrade --py36-plus --keep-runtime-typing torch/onnx/**/*.py
pyupgrade --py36-plus --keep-runtime-typing test/onnx/**/*.py
flynt torch/onnx/ --line-length 120
```

- Use f-strings for string formatting
- Use the new `super()` syntax for class initialization
- Use dictionary / set comprehension

Pull Request resolved: #77935
Approved by: https://github.com/BowenBao

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/161e931156744acc384ce14e410d3d27d289109a

Reviewed By: mehtanirav

Differential Revision: D36668836

fbshipit-source-id: f115c34c039505ef2786c5e6c14d7294b0463982
justinchuby added a commit to justinchuby/pytorch that referenced this pull request Jul 27, 2022
Use pyupgrade(https://github.com/asottile/pyupgrade) and flynt to modernize python syntax

```sh
pyupgrade --py36-plus --keep-runtime-typing torch/onnx/**/*.py
pyupgrade --py36-plus --keep-runtime-typing test/onnx/**/*.py
flynt torch/onnx/ --line-length 120
```

- Use f-strings for string formatting
- Use the new `super()` syntax for class initialization
- Use dictionary / set comprehension
Pull Request resolved: pytorch#77935
Approved by: https://github.com/BowenBao
@justinchuby justinchuby deleted the chuby/upgrade-py branch August 2, 2022 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: onnx Related to torch.onnx open source release notes: onnx torch.onnx related changes that should show up in the release notes topic: improvements topic category topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants