Skip to content

Commit

Permalink
[Automated Commit] Format Codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Oct 23, 2024
1 parent 5d8838f commit 651f7cd
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 134 deletions.
4 changes: 2 additions & 2 deletions loadgen/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
if len(version_split) < 2:
print("Version is incomplete. Needs a format like 4.1.1 in VERSION file")

command = ["xxd", "-i", "mlperf.conf", "mlperf_conf.h" ]
command = ["xxd", "-i", "mlperf.conf", "mlperf_conf.h"]
try:
subprocess.check_call(command)
except subprocess.CalledProcessError as e:
Expand All @@ -104,7 +104,7 @@
version_split[0]),
("MINOR_VERSION",
version_split[1])
],
],
include_dirs=[".", get_include()],
sources=mlperf_loadgen_sources,
depends=mlperf_loadgen_headers)
Expand Down
8 changes: 4 additions & 4 deletions loadgen/test_settings_internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ limitations under the License.
==============================================================================*/

#include "test_settings_internal.h"
#include "mlperf_conf.h"

#include <fstream>
#include <map>
#include <sstream>
#include <string>

#include "logging.h"
#include "mlperf_conf.h"
#include "utils.h"

namespace mlperf {
Expand Down Expand Up @@ -589,7 +589,7 @@ int TestSettings::FromConfig(const std::string &path, const std::string &model,
if (!is_mlperf_conf) {
// dirt simple config parser
fss = std::make_unique<std::ifstream>(path);
if (!static_cast<std::ifstream*>(fss.get())->is_open()) {
if (!static_cast<std::ifstream *>(fss.get())->is_open()) {
LogDetail([p = path](AsyncDetail &detail) {
#if USE_NEW_LOGGING_FORMAT
std::stringstream ss;
Expand All @@ -603,9 +603,9 @@ int TestSettings::FromConfig(const std::string &path, const std::string &model,
}
} else {
// Convert unsigned char array to std::string
std::string config_str(reinterpret_cast<const char*>(mlperf_conf), mlperf_conf_len);
std::string config_str(reinterpret_cast<const char *>(mlperf_conf),
mlperf_conf_len);
fss = std::make_unique<std::istringstream>(config_str);

}
while (std::getline(*fss, line)) {
line_nr++;
Expand Down
14 changes: 9 additions & 5 deletions loadgen/version_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.
# =============================================================================

## \file
# \file
# \brief A script run by the build to generate the version definitions
# expected at link time.

Expand All @@ -27,10 +27,11 @@

# Creates a C++ raw string literal using a delimiter that is very
# unlikely to show up in a git stats.
def make_raw_string(str) :
def make_raw_string(str):
delimeter = "LGVG_RSLD"
return "R\"" + delimeter + "(" + str + ")" + delimeter + "\""


def func_def(name, string):
return ("const std::string& Loadgen" + name + "() {\n" +
" static const std::string str = " + string + ";\n" +
Expand All @@ -42,10 +43,12 @@ def func_def(name, string):
# any modifications.
def generate_loadgen_version_definitions_git(ofile, git_command):
git_rev = os.popen(git_command + "rev-parse --short=10 HEAD").read()
git_commit_date = os.popen(git_command + "log --format=\"%cI\" -n 1").read()
git_commit_date = os.popen(
git_command +
"log --format=\"%cI\" -n 1").read()
git_status = os.popen(git_command + "status -s -uno .").read()
git_log = subprocess.Popen(
git_command + "log --pretty=oneline -n 16 --no-decorate", stdout=subprocess.PIPE, shell=True, encoding='ascii', errors="ignore" ).stdout.read()
git_command + "log --pretty=oneline -n 16 --no-decorate", stdout=subprocess.PIPE, shell=True, encoding='ascii', errors="ignore").stdout.read()
ofile.write(func_def("GitRevision", "\"" + git_rev[0:-1] + "\""))
ofile.write(func_def("GitCommitDate", "\"" + git_commit_date[0:-1] + "\""))
ofile.write(func_def("GitStatus", make_raw_string(git_status[0:-1])))
Expand Down Expand Up @@ -95,7 +98,8 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
ofile.write("namespace mlperf {\n\n")
# Open and read the VERSION.txt file
with open("VERSION.txt", "r") as version_file:
version_contents = version_file.read().strip() # Read and strip any extra whitespace/newlines
# Read and strip any extra whitespace/newlines
version_contents = version_file.read().strip()

# Write the version into the function definition
ofile.write(func_def("Version", f"\"{version_contents}\""))
Expand Down
Loading

0 comments on commit 651f7cd

Please sign in to comment.