From d64769c38e5ec60f1650e8b02ed7bdbd8c338291 Mon Sep 17 00:00:00 2001 From: Justin Chu Date: Wed, 27 Apr 2022 14:52:19 -0700 Subject: [PATCH] Set black's target version (#11370) Description: Set black's target version to be py37 - py310 Motivation and Context Black by default targets its format for py3.10. Since our project supports python 3.7, we need to target version to all the python versions supported. Re-ran black. 13 files reformatted. --- .../tools/quantization/operators/activation.py | 2 +- .../tools/quantization/operators/binary_op.py | 2 +- .../tools/quantization/operators/gavgpool.py | 2 +- .../tools/quantization/operators/pooling.py | 2 +- .../contrib_ops/onnx_contrib_ops_helper.py | 2 +- .../python/onnxruntime_test_ort_trainer.py | 4 ++-- .../transform/fusion/matmul_scale_gen.py | 2 +- .../eager/test_model/mnist_fc_training.py | 4 ++-- .../eager/test_models/mnist_fc_training.py | 4 ++-- .../python/orttraining_test_transformers.py | 18 +++++++++--------- .../mnist_training.py | 4 ++-- pyproject.toml | 1 + tools/ci_build/get_docker_image.py | 2 +- tools/python/util/run.py | 2 +- 14 files changed, 26 insertions(+), 25 deletions(-) diff --git a/onnxruntime/python/tools/quantization/operators/activation.py b/onnxruntime/python/tools/quantization/operators/activation.py index 3df1d1c631..ec2c2298e7 100644 --- a/onnxruntime/python/tools/quantization/operators/activation.py +++ b/onnxruntime/python/tools/quantization/operators/activation.py @@ -79,7 +79,7 @@ class QLinearActivation(QuantOperatorBase): qlinear_activation_inputs, [qlinear_activation_output], qlinear_activation_name, - **kwargs + **kwargs, ) # Create an entry for this quantized value diff --git a/onnxruntime/python/tools/quantization/operators/binary_op.py b/onnxruntime/python/tools/quantization/operators/binary_op.py index 7cfd69c204..f4c7c0fac7 100644 --- a/onnxruntime/python/tools/quantization/operators/binary_op.py +++ b/onnxruntime/python/tools/quantization/operators/binary_op.py @@ -55,7 +55,7 @@ class QLinearBinaryOp(QuantOperatorBase): qlinear_binary_math_inputs, [qlinear_binary_math_output], qlinear_binary_math_name, - **kwargs + **kwargs, ) nodes.append(qlinear_binary_math_node) diff --git a/onnxruntime/python/tools/quantization/operators/gavgpool.py b/onnxruntime/python/tools/quantization/operators/gavgpool.py index 7527685072..abb3187f56 100644 --- a/onnxruntime/python/tools/quantization/operators/gavgpool.py +++ b/onnxruntime/python/tools/quantization/operators/gavgpool.py @@ -57,6 +57,6 @@ class QGlobalAveragePool(QuantOperatorBase): ], [quantized_output_value.q_name], qnode_name, - **kwargs + **kwargs, ) self.quantizer.new_nodes += [qnode] diff --git a/onnxruntime/python/tools/quantization/operators/pooling.py b/onnxruntime/python/tools/quantization/operators/pooling.py index 6feb5faad9..e60a9a2fa5 100644 --- a/onnxruntime/python/tools/quantization/operators/pooling.py +++ b/onnxruntime/python/tools/quantization/operators/pooling.py @@ -59,7 +59,7 @@ class QLinearPool(QuantOperatorBase): ], [qlinear_output_name], qlinear_node_name, - **kwargs + **kwargs, ) # add all newly created nodes diff --git a/onnxruntime/test/python/contrib_ops/onnx_contrib_ops_helper.py b/onnxruntime/test/python/contrib_ops/onnx_contrib_ops_helper.py index 0003975d9c..521938b14b 100644 --- a/onnxruntime/test/python/contrib_ops/onnx_contrib_ops_helper.py +++ b/onnxruntime/test/python/contrib_ops/onnx_contrib_ops_helper.py @@ -51,7 +51,7 @@ def expect( inputs, outputs, name, - **kwargs + **kwargs, ): # type: (...) -> None present_inputs = [x for x in node.input if (x != "")] present_outputs = [x for x in node.output if (x != "")] diff --git a/onnxruntime/test/python/onnxruntime_test_ort_trainer.py b/onnxruntime/test/python/onnxruntime_test_ort_trainer.py index f269c53f2e..30e2dc62e1 100644 --- a/onnxruntime/test/python/onnxruntime_test_ort_trainer.py +++ b/onnxruntime/test/python/onnxruntime_test_ort_trainer.py @@ -374,7 +374,7 @@ class MNISTWrapper: ), batch_size=args_batch_size, shuffle=False, - **kwargs + **kwargs, ) test_loader = torch.utils.data.DataLoader( datasets.MNIST( @@ -384,7 +384,7 @@ class MNISTWrapper: ), batch_size=args_test_batch_size, shuffle=False, - **kwargs + **kwargs, ) return train_loader, test_loader diff --git a/onnxruntime/test/testdata/transform/fusion/matmul_scale_gen.py b/onnxruntime/test/testdata/transform/fusion/matmul_scale_gen.py index e4692894ea..68d4cab6dd 100644 --- a/onnxruntime/test/testdata/transform/fusion/matmul_scale_gen.py +++ b/onnxruntime/test/testdata/transform/fusion/matmul_scale_gen.py @@ -52,7 +52,7 @@ def gen(model_path, use_transpose_matmul, scale_input_0, scale_input_1, scale_ou matmul_op, "", matmul_domain, - **matmul_attrs + **matmul_attrs, ) ) diff --git a/orttraining/orttraining/eager/test_model/mnist_fc_training.py b/orttraining/orttraining/eager/test_model/mnist_fc_training.py index b96544e4f5..505fdf2493 100644 --- a/orttraining/orttraining/eager/test_model/mnist_fc_training.py +++ b/orttraining/orttraining/eager/test_model/mnist_fc_training.py @@ -96,7 +96,7 @@ def main(): ), batch_size=args.batch_size, shuffle=True, - **kwargs + **kwargs, ) test_loader = torch.utils.data.DataLoader( datasets.MNIST( @@ -106,7 +106,7 @@ def main(): ), batch_size=args.test_batch_size, shuffle=True, - **kwargs + **kwargs, ) # set device diff --git a/orttraining/orttraining/eager/test_models/mnist_fc_training.py b/orttraining/orttraining/eager/test_models/mnist_fc_training.py index 869d9cf8f7..54b5e0a771 100644 --- a/orttraining/orttraining/eager/test_models/mnist_fc_training.py +++ b/orttraining/orttraining/eager/test_models/mnist_fc_training.py @@ -97,7 +97,7 @@ def main(): ), batch_size=args.batch_size, shuffle=True, - **kwargs + **kwargs, ) test_loader = torch.utils.data.DataLoader( datasets.MNIST( @@ -107,7 +107,7 @@ def main(): ), batch_size=args.test_batch_size, shuffle=True, - **kwargs + **kwargs, ) device = torch.device("ort") diff --git a/orttraining/orttraining/test/python/orttraining_test_transformers.py b/orttraining/orttraining/test/python/orttraining_test_transformers.py index e43d3599d6..1e73da0f65 100644 --- a/orttraining/orttraining/test/python/orttraining_test_transformers.py +++ b/orttraining/orttraining/test/python/orttraining_test_transformers.py @@ -361,7 +361,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_mixed_precision_with_gradient_accumulation(self): @@ -378,7 +378,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_all(self): @@ -396,7 +396,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_list_input(self): @@ -410,7 +410,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_dict_input(self): @@ -424,7 +424,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_list_and_dict_input(self): @@ -438,7 +438,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_grad_accumulation_list_input(self): @@ -452,7 +452,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_grad_accumulation_dict_input(self): @@ -466,7 +466,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) def test_for_pretraining_full_precision_grad_accumulation_list_and_dict_input(self): @@ -480,7 +480,7 @@ class BertModelTest(unittest.TestCase): option_fp16, option_allreduce_post_accumulation, option_gradient_accumulation_steps, - option_split_batch + option_split_batch, ) diff --git a/orttraining/pytorch_frontend_examples/mnist_training.py b/orttraining/pytorch_frontend_examples/mnist_training.py index bea27011b3..afab8a3bf7 100644 --- a/orttraining/pytorch_frontend_examples/mnist_training.py +++ b/orttraining/pytorch_frontend_examples/mnist_training.py @@ -135,7 +135,7 @@ def main(): ), batch_size=args.batch_size, shuffle=True, - **kwargs + **kwargs, ) test_loader = torch.utils.data.DataLoader( datasets.MNIST( @@ -145,7 +145,7 @@ def main(): ), batch_size=args.test_batch_size, shuffle=True, - **kwargs + **kwargs, ) comm = MPI.COMM_WORLD diff --git a/pyproject.toml b/pyproject.toml index 9a104f0fbf..7a3fe477d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,7 @@ line-length = 120 # extend-exclude needs to be a regular expression extend-exclude = "cmake|onnxruntime/core/flatbuffers/" +target-version = ["py37", "py38", "py39", "py310"] [tool.isort] profile = "black" diff --git a/tools/ci_build/get_docker_image.py b/tools/ci_build/get_docker_image.py index e0eb06fc14..28407970e2 100755 --- a/tools/ci_build/get_docker_image.py +++ b/tools/ci_build/get_docker_image.py @@ -165,7 +165,7 @@ def main(): full_image_name, "--file", args.dockerfile, - args.context + args.context, ) if use_container_registry: diff --git a/tools/python/util/run.py b/tools/python/util/run.py index a8e45e9694..c3a389233f 100644 --- a/tools/python/util/run.py +++ b/tools/python/util/run.py @@ -18,7 +18,7 @@ def run( shell=False, env=None, check=True, - quiet=False + quiet=False, ): """Runs a subprocess.