Skip to content

Commit ceaa2d1

Browse files
authored
Merge pull request #3308 from jeffng-or/pre-python-38-hashing
Moved ODB hashing into its own method and made it compatible with pre…
2 parents 71c855f + 351845a commit ceaa2d1

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

flow/util/genElapsedTime.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,26 @@
1414
# ==============================================================================
1515

1616

17+
def get_hash(f):
18+
# content hash for the result file alongside .log file is useful to
19+
# debug divergent results under what should be identical
20+
# builds(such as local and CI builds)
21+
for ext in [".odb", ".rtlil", ".v"]:
22+
result_file = pathlib.Path(
23+
str(f).replace("logs/", "results/").replace(".log", ext)
24+
)
25+
if result_file.exists():
26+
hasher = hashlib.sha1()
27+
with open(result_file, "rb") as odb_f:
28+
while True:
29+
chunk = odb_f.read(16 * 1024 * 1024)
30+
if not chunk:
31+
break
32+
hasher.update(chunk)
33+
return hasher.hexdigest()
34+
return "N/A"
35+
36+
1737
def print_log_dir_times(logdir, args):
1838
first = True
1939
totalElapsed = 0
@@ -67,22 +87,7 @@ def print_log_dir_times(logdir, args):
6787
)
6888
break
6989

70-
# content hash for the result file alongside .log file is useful to
71-
# debug divergent results under what should be identical
72-
# builds(such as local and CI builds)
73-
for ext in [".odb", ".rtlil", ".v"]:
74-
result_file = pathlib.Path(
75-
str(f).replace("logs/", "results/").replace(".log", ext)
76-
)
77-
if result_file.exists():
78-
hasher = hashlib.sha1()
79-
with open(result_file, "rb") as odb_f:
80-
while chunk := odb_f.read(16 * 1024 * 1024):
81-
hasher.update(chunk)
82-
odb_hash = hasher.hexdigest()
83-
break
84-
else:
85-
odb_hash = "N/A"
90+
odb_hash = get_hash(f)
8691

8792
if not found:
8893
print("No elapsed time found in", str(f), file=sys.stderr)

0 commit comments

Comments
 (0)