Skip to content

Commit

Permalink
Update setup.py to get non-conflicting set of dependencies (#12636)
Browse files Browse the repository at this point in the history
This change upgrades setup.py and setup.cfg to provide non-conflicting
`pip check` valid set of constraints for CI image.
  • Loading branch information
potiuk authored and ashb committed Dec 3, 2020
1 parent 74e3c56 commit 3f43846
Show file tree
Hide file tree
Showing 13 changed files with 210 additions and 115 deletions.
3 changes: 3 additions & 0 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ This is the current syntax for `./breeze <./breeze>`_:
If you use this flag, automatically --github-registry is enabled.
Default: latest.
-v, --verbose
Expand Down Expand Up @@ -1508,6 +1509,7 @@ This is the current syntax for `./breeze <./breeze>`_:
If you use this flag, automatically --github-registry is enabled.
Default: latest.
-v, --verbose
Expand Down Expand Up @@ -2276,6 +2278,7 @@ This is the current syntax for `./breeze <./breeze>`_:
If you use this flag, automatically --github-registry is enabled.
Default: latest.
****************************************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion CI.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ You can use those variables when you try to reproduce the build locally.
| Image build variables |
+-----------------------------------------+-------------+-------------+------------+-------------------------------------------------+
| ``UPGRADE_TO_LATEST_CONSTRAINTS`` | false | false | false | Determines whether the build should |
| | | | (x) | attempt to eagerly upgrade all |
| | | | (x) | attempt to upgrade all |
| | | | | PIP dependencies to latest ones matching |
| | | | | ``setup.py`` limits. This tries to replicate |
| | | | | the situation of "fresh" user who just installs |
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ Step 4: Prepare PR
the "full tests needed" label is set for your PR. Additional check is set that prevents from
accidental merging of the request until full matrix of tests succeeds for the PR.

* when your change has "upgrade to latest dependencies" label set, constraints will be automatically
* when your change has "upgrade to newer dependencies" label set, constraints will be automatically
upgraded to latest constraints matching your setup.py. This is useful in case you want to force
upgrade to a latest version of dependencies. You can ask committers to set the label for you
when you need it in your PR.
Expand Down
2 changes: 2 additions & 0 deletions breeze
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ function breeze::parse_arguments() {
echo
echo "Force pulling the image, using github registry and skip mounting local sources."
echo "This is in order to get the exact same version as used in CI environment for SHA/RUN_ID!."
echo "You can specify --skip-mounting-local-sources to not mount local sources. "
echo
export FORCE_PULL_IMAGES="true"
export USE_GITHUB_REGISTRY="true"
Expand Down Expand Up @@ -2385,6 +2386,7 @@ function breeze::flag_pull_push_docker_images() {
If you use this flag, automatically --github-registry is enabled.
Default: ${_breeze_default_github_image_id:=}.
"
Expand Down
1 change: 0 additions & 1 deletion scripts/ci/images/ci_prepare_ci_image_on_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,4 @@ function build_ci_image_on_ci() {
export CHECK_IMAGE_FOR_REBUILD="false"
}


build_ci_image_on_ci
36 changes: 3 additions & 33 deletions scripts/ci/images/ci_wait_for_all_ci_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
export AIRFLOW_SOURCES="${AIRFLOW_SOURCES:=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../.." && pwd )}"
echo
echo "Airflow sources: ${AIRFLOW_SOURCES}"
echo "Waiting for all CI images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
echo

if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} != "true" ]]; then
echo
echo "This script should not be called"
echo "It need both USE_GITHUB_REGISTRY and GITHUB_REGISTRY_WAIT_FOR_IMAGE to true!"
echo
echo "USE_GITHUB_REGISTRY = ${USE_GITHUB_REGISTRY}"
echo "GITHUB_REGISTRY_WAIT_FOR_IMAGE =${GITHUB_REGISTRY_WAIT_FOR_IMAGE}"
echo
exit 1
fi

echo
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
echo

echo
echo "Check if jq is installed"
echo
command -v jq >/dev/null || (echo "ERROR! You must have 'jq' tool installed!" && exit 1)

echo
echo "The jq version $(jq --version)"
echo

# shellcheck source=scripts/ci/libraries/_all_libs.sh
source "${AIRFLOW_SOURCES}/scripts/ci/libraries/_all_libs.sh"

initialization::initialize_common_environment

