Skip to content

Commit 64ff25a

Browse files
fixed pylint errors
1 parent df30f28 commit 64ff25a

File tree

3 files changed

+34
-34
lines changed

3 files changed

+34
-34
lines changed

vtr_flow/scripts/download_noc_mlp.py

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
11
#!/usr/bin/env python3
2+
3+
"""
4+
Module for downloading and extracting NoC MLP benchmarks
5+
"""
6+
27
import sys
38
import os
49
import argparse
10+
import urllib.request
511
import urllib.parse
6-
import urllib.request, urllib.parse, urllib.error
7-
import urllib.request, urllib.error, urllib.parse
12+
import urllib.error
813
import math
914
import textwrap
1015
import tarfile
1116
import tempfile
1217
import shutil
1318
import errno
1419

15-
16-
class DownloadError(Exception):
17-
pass
18-
19-
20-
class ChecksumError(Exception):
21-
pass
22-
23-
2420
class ExtractionError(Exception):
25-
pass
21+
"""
22+
Raised when extracting the downlaoded file fails
23+
"""
2624

2725

2826
URL_MIRRORS = {"eecg": "https://www.eecg.utoronto.ca/~vaughn/titan/"}
2927

3028

3129
def parse_args():
30+
"""
31+
Parses command line arguments
32+
"""
3233
description = textwrap.dedent(
3334
"""
3435
Download and extract a MLP NoC benchmarks into a
@@ -38,7 +39,8 @@ def parse_args():
3839
does nothing (unless --force is specified).
3940
"""
4041
)
41-
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
42+
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
43+
description=description)
4244

4345
parser.add_argument(
4446
"--vtr_flow_dir",
@@ -64,6 +66,9 @@ def parse_args():
6466

6567

6668
def main():
69+
"""
70+
main() implementation
71+
"""
6772

6873
args = parse_args()
6974

@@ -83,10 +88,6 @@ def main():
8388

8489
print("Extracting {}".format(tar_gz_filename))
8590
extract_to_vtr_flow_dir(args, tar_gz_filename)
86-
87-
except DownloadError as e:
88-
print("Failed to download:", e)
89-
sys.exit(1)
9091
except ExtractionError as e:
9192
print("Failed to extract NoC MLP benchmarks release:", e)
9293
sys.exit(3)
@@ -124,17 +125,11 @@ def extract_to_vtr_flow_dir(args, tar_gz_filename):
124125
benchmarks_dir = os.path.join(args.vtr_flow_dir, "benchmarks")
125126
mlp_benchmarks_dir = os.path.join(benchmarks_dir, "noc/Large_Designs/MLP")
126127

127-
128128
if not args.force:
129129
# Check that all expected directories exist
130-
expected_dirs = [
131-
args.vtr_flow_dir,
132-
benchmarks_dir,
133-
mlp_benchmarks_dir,
134-
]
135-
for dir in expected_dirs:
136-
if not os.path.isdir(dir):
137-
raise ExtractionError("{} should be a directory".format(dir))
130+
for directory in [args.vtr_flow_dir, benchmarks_dir, mlp_benchmarks_dir]:
131+
if not os.path.isdir(directory):
132+
raise ExtractionError("{} should be a directory".format(directory))
138133

139134
# Create a temporary working directory
140135
tmpdir = tempfile.mkdtemp(suffix="download_NoC_MLP", dir= os.path.abspath("."))
@@ -143,13 +138,13 @@ def extract_to_vtr_flow_dir(args, tar_gz_filename):
143138
with tarfile.open(tar_gz_filename, "r:gz") as tar:
144139
tar.extractall(tmpdir)
145140
tmp_source_blif_dir = os.path.join(tmpdir, "MLP_Benchmark_Netlist_Files")
146-
for root, dirs, files in os.walk(tmp_source_blif_dir):
141+
for root, _, files in os.walk(tmp_source_blif_dir):
147142
for file in files:
148143
source_file = os.path.join(root, file)
149144
relative_path = os.path.relpath(source_file, tmp_source_blif_dir)
150145
destination_file = os.path.join(mlp_benchmarks_dir, relative_path)
151146
os.makedirs(os.path.dirname(destination_file), exist_ok=True)
152-
shutil.copy2(source_file, destination_file)
147+
shutil.copy2(source_file, destination_file)
153148

154149
# Create symbolic links to blif files
155150
find_and_link_files(mlp_benchmarks_dir, ".blif", "blif_files")
@@ -173,7 +168,7 @@ def find_and_link_files(base_path, target_extension, link_folder_name):
173168
os.makedirs(link_folder_path, exist_ok=True)
174169

175170
# Walk through all subdirectories
176-
for root, dirs, files in os.walk(base_path):
171+
for root, _, files in os.walk(base_path):
177172
if root == link_folder_path:
178173
continue
179174

vtr_flow/scripts/download_titan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def parse_args():
4141
does nothing (unless --force is specified).
4242
"""
4343
)
44-
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
44+
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
45+
description=description)
4546

4647
parser.add_argument(
4748
"--titan_version", default="2.0.0", help="Titan release version to download"

vtr_flow/scripts/python_libs/vtr/task.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(
4747
pass_requirements_file=None,
4848
sdc_dir=None,
4949
noc_traffic_list_type="outer_product",
50-
noc_traffic_list_add=[None],
50+
noc_traffic_list_add=None,
5151
noc_traffics_dir=None,
5252
place_constr_dir=None,
5353
qor_parse_file=None,
@@ -73,7 +73,7 @@ def __init__(
7373
self.pass_requirements_file = pass_requirements_file
7474
self.sdc_dir = sdc_dir
7575
self.noc_traffic_list_type = noc_traffic_list_type
76-
self.noc_traffics = noc_traffic_list_add
76+
self.noc_traffics = [None] if noc_traffic_list_add is None else noc_traffic_list_add
7777
self.noc_traffic_dir = noc_traffics_dir
7878
self.place_constr_dir = place_constr_dir
7979
self.qor_parse_file = qor_parse_file
@@ -480,11 +480,15 @@ def create_jobs(args, configs, after_run=False) -> List[Job]:
480480
combinations = list(itertools.product(config.circuits, config.noc_traffics))
481481
elif config.noc_traffic_list_type == "per_circuit":
482482
assert len(config.circuits) == len(config.noc_traffics)
483-
combinations = [(circuit, noc_traffic) for circuit, noc_traffic in zip(config.circuits, config.noc_traffics)]
483+
combinations = zip(config.circuits, config.noc_traffics)
484484
else:
485485
assert False, "Invalid noc_traffic_list_type"
486486

487-
combinations = [(arch, circuit, noc_traffic) for arch in config.archs for circuit, noc_traffic in combinations]
487+
combinations = [
488+
(arch, circ, traffic_flow)
489+
for arch in config.archs
490+
for circ, traffic_flow in combinations
491+
]
488492

489493
for arch, circuit, noc_traffic in combinations:
490494
golden_results = load_parse_results(

0 commit comments

Comments
 (0)