Skip to content
Merged
10 changes: 8 additions & 2 deletions loadgen/version_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
raise

with open(cc_filename, "w") as ofile:
ofile.write("// DO NOT EDIT: Autogenerated by version_generator.py.\n\n")
ofile.write(
"// DO NOT EDIT: Autogenerated by version_generator.py.\n\n")
ofile.write("#include <string>\n\n")
ofile.write("namespace mlperf {\n\n")
# Open and read the VERSION.txt file
Expand All @@ -114,7 +115,12 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):

date_time_now_local = datetime.datetime.now().isoformat()
date_time_now_utc = datetime.datetime.utcnow().isoformat()
ofile.write(func_def("BuildDateLocal", '"' + date_time_now_local + '"'))
ofile.write(
func_def(
"BuildDateLocal",
'"' +
date_time_now_local +
'"'))
ofile.write(func_def("BuildDateUtc", '"' + date_time_now_utc + '"'))

git_dir = '--git-dir="' + loadgen_root + '/../.git" '
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import json
import os
import io


def _make_r_io_base(f, mode: str):
if not isinstance(f, io.IOBase):
f = open(f, mode=mode, encoding="utf-8")
return f


def jload(f, mode="r"):
"""Load a .json file into a dictionary."""
f = _make_r_io_base(f, mode)
jdict = json.load(f)
f.close()
return jdict
if not isinstance(f, io.IOBase):
with open(f, mode=mode) as f:
return json.load(f)
else:
return json.load(f)
Loading