for PYTHON_MAJOR_MINOR_VERSION in ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}
do
export AIRFLOW_CI_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-ci"
push_pull_remove_images::wait_for_github_registry_image "${AIRFLOW_CI_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"
export PYTHON_MAJOR_MINOR_VERSION
"$( dirname "${BASH_SOURCE[0]}" )/ci_wait_for_ci_image.sh"
done
38 changes: 3 additions & 35 deletions scripts/ci/images/ci_wait_for_all_prod_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,12 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
export AIRFLOW_SOURCES="${AIRFLOW_SOURCES:=$( cd "$( dirname "${BASH_SOURCE[0]}" )/../../.." && pwd )}"
echo
echo "Airflow sources: ${AIRFLOW_SOURCES}"
echo "Waiting for all PROD images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
echo

if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} != "true" ]]; then
echo
echo "This script should not be called"
echo "It need both USE_GITHUB_REGISTRY and GITHUB_REGISTRY_WAIT_FOR_IMAGE to true!"
echo
echo "USE_GITHUB_REGISTRY = ${USE_GITHUB_REGISTRY}"
echo "GITHUB_REGISTRY_WAIT_FOR_IMAGE =${GITHUB_REGISTRY_WAIT_FOR_IMAGE}"
echo
exit 1
fi

echo
echo "Waiting for all images to appear: ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}"
echo

echo
echo "Check if jq is installed"
echo
command -v jq >/dev/null || (echo "ERROR! You must have 'jq' tool installed!" && exit 1)

echo
echo "The jq version $(jq --version)"
echo

# shellcheck source=scripts/ci/libraries/_all_libs.sh
source "${AIRFLOW_SOURCES}/scripts/ci/libraries/_all_libs.sh"

initialization::initialize_common_environment

for PYTHON_MAJOR_MINOR_VERSION in ${CURRENT_PYTHON_MAJOR_MINOR_VERSIONS_AS_STRING}
do
export AIRFLOW_PROD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}"
export AIRFLOW_PROD_BUILD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-build"
push_pull_remove_images::wait_for_github_registry_image "${AIRFLOW_PROD_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"
push_pull_remove_images::wait_for_github_registry_image "${AIRFLOW_PROD_BUILD_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"
export PYTHON_MAJOR_MINOR_VERSION
"$( dirname "${BASH_SOURCE[0]}" )/ci_wait_for_prod_image.sh"
done
52 changes: 52 additions & 0 deletions scripts/ci/images/ci_wait_for_ci_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# shellcheck source=scripts/ci/libraries/_script_init.sh
. "$( dirname "${BASH_SOURCE[0]}" )/../libraries/_script_init.sh"

function verify_ci_image_dependencies {
echo
echo "Checking if Airflow dependencies are non-conflicting in CI image."
echo

push_pull_remove_images::pull_image_github_dockerhub "${AIRFLOW_CI_IMAGE}" \
"${GITHUB_REGISTRY_AIRFLOW_CI_IMAGE}:${GITHUB_REGISTRY_PULL_IMAGE_TAG}"

# TODO: remove after we have it fully working
docker run --rm --entrypoint /bin/bash "${AIRFLOW_CI_IMAGE}" -c 'pip check' || true
}

push_pull_remove_images::check_if_github_registry_wait_for_image_enabled

push_pull_remove_images::check_if_jq_installed

build_image::login_to_github_registry_if_needed

export AIRFLOW_CI_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}-ci"

echo
echo "Waiting for image to appear: ${AIRFLOW_CI_IMAGE_NAME}"
echo

push_pull_remove_images::wait_for_github_registry_image \
"${AIRFLOW_CI_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"

echo
echo "Verifying the ${AIRFLOW_CI_IMAGE_NAME} image after pulling it"
echo

verify_ci_image_dependencies
52 changes: 52 additions & 0 deletions scripts/ci/images/ci_wait_for_prod_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# shellcheck source=scripts/ci/libraries/_script_init.sh
. "$( dirname "${BASH_SOURCE[0]}" )/../libraries/_script_init.sh"

function verify_prod_image_dependencies {
echo
echo "Checking if Airflow dependencies are non-conflicting in PROD image."
echo

push_pull_remove_images::pull_image_github_dockerhub "${AIRFLOW_PROD_IMAGE}" \
"${GITHUB_REGISTRY_AIRFLOW_PROD_IMAGE}:${GITHUB_REGISTRY_PULL_IMAGE_TAG}"

# TODO: remove the | true after we fixed pip check for prod image
docker run --rm --entrypoint /bin/bash "${AIRFLOW_PROD_IMAGE}" -c 'pip check' || true
}

push_pull_remove_images::check_if_github_registry_wait_for_image_enabled

push_pull_remove_images::check_if_jq_installed

