Skip to content

Commit

Permalink
Fix build platform environment variable (#13914)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Liam-Sturge authored Feb 7, 2023
1 parent 7323e1d commit c8b99a9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@
# [--net=host] [--cache-from <IMAGE_NAME>] [--cache]
# [--name CONTAINER_NAME] [--context-path <CONTEXT_PATH>]
# [--spec DOCKER_IMAGE_SPEC]
# [--platform <BUILD_PLATFORM>]
# [<COMMAND>]
#
# CONTAINER_TYPE: Type of the docker container used the run the build,
# e.g. "ci_cpu", "ci_gpu"
#
# BUILD_PLATFORM: (Optional) Type of build platform used for the build,
# e.g. "arm", "cpu", "gpu". Defaults to "cpu".
#
# DOCKER_IMAGE_TAG: (Optional) Docker image tag to be built and used.
# Defaults to 'latest', as it is the default Docker tag.
#
Expand Down Expand Up @@ -119,6 +123,14 @@ if [[ "$1" == "--name" ]]; then
shift 2
fi

PLATFORM="cpu"

if [[ "$1" == "--platform" ]]; then
PLATFORM="$2"
echo "Using build platform: ${PLATFORM}"
shift 2
fi

if [[ ! -f "${DOCKERFILE_PATH}" ]]; then
echo "Invalid Dockerfile path: \"${DOCKERFILE_PATH}\""
exit 1
Expand Down Expand Up @@ -227,6 +239,7 @@ if [[ -n ${COMMAND} ]]; then
-e "CI_BUILD_GID=$(id -g)" \
-e "CI_PYTEST_ADD_OPTIONS=$CI_PYTEST_ADD_OPTIONS" \
-e "CI_IMAGE_NAME=${DOCKER_IMAGE_NAME}" \
-e "PLATFORM=${PLATFORM}" \
${CUDA_ENV}\
${CI_DOCKER_EXTRA_PARAMS[@]} \
${DOCKER_IMG_SPEC} \
Expand Down

0 comments on commit c8b99a9

Please sign in to comment.