diff --git a/tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh b/tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh index 698c0d008fd..ffb7c5147c1 100644 --- a/tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh +++ b/tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh @@ -18,13 +18,8 @@ set -e set -x -# CPU size -MAC_CPU_MAX_WHL_SIZE=190M -LINUX_CPU_MAX_WHL_SIZE=170M -WIN_CPU_MAX_WHL_SIZE=113M -# GPU size -LINUX_GPU_MAX_WHL_SIZE=435M -WIN_GPU_MAX_WHL_SIZE=252M +# Get size check function +source tensorflow/tools/ci_build/release/common.sh function run_smoke_test() { @@ -55,7 +50,7 @@ function run_smoke_test() { test_tf_imports # Test TensorFlow whl file size - test_tf_whl_size + test_tf_whl_size ${WHL_NAME} RESULT=$? @@ -103,48 +98,6 @@ function test_tf_imports() { return $RESULT } -function test_tf_whl_size() { - # First, list all wheels with their sizes: - echo "Found these wheels: " - find $WHL_NAME -type f -exec ls -lh {} \; - echo "====================" - # Check CPU whl size. - if [[ "$WHL_NAME" == *"_cpu"* ]]; then - # Check MAC CPU whl size. - if [[ "$WHL_NAME" == *"-macos"* ]] && [[ $(find $WHL_NAME -type f -size +${MAC_CPU_MAX_WHL_SIZE}) ]]; then - echo "Mac CPU whl size has exceeded ${MAC_CPU_MAX_WHL_SIZE}. To keep -within pypi's CDN distribution limit, we must not exceed that threshold." - return 1 - fi - # Check Linux CPU whl size. - if [[ "$WHL_NAME" == *"-manylinux"* ]] && [[ $(find $WHL_NAME -type f -size +${LINUX_CPU_MAX_WHL_SIZE}) ]]; then - echo "Linux CPU whl size has exceeded ${LINUX_CPU_MAX_WHL_SIZE}. To keep -within pypi's CDN distribution limit, we must not exceed that threshold." - return 1 - fi - # Check Windows CPU whl size. - if [[ "$WHL_NAME" == *"-win"* ]] && [[ $(find $WHL_NAME -type f -size +${WIN_CPU_MAX_WHL_SIZE}) ]]; then - echo "Windows CPU whl size has exceeded ${WIN_CPU_MAX_WHL_SIZE}. To keep -within pypi's CDN distribution limit, we must not exceed that threshold." - return 1 - fi - # Check GPU whl size - elif [[ "$WHL_NAME" == *"_gpu"* ]]; then - # Check Linux GPU whl size. - if [[ "$WHL_NAME" == *"-manylinux"* ]] && [[ $(find $WHL_NAME -type f -size +${LINUX_GPU_MAX_WHL_SIZE}) ]]; then - echo "Linux GPU whl size has exceeded ${LINUX_GPU_MAX_WHL_SIZE}. To keep -within pypi's CDN distribution limit, we must not exceed that threshold." - return 1 - fi - # Check Windows GPU whl size. - if [[ "$WHL_NAME" == *"-win"* ]] && [[ $(find $WHL_NAME -type f -size +${WIN_GPU_MAX_WHL_SIZE}) ]]; then - echo "Windows GPU whl size has exceeded ${WIN_GPU_MAX_WHL_SIZE}. To keep -within pypi's CDN distribution limit, we must not exceed that threshold." - return 1 - fi - fi -} - ########################################################################### # Main ########################################################################### diff --git a/tensorflow/tools/ci_build/nightly_release/windows/upload_nightly_pip.sh b/tensorflow/tools/ci_build/nightly_release/windows/upload_nightly_pip.sh index d2f2fddc323..4efab9061a2 100644 --- a/tensorflow/tools/ci_build/nightly_release/windows/upload_nightly_pip.sh +++ b/tensorflow/tools/ci_build/nightly_release/windows/upload_nightly_pip.sh @@ -35,7 +35,19 @@ for f in $(ls "${KOKORO_GFILE_DIR}"/tf_nightly_gpu*dev*cp3*-cp3*-win_amd64.whl); copy_to_new_project_name "${f}" tf_nightly python done +OVERALL_RETVAL=0 # Upload the built packages to pypi. for f in $(ls "${KOKORO_GFILE_DIR}"/tf_nightly*dev*cp3*-cp3*-win_amd64.whl); do - python -m twine upload -r pypi-warehouse "$f" || echo + test_tf_whl_size $f + RETVAL=$? + + # Upload the PIP package if whl test passes. + if [ ${RETVAL} -eq 0 ]; then + python -m twine upload -r pypi-warehouse "$f" + else + echo "Unable to upload package $f. Size check failed." + OVERALL_RETVAL=1 + fi done + +exit $OVERALL_RETVAL diff --git a/tensorflow/tools/ci_build/release/common.sh b/tensorflow/tools/ci_build/release/common.sh index 289d9211eac..363df083b89 100644 --- a/tensorflow/tools/ci_build/release/common.sh +++ b/tensorflow/tools/ci_build/release/common.sh @@ -434,3 +434,55 @@ function test_xml_summary_exit { test_xml_summary exit "${RETVAL}" } + +# CPU size +MAC_CPU_MAX_WHL_SIZE=190M +LINUX_CPU_MAX_WHL_SIZE=170M +WIN_CPU_MAX_WHL_SIZE=113M +# GPU size +LINUX_GPU_MAX_WHL_SIZE=435M +WIN_GPU_MAX_WHL_SIZE=252M + +function test_tf_whl_size() { + WHL_PATH=${1} + # First, list all wheels with their sizes: + echo "Found these wheels: " + find $WHL_PATH -type f -exec ls -lh {} \; + echo "====================" + # Check CPU whl size. + if [[ "$WHL_PATH" == *"_cpu"* ]]; then + # Check MAC CPU whl size. + if [[ "$WHL_PATH" == *"-macos"* ]] && [[ $(find $WHL_PATH -type f -size +${MAC_CPU_MAX_WHL_SIZE}) ]]; then + echo "Mac CPU whl size has exceeded ${MAC_CPU_MAX_WHL_SIZE}. To keep +within pypi's CDN distribution limit, we must not exceed that threshold." + return 1 + fi + # Check Linux CPU whl size. + if [[ "$WHL_PATH" == *"-manylinux"* ]] && [[ $(find $WHL_PATH -type f -size +${LINUX_CPU_MAX_WHL_SIZE}) ]]; then + echo "Linux CPU whl size has exceeded ${LINUX_CPU_MAX_WHL_SIZE}. To keep +within pypi's CDN distribution limit, we must not exceed that threshold." + return 1 + fi + # Check Windows CPU whl size. + if [[ "$WHL_PATH" == *"-win"* ]] && [[ $(find $WHL_PATH -type f -size +${WIN_CPU_MAX_WHL_SIZE}) ]]; then + echo "Windows CPU whl size has exceeded ${WIN_CPU_MAX_WHL_SIZE}. To keep +within pypi's CDN distribution limit, we must not exceed that threshold." + return 1 + fi + # Check GPU whl size + elif [[ "$WHL_PATH" == *"_gpu"* ]]; then + # Check Linux GPU whl size. + if [[ "$WHL_PATH" == *"-manylinux"* ]] && [[ $(find $WHL_PATH -type f -size +${LINUX_GPU_MAX_WHL_SIZE}) ]]; then + echo "Linux GPU whl size has exceeded ${LINUX_GPU_MAX_WHL_SIZE}. To keep +within pypi's CDN distribution limit, we must not exceed that threshold." + return 1 + fi + # Check Windows GPU whl size. + if [[ "$WHL_PATH" == *"-win"* ]] && [[ $(find $WHL_PATH -type f -size +${WIN_GPU_MAX_WHL_SIZE}) ]]; then + echo "Windows GPU whl size has exceeded ${WIN_GPU_MAX_WHL_SIZE}. To keep +within pypi's CDN distribution limit, we must not exceed that threshold." + return 1 + fi + fi +} + diff --git a/tensorflow/tools/ci_build/windows/cpu/pip/build_tf_windows.sh b/tensorflow/tools/ci_build/windows/cpu/pip/build_tf_windows.sh index 8142ed674b6..e4258f0408e 100644 --- a/tensorflow/tools/ci_build/windows/cpu/pip/build_tf_windows.sh +++ b/tensorflow/tools/ci_build/windows/cpu/pip/build_tf_windows.sh @@ -155,10 +155,6 @@ create_python_test_dir "${PY_TEST_DIR}" ./bazel-bin/tensorflow/tools/pip_package/build_pip_package "$PWD/${PY_TEST_DIR}" ${EXTRA_PIP_FLAGS} if [[ "$TF_NIGHTLY" == 1 ]]; then - WHL_PATH=$(ls ${PY_TEST_DIR}/tf_nightly*.whl) - # Test the whl pip package. - chmod +x tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh - ./tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh ${WHL_PATH} exit 0 fi diff --git a/tensorflow/tools/ci_build/windows/gpu/pip/build_tf_windows.sh b/tensorflow/tools/ci_build/windows/gpu/pip/build_tf_windows.sh index bca5561cd7d..1874a23df6d 100644 --- a/tensorflow/tools/ci_build/windows/gpu/pip/build_tf_windows.sh +++ b/tensorflow/tools/ci_build/windows/gpu/pip/build_tf_windows.sh @@ -153,10 +153,6 @@ create_python_test_dir "${PY_TEST_DIR}" --gpu ${EXTRA_PIP_FLAGS} if [[ "$TF_NIGHTLY" == 1 ]]; then - WHL_PATH=$(ls ${PY_TEST_DIR}/tf_nightly*.whl) - # Test the whl pip package. - chmod +x tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh - ./tensorflow/tools/ci_build/builds/nightly_release_smoke_test.sh ${WHL_PATH} exit 0 fi