@@ -38,6 +38,7 @@ WITH_SNOWPARK=false
38
38
MODE=" continuous_run"
39
39
SNOWML_DIR=" snowml"
40
40
SNOWPARK_DIR=" snowpark-python"
41
+ IS_NT=false
41
42
42
43
while (( $# )) ; do
43
44
case $1 in
@@ -74,26 +75,70 @@ while (($#)); do
74
75
shift
75
76
done
76
77
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
+
77
113
# Check Python3.8 exist
78
114
# 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)
86
132
fi
87
- set -eu
88
133
89
134
cd " ${WORKSPACE} "
90
135
91
136
# Check and download yq if not presented.
92
- _YQ_BIN=" yq"
137
+ _YQ_BIN=" yq${EXT} "
93
138
if ! command -v " ${_YQ_BIN} " & > /dev/null; then
94
139
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} "
97
142
fi
98
143
99
144
# Create temp release folder
@@ -109,23 +154,39 @@ echo "Extracted Package Version from code: ${VERSION}"
109
154
OPTIONAL_REQUIREMENTS=()
110
155
while IFS=' ' read -r line; do OPTIONAL_REQUIREMENTS+=(" $line " ); done < <( " ${_YQ_BIN} " ' .requirements.run_constrained.[] | ... style=""' ci/conda_recipe/meta.yaml)
111
156
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
-
118
157
# Compare test required dependencies with wheel pkg dependencies and exclude tests if necessary
119
158
EXCLUDE_TESTS=$( mktemp " ${TEMP_TEST_DIR} /exclude_tests_XXXXX" )
120
159
if [[ ${MODE} = " continuous_run" || ${MODE} = " release" ]]; then
121
160
./ci/get_excluded_tests.sh -f " ${EXCLUDE_TESTS} " -m unused -b " ${BAZEL} "
122
161
elif [[ ${MODE} = " merge_gate" ]]; then
123
162
./ci/get_excluded_tests.sh -f " ${EXCLUDE_TESTS} " -m all -b " ${BAZEL} "
124
163
fi
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
+
125
179
# Copy tests into temp directory
126
180
pushd " ${TEMP_TEST_DIR} "
127
- rsync -av --exclude-from " ${EXCLUDE_TESTS} " " ${WORKSPACE} /${SNOWML_DIR} /tests" .
181
+ rsync -av --exclude-from " ${EXCLUDE_TESTS} " " .. /${SNOWML_DIR} /tests" .
128
182
popd
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
+
129
190
popd
130
191
131
192
# Build snowml package
@@ -149,12 +210,10 @@ if [ "${ENV}" = "pip" ]; then
149
210
150
211
# Build SnowML
151
212
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
153
214
cp " $( ${BAZEL} info bazel-bin) /snowflake/ml/snowflake_ml_python-${VERSION} -py3-none-any.whl" " ${WORKSPACE} "
154
215
popd
155
216
else
156
- which conda
157
-
158
217
# Clean conda cache
159
218
conda clean --all --force-pkgs-dirs -y
160
219
@@ -183,7 +242,7 @@ pushd "${TEMP_TEST_DIR}"
183
242
COMMON_PYTEST_FLAG=()
184
243
COMMON_PYTEST_FLAG+=(--strict-markers) # Strict the pytest markers to avoid typo in markers
185
244
COMMON_PYTEST_FLAG+=(--import-mode=append)
186
- COMMON_PYTEST_FLAG+=(-n 10 )
245
+ COMMON_PYTEST_FLAG+=(-n logical )
187
246
188
247
if [ " ${ENV} " = " pip" ]; then
189
248
# Copy wheel package
@@ -196,10 +255,10 @@ if [ "${ENV}" = "pip" ]; then
196
255
# otherwise it will fail in dependency resolution.
197
256
python3.8 -m pip install --upgrade pip
198
257
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
200
259
if [ " ${WITH_SNOWPARK} " = true ]; then
201
260
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
203
262
fi
204
263
python3.8 -m pip list
205
264
@@ -216,12 +275,12 @@ else
216
275
conda clean --all --force-pkgs-dirs -y
217
276
218
277
# 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[@]} "
220
279
conda list -p testenv
221
280
222
281
# Run integration tests
223
282
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/
225
284
TEST_RETCODE=$?
226
285
set -e
227
286
0 commit comments