Skip to content

Commit

Permalink
build(traffic_light_fine_detector): simplify download logic
Browse files Browse the repository at this point in the history
Signed-off-by: Esteve Fernandez <[email protected]>
  • Loading branch information
esteve committed Aug 11, 2023
1 parent 5b8c05c commit 5c00581
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions perception/traffic_light_fine_detector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,19 @@ function(download FILE_NAME FILE_HASH)
if(${FILE_HASH} STREQUAL ${EXISTING_FILE_HASH})
message(STATUS "same ${FILE_NAME}")
message(STATUS "File already exists.")
else()
message(STATUS "diff ${FILE_NAME}")
message(STATUS "File hash changes. Downloading now ...")
if(DOWNLOAD_ARTIFACTS)
file(DOWNLOAD ${DATA_DIR}/${FILE_NAME} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 300)
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
else()
message(WARNING "Skipped download for ${FILE_NAME} (enable by setting DOWNLOAD_ARTIFACTS)")
file(MAKE_DIRECTORY "${DATA_PATH}")
return()
endif()
endif()
else()
message(STATUS "not found ${FILE_NAME}")
if(DOWNLOAD_ARTIFACTS)
message(STATUS "File doesn't exists. Downloading now ...")
file(DOWNLOAD ${DATA_DIR}/${FILE_NAME} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 300)
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
else()
message(WARNING "Skipped download for ${FILE_NAME} (enable by setting DOWNLOAD_ARTIFACTS)")
file(MAKE_DIRECTORY "${DATA_PATH}")
return()
endif()
message(STATUS "diff ${FILE_NAME}")
endif()
if(${STATUS_CODE} EQUAL 0)
message(STATUS "Download completed successfully!")
if(DOWNLOAD_ARTIFACTS)
message(STATUS "Downloading now ...")
file(DOWNLOAD ${DATA_DIR}/${FILE_NAME} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 300)
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
else()
message(FATAL_ERROR "Error occurred during download: ${ERROR_MESSAGE}")
message(WARNING "Skipped download for ${FILE_NAME} (enable by setting DOWNLOAD_ARTIFACTS)")
file(MAKE_DIRECTORY "${DATA_PATH}")
return()
endif()
endfunction()
download(tlr_yolox_s_batch_1.onnx ${PRETRAINED_MODEL_BATCH_1_HASH})
Expand Down

0 comments on commit 5c00581

Please sign in to comment.