Skip to content

Commit

Permalink
[CodeStyle][Ruff][BUAA][G-[81-90]] Fix ruff RUF005 diagnostic for 1…
Browse files Browse the repository at this point in the history
…0 files in `python/paddle/` (#67346)
  • Loading branch information
MufanColin authored Aug 13, 2024
1 parent 3280b5d commit 556d177
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 125 deletions.
25 changes: 12 additions & 13 deletions test/auto_parallel/test_amp_o2_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ def test_bf16(self):
coverage_args = []

tmp_dir = tempfile.TemporaryDirectory()
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
33 changes: 16 additions & 17 deletions test/auto_parallel/test_auto_parallel_relaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,22 @@ def test_relaunch(self):
else:
coverage_args = []

cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--log_dir",
self.temp_dir.name,
"--cluster_topo_path",
cluster_json_path,
"--rank_mapping_path",
mapping_json_path,
"--enable_auto_mapping",
"True",
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--log_dir",
self.temp_dir.name,
"--cluster_topo_path",
cluster_json_path,
"--rank_mapping_path",
mapping_json_path,
"--enable_auto_mapping",
"True",
launch_model_path,
]
process = subprocess.Popen(cmd)
process.wait()
self.assertEqual(process.returncode, 0)
Expand Down
29 changes: 14 additions & 15 deletions test/auto_parallel/test_auto_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,20 @@ def test_auto_tuner(self):
with open(test_json_path, "w") as f:
f.write(json_object)

cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
"--auto_tuner_json",
test_json_path,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
"--auto_tuner_json",
test_json_path,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
29 changes: 14 additions & 15 deletions test/auto_parallel/test_auto_tuner_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,20 @@ def test_auto_tuner_compare(self):
test_json_path = os.path.join(tmp_dir.name, "test.json")
with open(test_json_path, "w") as f:
f.write(json_object)
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
"--auto_tuner_json",
test_json_path,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
"--auto_tuner_json",
test_json_path,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
25 changes: 12 additions & 13 deletions test/auto_parallel/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@ def test_converter(self):
coverage_args = []

tmp_dir = tempfile.TemporaryDirectory()
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
25 changes: 12 additions & 13 deletions test/auto_parallel/test_engine_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ def test_engine_api(self):
coverage_args = []

tmp_dir = tempfile.TemporaryDirectory()
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
25 changes: 12 additions & 13 deletions test/auto_parallel/test_engine_api_dp.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ def test_engine_api(self):
coverage_args = []

tmp_dir = tempfile.TemporaryDirectory()
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
25 changes: 12 additions & 13 deletions test/auto_parallel/test_gpt_with_pir.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ def test_gpt_pir(self):
coverage_args = []

tmp_dir = tempfile.TemporaryDirectory()
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down
25 changes: 12 additions & 13 deletions test/auto_parallel/test_gpt_with_prim.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ def test_gpt_prim(self):
coverage_args = []

tmp_dir = tempfile.TemporaryDirectory()
cmd = (
[sys.executable, "-u"]
+ coverage_args
+ [
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]
)
cmd = [
sys.executable,
"-u",
*coverage_args,
"-m",
"paddle.distributed.launch",
"--devices",
"0,1",
"--log_dir",
tmp_dir.name,
launch_model_path,
]

process = subprocess.Popen(cmd)
process.wait()
Expand Down

0 comments on commit 556d177

Please sign in to comment.