@@ -38,6 +38,7 @@ WITH_SNOWPARK=false
3838MODE=" continuous_run"
3939SNOWML_DIR=" snowml"
4040SNOWPARK_DIR=" snowpark-python"
41+ IS_NT=false
4142
4243while (( $# )) ; do
4344 case $1 in
@@ -74,26 +75,70 @@ while (($#)); do
7475 shift
7576done
7677
78+ EXT=" "
79+ BAZEL_ADDITIONAL_BUILD_FLAGS=()
80+ BAZEL_ADDITIONAL_STARTUP_FLAGS=()
81+
82+ # Computing artifact location
83+ # Detect the platform, also update some platform specific bazel settings
84+ case " $( uname) " in
85+ Linux)
86+ PLATFORM=" linux" ;;
87+ Darwin)
88+ PLATFORM=" darwin" ;;
89+ * NT* )
90+ PLATFORM=" windows"
91+ IS_NT=true ;;
92+ esac
93+
94+ # Detect the architecture
95+ ARCH=" $( uname -m) "
96+ case " $ARCH " in
97+ aarch64|ppc64le|arm64)
98+ ARCH=" arm64" ;;
99+ * )
100+ ARCH=" amd64" ;;
101+ esac
102+
103+ # Compute the platform-arch string used to download yq.
104+ case " ${PLATFORM} _${ARCH} " in
105+ linux_arm64|linux_amd64|darwin_arm64|darwin_amd64|windows_amd64)
106+ ;; # pass
107+ * )
108+ echo " Platform / Architecture is not supported by yq." >&2
109+ exit 1
110+ ;;
111+ esac
112+
77113# Check Python3.8 exist
78114# TODO(SNOW-845592): ideally we should download py3.8 from conda if not exist. Currently we just fail.
79- set +eu
80- source /opt/rh/rh-python38/enable
81- PYTHON38_EXIST=$?
82- if [ $PYTHON38_EXIST -ne 0 ]; then
83- echo " Failed to execute tests: Python3.8 is not installed."
84- rm -rf " ${TEMP_TEST_DIR} "
85- exit ${PYTHON38_EXIST}
115+ if [ " ${ENV} " = " pip" ]; then
116+ set +eu
117+ source /opt/rh/rh-python38/enable
118+ PYTHON38_EXIST=$?
119+ if [ $PYTHON38_EXIST -ne 0 ]; then
120+ echo " Failed to execute tests: Python3.8 is not installed."
121+ rm -rf " ${TEMP_TEST_DIR} "
122+ exit ${PYTHON38_EXIST}
123+ fi
124+ set -eu
125+ fi
126+
127+ if [ ${IS_NT} = true ]; then
128+ EXT=" .exe"
129+ BAZEL_ADDITIONAL_BUILD_FLAGS+=(--nobuild_python_zip)
130+ BAZEL_ADDITIONAL_BUILD_FLAGS+=(--enable_runfiles)
131+ BAZEL_ADDITIONAL_STARTUP_FLAGS+=(--output_user_root=D:/broot)
86132fi
87- set -eu
88133
89134cd " ${WORKSPACE} "
90135
91136# Check and download yq if not presented.
92- _YQ_BIN=" yq"
137+ _YQ_BIN=" yq${EXT} "
93138if ! command -v " ${_YQ_BIN} " & > /dev/null; then
94139 TEMP_BIN=$( mktemp -d " ${WORKSPACE} /tmp_bin_XXXXX" )
95- curl -Ls https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o " ${TEMP_BIN} /yq" && chmod +x " ${TEMP_BIN} /yq"
96- _YQ_BIN=" ${TEMP_BIN} /yq"
140+ curl -Lsv https://github.com/mikefarah/yq/releases/latest/download/yq_ ${PLATFORM} _ ${ARCH}${EXT} -o " ${TEMP_BIN} /yq${EXT} " && chmod +x " ${TEMP_BIN} /yq${EXT} "
141+ _YQ_BIN=" ${TEMP_BIN} /yq${EXT} "
97142fi
98143
99144# Create temp release folder
@@ -109,23 +154,39 @@ echo "Extracted Package Version from code: ${VERSION}"
109154OPTIONAL_REQUIREMENTS=()
110155while IFS=' ' read -r line; do OPTIONAL_REQUIREMENTS+=(" $line " ); done < <( " ${_YQ_BIN} " ' .requirements.run_constrained.[] | ... style=""' ci/conda_recipe/meta.yaml)
111156
112- # Generate and copy auto-gen tests.
113- if [[ ${MODE} = " release" ]]; then
114- " ${BAZEL} " build //tests/... --build_tag_filters=autogen_build
115- cp -r " $( " ${BAZEL} " info bazel-bin) /tests" " ${TEMP_TEST_DIR} "
116- fi
117-
118157# Compare test required dependencies with wheel pkg dependencies and exclude tests if necessary
119158EXCLUDE_TESTS=$( mktemp " ${TEMP_TEST_DIR} /exclude_tests_XXXXX" )
120159if [[ ${MODE} = " continuous_run" || ${MODE} = " release" ]]; then
121160 ./ci/get_excluded_tests.sh -f " ${EXCLUDE_TESTS} " -m unused -b " ${BAZEL} "
122161elif [[ ${MODE} = " merge_gate" ]]; then
123162 ./ci/get_excluded_tests.sh -f " ${EXCLUDE_TESTS} " -m all -b " ${BAZEL} "
124163fi
164+
165+ # Generate and copy auto-gen tests.
166+ if [[ ${MODE} = " release" ]]; then
167+ # When release, we build all autogen tests
168+ " ${BAZEL} " " ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+" ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]} " } " build " ${BAZEL_ADDITIONAL_BUILD_FLAGS[@]+" ${BAZEL_ADDITIONAL_BUILD_FLAGS[@]} " } " //tests/integ/...
169+ else
170+ # In other cases, we build required utility only.
171+ " ${BAZEL} " " ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+" ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]} " } " build --build_tag_filters=-autogen_build,-autogen " ${BAZEL_ADDITIONAL_BUILD_FLAGS[@]+" ${BAZEL_ADDITIONAL_BUILD_FLAGS[@]} " } " //tests/integ/...
172+ fi
173+
174+ # Rsync cannot work well with path that has drive letter in Windows,
175+ # Thus, these two rsync has to use relative path instead of absolute ones.
176+
177+ rsync -av --exclude ' *.runfiles_manifest' --exclude ' *.runfiles/**' " bazel-bin/tests" .
178+
125179# Copy tests into temp directory
126180pushd " ${TEMP_TEST_DIR} "
127- rsync -av --exclude-from " ${EXCLUDE_TESTS} " " ${WORKSPACE} /${SNOWML_DIR} /tests" .
181+ rsync -av --exclude-from " ${EXCLUDE_TESTS} " " .. /${SNOWML_DIR} /tests" .
128182popd
183+
184+ # Bazel on windows is consuming a lot of memory, let's clean it before proceed to avoid OOM.
185+ if [ ${IS_NT} = true ]; then
186+ " ${BAZEL} " " ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+" ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]} " } " clean --expunge
187+ " ${BAZEL} " " ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+" ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]} " } " shutdown
188+ fi
189+
129190popd
130191
131192# Build snowml package
@@ -149,12 +210,10 @@ if [ "${ENV}" = "pip" ]; then
149210
150211 # Build SnowML
151212 pushd ${SNOWML_DIR}
152- " ${BAZEL} " build //snowflake/ml:wheel
213+ " ${BAZEL} " " ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]+ " ${BAZEL_ADDITIONAL_STARTUP_FLAGS[@]} " } " build " ${BAZEL_ADDITIONAL_BUILD_FLAGS[@]+ " ${BAZEL_ADDITIONAL_BUILD_FLAGS[@]} " } " //snowflake/ml:wheel
153214 cp " $( ${BAZEL} info bazel-bin) /snowflake/ml/snowflake_ml_python-${VERSION} -py3-none-any.whl" " ${WORKSPACE} "
154215 popd
155216else
156- which conda
157-
158217 # Clean conda cache
159218 conda clean --all --force-pkgs-dirs -y
160219
@@ -183,7 +242,7 @@ pushd "${TEMP_TEST_DIR}"
183242COMMON_PYTEST_FLAG=()
184243COMMON_PYTEST_FLAG+=(--strict-markers) # Strict the pytest markers to avoid typo in markers
185244COMMON_PYTEST_FLAG+=(--import-mode=append)
186- COMMON_PYTEST_FLAG+=(-n 10 )
245+ COMMON_PYTEST_FLAG+=(-n logical )
187246
188247if [ " ${ENV} " = " pip" ]; then
189248 # Copy wheel package
@@ -196,10 +255,10 @@ if [ "${ENV}" = "pip" ]; then
196255 # otherwise it will fail in dependency resolution.
197256 python3.8 -m pip install --upgrade pip
198257 python3.8 -m pip list
199- python3.8 -m pip install " snowflake_ml_python-${VERSION} -py3-none-any.whl[all]" pytest-xdist inflection --no-cache-dir --force-reinstall
258+ python3.8 -m pip install " snowflake_ml_python-${VERSION} -py3-none-any.whl[all]" pytest-xdist[psutil] -r " ${WORKSPACE} / ${SNOWML_DIR} /requirements.txt " --no-cache-dir --force-reinstall
200259 if [ " ${WITH_SNOWPARK} " = true ]; then
201260 cp " $( find " ${WORKSPACE} " -maxdepth 1 -iname ' snowflake_snowpark_python-*.whl' ) " " ${TEMP_TEST_DIR} "
202- python3.8 -m pip install " $( find . -maxdepth 1 -iname ' snowflake_snowpark_python-*.whl' ) " --force-reinstall
261+ python3.8 -m pip install " $( find . -maxdepth 1 -iname ' snowflake_snowpark_python-*.whl' ) " --no-deps -- force-reinstall
203262 fi
204263 python3.8 -m pip list
205264
@@ -216,12 +275,12 @@ else
216275 conda clean --all --force-pkgs-dirs -y
217276
218277 # Create testing env
219- conda create -y -p testenv -c " file:// ${WORKSPACE} /conda-bld" -c " https://repo.anaconda.com/pkgs/snowflake/" --override-channels " python=3.8" snowflake-ml-python pytest-xdist inflection " ${OPTIONAL_REQUIREMENTS[@]} "
278+ conda create -y -p testenv -c " ${WORKSPACE} /conda-bld" -c " https://repo.anaconda.com/pkgs/snowflake/" --override-channels " python=3.8" snowflake-ml-python pytest-xdist psutil inflection " ${OPTIONAL_REQUIREMENTS[@]} "
220279 conda list -p testenv
221280
222281 # Run integration tests
223282 set +e
224- TEST_SRCDIR=" ${TEMP_TEST_DIR} " conda run -p testenv --no-capture-output python3.8 -m pytest " ${COMMON_PYTEST_FLAG[@]} " tests/integ/
283+ TEST_SRCDIR=" ${TEMP_TEST_DIR} " conda run -p testenv --no-capture-output python -m pytest " ${COMMON_PYTEST_FLAG[@]} " tests/integ/
225284 TEST_RETCODE=$?
226285 set -e
227286
0 commit comments