Skip to content

Commit

Permalink
fix: extraPipPackages values for airflow 2.9.0+ (#858)
Browse files Browse the repository at this point in the history
Signed-off-by: Mathew Wicks <[email protected]>
  • Loading branch information
thesuperzapper authored May 1, 2024
1 parent 912a037 commit d4624fa
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions charts/airflow/templates/_helpers/pods.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,31 @@ EXAMPLE USAGE: {{ include "airflow.init_container.install_pip_packages" (dict "R
- "bash"
- "-c"
- |
unset PYTHONUSERBASE && \
pip freeze | grep -i {{ range .Values.airflow.protectedPipPackages }}-e {{ printf "%s==" . | quote }} {{ end }} > protected-packages.txt && \
pip install --constraint ./protected-packages.txt --user {{ range .extraPipPackages }}{{ . | quote }} {{ end }} && \
echo "copying '/home/airflow/.local/' to '/opt/home-airflow-local/.local/'..." && \
set -euo pipefail

echo "DANGER: the 'extraPipPackages' feature may cause unexpected runtime errors!"
echo "DANGER: consider building a custom image with the required packages!"
echo ""

pip freeze | grep -i {{ range .Values.airflow.protectedPipPackages }}-e {{ printf "%s==" . | squote }} {{ end }} > protected-packages.txt
{{- range .extraPipPackages }}
echo {{ . | squote }} >> requested-packages.txt
{{- end }}
echo "INFO: ==== PROTECTED PACKAGES ====" && cat protected-packages.txt && echo ""
echo "INFO: ==== REQUESTED PACKAGES ====" && cat requested-packages.txt && echo ""

echo "INFO: ==== RUNNING PIP INSTALL ===="
if [ -n "${VIRTUAL_ENV:-}" ]; then
# airflow >2.9.0 uses virtualenv
pip install --constraint ./protected-packages.txt --requirement ./requested-packages.txt
else
# airflow <2.9.0 uses user-site
pip install --constraint ./protected-packages.txt --requirement ./requested-packages.txt --user
fi
echo ""

echo "INFO: ==== COPYING PACKAGES TO VOLUME ===="
echo "INFO: copying from '/home/airflow/.local/' to '/opt/home-airflow-local/.local/'"
rsync -ah --stats --delete /home/airflow/.local/ /opt/home-airflow-local/.local/
volumeMounts:
- name: home-airflow-local
Expand Down

0 comments on commit d4624fa

Please sign in to comment.