build_image::login_to_github_registry_if_needed

export AIRFLOW_PROD_IMAGE_NAME="${BRANCH_NAME}-python${PYTHON_MAJOR_MINOR_VERSION}"

echo
echo "Waiting for image to appear: ${AIRFLOW_PROD_IMAGE_NAME}"
echo

push_pull_remove_images::wait_for_github_registry_image \
"${AIRFLOW_PROD_IMAGE_NAME}" "${GITHUB_REGISTRY_PULL_IMAGE_TAG}"

echo
echo "Verifying the ${AIRFLOW_PROD_IMAGE_NAME} image after pulling it"
echo

verify_prod_image_dependencies
43 changes: 21 additions & 22 deletions scripts/ci/libraries/_build_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -346,25 +346,35 @@ function build_images::get_docker_image_names() {

# File that is touched when the CI image is built for the first time locally
export BUILT_CI_IMAGE_FLAG_FILE="${BUILD_CACHE_DIR}/${BRANCH_NAME}/.built_${PYTHON_MAJOR_MINOR_VERSION}"

# GitHub Registry names must be lowercase :(
github_repository_lowercase="$(echo "${GITHUB_REPOSITORY}" |tr '[:upper:]' '[:lower:]')"
export GITHUB_REGISTRY_AIRFLOW_PROD_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/${AIRFLOW_PROD_BASE_TAG}"
export GITHUB_REGISTRY_AIRFLOW_PROD_BUILD_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/${AIRFLOW_PROD_BASE_TAG}-build"
export GITHUB_REGISTRY_PYTHON_BASE_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/python:${PYTHON_BASE_IMAGE_VERSION}-slim-buster"

export GITHUB_REGISTRY_AIRFLOW_CI_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/${AIRFLOW_CI_BASE_TAG}"
export GITHUB_REGISTRY_PYTHON_BASE_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/python:${PYTHON_BASE_IMAGE_VERSION}-slim-buster"
}

