Skip to content

Commit

Permalink
Fix loadgen VERSION to include patch number, remove hardcoded versions
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunsuresh committed Oct 23, 2024
1 parent f506644 commit 95c5541
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
15 changes: 11 additions & 4 deletions loadgen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@ project(mlperf_loadgen)
# Read the version file
file(READ "${CMAKE_SOURCE_DIR}/VERSION.txt" VERSION_CONTENTS)

# Extract the major and minor versions from the VERSION file (assuming "MAJOR.MINOR.PATCH" format)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" VERSION_MATCH ${VERSION_CONTENTS})
# Extract the major, minor, and patch versions from the VERSION file (assuming "MAJOR.MINOR.PATCH" format)
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" VERSION_MATCH ${VERSION_CONTENTS})

# Set the variables for the major and minor versions
# Set the variables for the major, minor, and patch versions
set(mlperf_loadgen_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(mlperf_loadgen_VERSION_MINOR "${CMAKE_MATCH_2}")
set(mlperf_loadgen_VERSION_PATCH "${CMAKE_MATCH_3}")

message("mlperf_loadgen v${mlperf_loadgen_VERSION_MAJOR}.${mlperf_loadgen_VERSION_MINOR}")
# Check if the version format was parsed correctly
if(NOT mlperf_loadgen_VERSION_MAJOR OR NOT mlperf_loadgen_VERSION_MINOR OR NOT mlperf_loadgen_VERSION_PATCH)
message(FATAL_ERROR "Version format in VERSION.txt is incorrect. Expected format: MAJOR.MINOR.PATCH")
endif()

# Print out the version
message("mlperf_loadgen v${mlperf_loadgen_VERSION_MAJOR}.${mlperf_loadgen_VERSION_MINOR}.${mlperf_loadgen_VERSION_PATCH}")

# Set build options. NB: CXX_STANDARD is supported since CMake 3.1.
if (NOT MSVC)
Expand Down
7 changes: 6 additions & 1 deletion loadgen/version_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
ofile.write("// DO NOT EDIT: Autogenerated by version_generator.py.\n\n")
ofile.write("#include <string>\n\n")
ofile.write("namespace mlperf {\n\n")
ofile.write(func_def("Version", "\"4.1\""))
# 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

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

date_time_now_local = datetime.datetime.now().isoformat()
date_time_now_utc = datetime.datetime.utcnow().isoformat()
Expand Down

0 comments on commit 95c5541

Please sign in to comment.