Skip to content

Commit c8b99a9

Browse files
authored
Fix build platform environment variable (#13914)
Certain tests that make use of `pytest_wrapper.py`, such as those triggered by `task_python_integration.sh` will fail when a "PLATFORM" environment variable is not set within the Docker container. When using `build.sh` to both create a container, and run a command to execute one of the tests that requires a "PLATFORM", an error will occur due to the missing environment variable. This patch is necessary to add support for this environment variable to `build.sh` and prevent such errors.
1 parent 7323e1d commit c8b99a9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docker/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@
2525
# [--net=host] [--cache-from <IMAGE_NAME>] [--cache]
2626
# [--name CONTAINER_NAME] [--context-path <CONTEXT_PATH>]
2727
# [--spec DOCKER_IMAGE_SPEC]
28+
# [--platform <BUILD_PLATFORM>]
2829
# [<COMMAND>]
2930
#
3031
# CONTAINER_TYPE: Type of the docker container used the run the build,
3132
# e.g. "ci_cpu", "ci_gpu"
3233
#
34+
# BUILD_PLATFORM: (Optional) Type of build platform used for the build,
35+
# e.g. "arm", "cpu", "gpu". Defaults to "cpu".
36+
#
3337
# DOCKER_IMAGE_TAG: (Optional) Docker image tag to be built and used.
3438
# Defaults to 'latest', as it is the default Docker tag.
3539
#
@@ -119,6 +123,14 @@ if [[ "$1" == "--name" ]]; then
119123
shift 2
120124
fi
121125

126+
PLATFORM="cpu"
127+
128+
if [[ "$1" == "--platform" ]]; then
129+
PLATFORM="$2"
130+
echo "Using build platform: ${PLATFORM}"
131+
shift 2
132+
fi
133+
122134
if [[ ! -f "${DOCKERFILE_PATH}" ]]; then
123135
echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\""
124136
exit 1
@@ -227,6 +239,7 @@ if [[ -n ${COMMAND} ]]; then
227239
-e "CI_BUILD_GID=$(id -g)" \
228240
-e "CI_PYTEST_ADD_OPTIONS=$CI_PYTEST_ADD_OPTIONS" \
229241
-e "CI_IMAGE_NAME=${DOCKER_IMAGE_NAME}" \
242+
-e "PLATFORM=${PLATFORM}" \
230243
${CUDA_ENV}\
231244
${CI_DOCKER_EXTRA_PARAMS[@]} \
232245
${DOCKER_IMG_SPEC} \

0 commit comments

Comments
 (0)