# Prepares all variables needed by the CI build. Depending on the configuration used (python version
# DockerHub user etc. the variables are set so that other functions can use those variables.
function build_images::prepare_ci_build() {
export AIRFLOW_CI_LOCAL_MANIFEST_IMAGE="local/${DOCKERHUB_REPO}:${AIRFLOW_CI_BASE_TAG}-manifest"
export AIRFLOW_CI_REMOTE_MANIFEST_IMAGE="${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${AIRFLOW_CI_BASE_TAG}-manifest"
# If GitHub Registry is used, login to the registry using GITHUB_USERNAME and GITHUB_TOKEN
function build_image::login_to_github_registry_if_needed() {
if [[ ${USE_GITHUB_REGISTRY} == "true" ]]; then
if [[ -n ${GITHUB_TOKEN=} ]]; then
echo "${GITHUB_TOKEN}" | docker login \
--username "${GITHUB_USERNAME:-apache}" \
--password-stdin \
"${GITHUB_REGISTRY}"
fi
# GitHub Registry names must be lowercase :(
github_repository_lowercase="$(echo "${GITHUB_REPOSITORY}" |tr '[:upper:]' '[:lower:]')"
export GITHUB_REGISTRY_AIRFLOW_CI_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/${AIRFLOW_CI_BASE_TAG}"
export GITHUB_REGISTRY_PYTHON_BASE_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/python:${PYTHON_BASE_IMAGE_VERSION}-slim-buster"
fi

}

# Prepares all variables needed by the CI build. Depending on the configuration used (python version
# DockerHub user etc. the variables are set so that other functions can use those variables.
function build_images::prepare_ci_build() {
export AIRFLOW_CI_LOCAL_MANIFEST_IMAGE="local/${DOCKERHUB_REPO}:${AIRFLOW_CI_BASE_TAG}-manifest"
export AIRFLOW_CI_REMOTE_MANIFEST_IMAGE="${DOCKERHUB_USER}/${DOCKERHUB_REPO}:${AIRFLOW_CI_BASE_TAG}-manifest"
export THE_IMAGE_TYPE="CI"
export IMAGE_DESCRIPTION="Airflow CI"

Expand All @@ -375,6 +385,7 @@ function build_images::prepare_ci_build() {
export AIRFLOW_IMAGE="${AIRFLOW_CI_IMAGE}"
readonly AIRFLOW_IMAGE

build_image::login_to_github_registry_if_needed
sanity_checks::go_to_airflow_sources
permissions::fix_group_permissions
}
Expand Down Expand Up @@ -662,19 +673,7 @@ function build_images::prepare_prod_build() {
export AIRFLOW_IMAGE="${AIRFLOW_PROD_IMAGE}"
readonly AIRFLOW_IMAGE

if [[ ${USE_GITHUB_REGISTRY="false"} == "true" ]]; then
if [[ -n ${GITHUB_TOKEN=} ]]; then
echo "${GITHUB_TOKEN}" | docker login \
--username "${GITHUB_USERNAME}" \
--password-stdin \
"${GITHUB_REGISTRY}"
fi
# GitHub Registry names must be lowercase :(
github_repository_lowercase="$(echo "${GITHUB_REPOSITORY}" |tr '[:upper:]' '[:lower:]')"
export GITHUB_REGISTRY_AIRFLOW_PROD_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/${AIRFLOW_PROD_BASE_TAG}"
export GITHUB_REGISTRY_AIRFLOW_PROD_BUILD_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/${AIRFLOW_PROD_BASE_TAG}-build"
export GITHUB_REGISTRY_PYTHON_BASE_IMAGE="${GITHUB_REGISTRY}/${github_repository_lowercase}/python:${PYTHON_BASE_IMAGE_VERSION}-slim-buster"
fi
build_image::login_to_github_registry_if_needed

AIRFLOW_BRANCH_FOR_PYPI_PRELOADING="${BRANCH_NAME}"
sanity_checks::go_to_airflow_sources
Expand Down
44 changes: 38 additions & 6 deletions scripts/ci/libraries/_push_pull_remove_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,18 @@ function push_pull_remove_images::push_prod_images() {

# waits for an image to be available in the github registry
function push_pull_remove_images::wait_for_github_registry_image() {
local github_repository_lowercase
github_repository_lowercase="$(echo "${GITHUB_REPOSITORY}" |tr '[:upper:]' '[:lower:]')"
GITHUB_API_ENDPOINT="https://${GITHUB_REGISTRY}/v2/${github_repository_lowercase}"
IMAGE_NAME="${1}"
IMAGE_TAG=${2}
echo "Waiting for ${IMAGE_NAME}:${IMAGE_TAG} image"
local github_api_endpoint
github_api_endpoint="https://${GITHUB_REGISTRY}/v2/${github_repository_lowercase}"
local image_name_in_github_registry="${1}"
local image_tag_in_github_registry=${2}

GITHUB_API_CALL="${GITHUB_API_ENDPOINT}/${IMAGE_NAME}/manifests/${IMAGE_TAG}"
echo
echo "Waiting for ${GITHUB_REPOSITORY}/${image_name_in_github_registry}:${image_tag_in_github_registry} image"
echo

GITHUB_API_CALL="${github_api_endpoint}/${image_name_in_github_registry}/manifests/${image_tag_in_github_registry}"
while true; do
curl -X GET "${GITHUB_API_CALL}" -u "${GITHUB_USERNAME}:${GITHUB_TOKEN}" 2>/dev/null > "${OUTPUT_LOG}"
local digest
Expand All @@ -282,6 +287,33 @@ function push_pull_remove_images::wait_for_github_registry_image() {
fi
sleep 10
done
verbosity::print_info "Found ${IMAGE_NAME}:${IMAGE_TAG} image"
verbosity::print_info "Found ${image_name_in_github_registry}:${image_tag_in_github_registry} image"
verbosity::print_info "Digest: '${digest}'"
}

function push_pull_remove_images::check_if_github_registry_wait_for_image_enabled() {
if [[ ${USE_GITHUB_REGISTRY} != "true" || ${GITHUB_REGISTRY_WAIT_FOR_IMAGE} != "true" ]]; then
echo
echo "This script should not be called"
echo "It need both USE_GITHUB_REGISTRY and GITHUB_REGISTRY_WAIT_FOR_IMAGE to true!"
echo
echo "USE_GITHUB_REGISTRY = ${USE_GITHUB_REGISTRY}"
echo "GITHUB_REGISTRY_WAIT_FOR_IMAGE =${GITHUB_REGISTRY_WAIT_FOR_IMAGE}"
echo
exit 1
else
echo
echo "Both USE_GITHUB_REGISTRY and GITHUB_REGISTRY_WAIT_FOR_IMAGE are set to true. Good!"
fi
}

function push_pull_remove_images::check_if_jq_installed() {
echo
echo "Check if jq is installed"
echo
command -v jq >/dev/null || (echo "ERROR! You must have 'jq' tool installed!" && exit 1)

echo
echo "The jq version $(jq --version)"
echo
}
Loading

0 comments on commit 3f43846

Please sign in to comment.