Skip to content

Commit

Permalink
fix(yabloc_pose_initializer): disable downloading artifacts by default (
Browse files Browse the repository at this point in the history
#4110)

Signed-off-by: Esteve Fernandez <esteve.fernandez@tier4.jp>
Co-authored-by: Esteve Fernandez <esteve.fernadnez@tier4.jp>
  • Loading branch information
esteve and Esteve Fernandez committed Jun 30, 2023
1 parent e88ccad commit da9c9c5
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions localization/yabloc/yabloc_pose_initializer/download.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(DOWNLOAD_ARTIFACTS OFF CACHE BOOL "enable artifacts download")

set(DATA_URL "https://s3.ap-northeast-2.wasabisys.com/pinto-model-zoo/136_road-segmentation-adas-0001/resources.tar.gz")
set(DATA_PATH "${CMAKE_CURRENT_SOURCE_DIR}/data")
set(FILE_HASH 146ed8af689a30b898dc5369870c40fb)
set(FILE_NAME "resources.tar.gz")

function(download)
function(download_and_extract)
message(STATUS "Checking and downloading ${FILE_NAME}")
set(FILE_PATH ${DATA_PATH}/${FILE_NAME})
set(STATUS_CODE 0)
Expand All @@ -38,25 +40,28 @@ function(download)
list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
endif()
else()
message(STATUS "not found ${FILE_NAME}")
message(STATUS "File doesn't exists. Downloading now ...")
file(DOWNLOAD ${DATA_URL} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 3600)
list(GET DOWNLOAD_STATUS 0 STATUS_CODE)
list(GET DOWNLOAD_STATUS 1 ERROR_MESSAGE)
if(DOWNLOAD_ARTIFACTS)
message(STATUS "not found ${FILE_NAME}")
message(STATUS "File doesn't exists. Downloading now ...")
file(DOWNLOAD ${DATA_URL} ${FILE_PATH} STATUS DOWNLOAD_STATUS TIMEOUT 3600)
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()

if(${STATUS_CODE} EQUAL 0)
message(STATUS "Download completed successfully!")
else()
message(FATAL_ERROR "Error occurred during download: ${ERROR_MESSAGE}")
endif()
endfunction()

function(extract)
execute_process(COMMAND
${CMAKE_COMMAND} -E
tar xzf "${DATA_PATH}/${FILE_NAME}" WORKING_DIRECTORY "${DATA_PATH}")
endfunction()

download()
extract()
download_and_extract()

0 comments on commit da9c9c5

Please sign in to comment.