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

Cloud composer python311 upgrade #3680

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mjumbewu
Copy link
Contributor

@mjumbewu mjumbewu commented Feb 7, 2025

TESTING IN PROGRESS

  • Update Dockerfile and Dockerfile.composer to use apache/airflow:2.10.2-python3.11
  • Create a requirements-composer-2.11.1-airflow-2.10.2.txt file with the appropriate dependencies
  • Create a Python 3.11 environment and install the dependencies
    pip install -r requirements-composer-2.11.1-airflow-2.10.2.txt -r requirements.txt
  • Verify that the docker image builds at all. Useful to do this as a separate step for better visibility into errors:
    docker build . -t calitp-airflow-test
  • Follow other testing instructions in the airflow/README.md file.

As of 2025 Feb 6, the following packages in requirements.txt of the airflow image need to be updated to work with Python 3.11:

  • boto3 -- our Airflow image was pinned to boto3==1.36.15, which requires botocore 1.29.165, requires urllib3<1.27, which is too old for the newer Composer images.
  • platformdirs -- our image was pinned to platformdirs<3,>=2.5, whereas the current Composer image requires 4.3.6. Oddly, the previous Composer image we were using required platformdirs==3.2.0, so I'm not actually sure how that was working without conflict (except that our requirements were installed after the Composer requirements).
  • pydantic -- We had pinned pydantic==1.9 because of typing extension conflicts, which should no longer be an issue, as we are using Python 3.11 in the new Composer image.

Additionally, the following package version requirements have been loosened in calitp-data-infra:

  • pydantic = ">1.9"
  • pendulum = ">2.1.2"
  • google-cloud-secret-manager = ">2.16.4"

Replaced all imports from pydantic to use pydantic.v1 compatibility layer within Pydantic 2+ (found with pydantic(?!\.v1)).

In order to test the updated calitp-data-infra package, I had to copy the packages folder into the airflow folder, add COPY ./packages/calitp-data-infra/ /tmp/calitp-data-infra/ to the airflow Dockerfile, and then use calitp-data-infra @ file:///tmp/calitp-data-infra in the requirements file.

As a follow-on, we should consider upgrading our use of Pydantic to the latest version. The bump-pydantic tool should help with that.

Description

Describe your changes and why you're making them. Please include the context, motivation, and relevant dependencies.

Resolves #[issue]

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

How has this been tested?

Include commands/logs/screenshots as relevant.

If making changes to dbt models, please run the command poetry run dbt run -s CHANGED_MODEL and poetry run dbt test -s CHANGED_MODEL, then include the output in this section of the PR.

Post-merge follow-ups

Document any actions that must be taken post-merge to deploy or otherwise implement the changes in this PR (for example, running a full refresh of some incremental model in dbt). If these actions will take more than a few hours after the merge or if they will be completed by someone other than the PR author, please create a dedicated follow-up issue and link it here to track resolution.

  • No action required
  • Actions required (specified below)

Includes update to Pydantic 2.x, which requires a change in the imports of the package.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant