Skip to content

Commit

Permalink
Handle removed source by removal of installed packages (apache#45695)
Browse files Browse the repository at this point in the history
When breeze is run with sources removed, we need to also remove
editable distributions installed from those sources.

If we do not do it, ModuleNotFoundError is thrown where entrypoints
or distribution information are loaded.
  • Loading branch information
potiuk authored and dauinh committed Jan 23, 2025
1 parent 5d22285 commit cd26076
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
16 changes: 10 additions & 6 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,15 @@ function environment_initialization() {
fi
}

function handle_mount_sources() {
if [[ ${MOUNT_SOURCES=} == "remove" ]]; then
echo
echo "${COLOR_BLUE}Mounted sources are removed, cleaning up mounted dist-info files${COLOR_RESET}"
echo
rm -rf /usr/local/lib/python${PYTHON_MAJOR_MINOR_VERSION}/site-packages/apache_airflow*.dist-info/
fi
}

function determine_airflow_to_use() {
USE_AIRFLOW_VERSION="${USE_AIRFLOW_VERSION:=""}"
if [[ ${USE_AIRFLOW_VERSION} == "" && ${USE_PACKAGES_FROM_DIST=} != "true" ]]; then
Expand All @@ -885,12 +894,6 @@ function determine_airflow_to_use() {
mkdir -p "${AIRFLOW_SOURCES}"/logs/
mkdir -p "${AIRFLOW_SOURCES}"/tmp/
else
if [[ ${USE_AIRFLOW_VERSION} =~ 2\.[7-8].* && ${TEST_TYPE} == "Providers[fab]" ]]; then
echo
echo "${COLOR_YELLOW}Skipping FAB tests on Airflow 2.7 and 2.8 because of FAB incompatibility with them${COLOR_RESET}"
echo
exit 0
fi
if [[ ${CLEAN_AIRFLOW_INSTALLATION=} == "true" ]]; then
echo
echo "${COLOR_BLUE}Uninstalling all packages first${COLOR_RESET}"
Expand Down Expand Up @@ -1074,6 +1077,7 @@ function start_webserver_with_examples(){
echo "${COLOR_BLUE}Airflow webserver started${COLOR_RESET}"
}

handle_mount_sources
determine_airflow_to_use
environment_initialization
check_boto_upgrade
Expand Down
17 changes: 11 additions & 6 deletions scripts/docker/entrypoint_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ function environment_initialization() {
fi
}

# Handle mount sources
function handle_mount_sources() {
if [[ ${MOUNT_SOURCES=} == "remove" ]]; then
echo
echo "${COLOR_BLUE}Mounted sources are removed, cleaning up mounted dist-info files${COLOR_RESET}"
echo
rm -rf /usr/local/lib/python${PYTHON_MAJOR_MINOR_VERSION}/site-packages/apache_airflow*.dist-info/
fi
}

# Determine which airflow version to use
function determine_airflow_to_use() {
USE_AIRFLOW_VERSION="${USE_AIRFLOW_VERSION:=""}"
Expand All @@ -203,12 +213,6 @@ function determine_airflow_to_use() {
mkdir -p "${AIRFLOW_SOURCES}"/logs/
mkdir -p "${AIRFLOW_SOURCES}"/tmp/
else
if [[ ${USE_AIRFLOW_VERSION} =~ 2\.[7-8].* && ${TEST_TYPE} == "Providers[fab]" ]]; then
echo
echo "${COLOR_YELLOW}Skipping FAB tests on Airflow 2.7 and 2.8 because of FAB incompatibility with them${COLOR_RESET}"
echo
exit 0
fi
if [[ ${CLEAN_AIRFLOW_INSTALLATION=} == "true" ]]; then
echo
echo "${COLOR_BLUE}Uninstalling all packages first${COLOR_RESET}"
Expand Down Expand Up @@ -396,6 +400,7 @@ function start_webserver_with_examples(){
echo "${COLOR_BLUE}Airflow webserver started${COLOR_RESET}"
}

handle_mount_sources
determine_airflow_to_use
environment_initialization
check_boto_upgrade
Expand Down

0 comments on commit cd26076

Please sign in to comment.