pip_download_test.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env bash
  2. # This script automatically download ray and run the sanity check (sanity_check.py and sanity_check_cpp.sh)
  3. # in various Python version. This script requires conda command to exist.
  4. unset RAY_ADDRESS
  5. export RAY_HASH=$RAY_HASH
  6. export RAY_VERSION=$RAY_VERSION
  7. if [[ -z "$RAY_HASH" ]]; then
  8. echo "RAY_HASH env var should be provided"
  9. exit 1
  10. fi
  11. if [[ -z "$RAY_VERSION" ]]; then
  12. echo "RAY_VERSION env var should be provided"
  13. exit 1
  14. fi
  15. if ! [ -x "$(command -v conda)" ]; then
  16. echo "conda doesn't exist. Please download conda for this machine"
  17. exit 1
  18. else
  19. echo "conda exists"
  20. fi
  21. echo "Start downloading Ray version ${RAY_VERSION} of commit ${RAY_HASH}"
  22. pip install --upgrade pip
  23. # This is required to use conda activate
  24. source "$(conda info --base)/etc/profile.d/conda.sh"
  25. if [[ $(uname -m) == 'arm64' ]] && [[ $OSTYPE == "darwin"* ]]; then
  26. PYTHON_VERSIONS=( "3.8" "3.9" "3.10" )
  27. else
  28. PYTHON_VERSIONS=( "3.7" "3.8" "3.9" "3.10" )
  29. fi
  30. for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"
  31. do
  32. env_name="${RAY_VERSION}-${PYTHON_VERSION}-env"
  33. conda create -y -n "${env_name}" python="${PYTHON_VERSION}"
  34. conda activate "${env_name}"
  35. printf "\n\n\n"
  36. echo "========================================================="
  37. echo "Python version."
  38. python --version
  39. echo "This should be equal to ${PYTHON_VERSION}"
  40. echo "========================================================="
  41. printf "\n\n\n"
  42. # TODO (Alex): Get rid of this once grpc adds working PyPI wheels for M1 macs.
  43. if [[ $(uname -m) == 'arm64' ]] && [[ $OSTYPE == "darwin"* ]]; then
  44. conda install -y grpcio
  45. fi
  46. # shellcheck disable=SC2102
  47. pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple ray[cpp]=="${RAY_VERSION}"
  48. failed=false
  49. cpp_failed=false
  50. printf "\n\n\n"
  51. echo "========================================================="
  52. if python sanity_check.py; then
  53. echo "PYTHON ${PYTHON_VERSION} succeed sanity check."
  54. else
  55. failed=true
  56. fi
  57. if bash sanity_check_cpp.sh; then
  58. echo "PYTHON ${PYTHON_VERSION} succeed sanity check C++."
  59. else
  60. cpp_failed=true
  61. fi
  62. echo "========================================================="
  63. printf "\n\n\n"
  64. conda deactivate
  65. conda remove -y --name "${env_name}" --all
  66. if [ "$failed" = true ]; then
  67. echo "PYTHON ${PYTHON_VERSION} failed sanity check."
  68. exit 1
  69. fi
  70. if [ "$cpp_failed" = true ]; then
  71. echo "PYTHON ${PYTHON_VERSION} failed sanity check C++."
  72. exit 1
  73. fi
  74. done