datahub/metadata-ingestion/scripts/airflow1-constraints.sh
2022-02-17 00:33:28 -08:00

39 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
HEADER=$(cat <<-EOF
#
# This file helps pip resolve dependencies for Airflow 1.x in a reasonable amount
# of time during testing. Without these constraints, pip will spend hours
# backtracking in an attempt to find a compatible list of versions.
# See https://pip.pypa.io/en/latest/topics/dependency-resolution/#backtracking
# for some explanation of backtracing with the new behavior in pip 20.3+.
#
EOF
)
# Setup a clean virtualenv and install dev deps.
../gradlew clean installDev
# Save a copy of the pip environment.
pip freeze > requirements-dev.txt
# Install Airflow 1.10.15. This will automatically uninstall all incompatible dependencies versions
# and replace them with compatible ones. One minor snag: we need to manually remove the Airflow
# 2.x providers that were split into separate packages, since pip won't remove those automatically.
pip uninstall -y apache-airflow-providers-http apache-airflow-providers-snowflake
pip install -e '.[dev-airflow1-base]'
# Save another copy of the pip environment.
pip freeze > requirements-dev-airflow1.txt
# Add updated dependencies to the constraints file.
# This gets all lines in dev-airflow1.txt that are not in dev.txt.
comm -23 requirements-dev-airflow1.txt requirements-dev.txt > airflow1-constraints-data.txt
# Add a timestamp and comment header to the top of the file.
(echo "# Generated by scripts/airflow1-constraints.sh on $(date)." && echo "$HEADER" && cat airflow1-constraints-data.txt) > tests/airflow1-constraints.txt
# Cleanup.
mv requirements-dev.txt requirements-dev-airflow1.txt airflow1-constraints-data.txt /tmp