Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated library for airflow dev #58

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Difference between this fork and the source

In the [docker container entrypoint file](https://github.com/brightsidehealth/composer-local-dev/blob/9d96b77a13768f697861f0a8305939ee8272b9bc/composer_local_dev/docker_files/entrypoint.sh#L32) we check for the presence of a `PRIVATE_INDEX_URLS` environment variable.
If found then those private indices (in our case packages in Google Cloud Artifact Registry) will be included.
To use, add your comma separated indices via `PRIVATE_INDEX_URLS=<your package indices>` to the `variables.env` file generated by the composer-dev cli.

# Composer Local Development CLI tool

[Google Cloud Privacy Notice](https://cloud.google.com/terms/cloud-privacy-notice)
Expand Down
53 changes: 37 additions & 16 deletions composer_local_dev/docker_files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,51 @@

set -xe

init_airflow() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting this breaks the script

sudo chown airflow:airflow airflow
sudo chown airflow:airflow airflow
sudo chown airflow:airflow .config

mkdir -p ${AIRFLOW__CORE__DAGS_FOLDER}
mkdir -p ${AIRFLOW__CORE__PLUGINS_FOLDER}
mkdir -p ${AIRFLOW__CORE__DATA_FOLDER}

# That file exists in Composer < 1.19.2 and is responsible for linking name
# `python` to python3 exec, in Composer >= 1.19.2 name `python` is already
# linked to python3 and file no longer exist.
if [ -f /var/local/setup_python_command.sh ]; then
/var/local/setup_python_command.sh
fi

pip3 install --upgrade -r composer_requirements.txt
pip3 check
# That file exists in Composer < 1.19.2 and is responsible for linking name
# `python` to python3 exec, in Composer >= 1.19.2 name `python` is already
# linked to python3 and file no longer exist.
if [ -f /var/local/setup_python_command.sh ]; then
/var/local/setup_python_command.sh
fi

if [ -n "${PRIVATE_INDEX_URLS}" ]; then
echo "Adding private PyPI repository indexes: ${PRIVATE_INDEX_URLS}"
pip3 install keyring keyrings.google-artifactregistry-auth

# Split PRIVATE_INDEX_URLS by comma and create a space-separated string of URLs
OLDIFS=$IFS
IFS=','
# shellcheck disable=SC2086
set -- $PRIVATE_INDEX_URLS
IFS=$OLDIFS
EXTRA_INDEX_URLS=""
for url; do
EXTRA_INDEX_URLS="${EXTRA_INDEX_URLS} ${url}"
done
# Export the URLs as an environment variable
export PIP_EXTRA_INDEX_URL="${EXTRA_INDEX_URLS}"
printf 'PIP_EXTRA_INDEX_URL='"${PIP_EXTRA_INDEX_URL}"
fi

# Example usage of PIP_EXTRA_INDEX_URL in pip install
pip3 install --upgrade -r composer_requirements.txt --extra_index_url="${PIP_EXTRA_INDEX_URL}"

pip3 install --upgrade -r composer_requirements.txt
pip3 check

airflow db init

# Allow non-authenticated access to UI for Airflow 2.*
if ! grep -Fxq "AUTH_ROLE_PUBLIC = 'Admin'" /home/airflow/airflow/webserver_config.py; then
echo "AUTH_ROLE_PUBLIC = 'Admin'" >> /home/airflow/airflow/webserver_config.py
fi
}
# Allow non-authenticated access to UI for Airflow 2.*
if ! grep -Fxq "AUTH_ROLE_PUBLIC = 'Admin'" /home/airflow/airflow/webserver_config.py; then
echo "AUTH_ROLE_PUBLIC = 'Admin'" >>/home/airflow/airflow/webserver_config.py
fi

create_user() {
local user_name="$1"
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
)
dependencies = [
"click>=7.0",
"google-auth==2.27.*",
"google-auth==2.30.*",
"google-cloud-orchestration-airflow>=1.2.0",
"google-cloud-artifact-registry>=1.2.0",
"rich_click==1.4.0",
"docker==6.*",
"requests==2.31",
]
extras = {
"tests": ["pytest", "nox", "coverage"],
Expand Down