Fix broken CI due to fastapi incompatibility with cadwyn for Airflow 3#2076
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2076 +/- ##
=======================================
Coverage 97.77% 97.77%
=======================================
Files 91 91
Lines 5848 5848
=======================================
Hits 5718 5718
Misses 130 130 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull Request Overview
This PR addresses a CI failure caused by an incompatibility between cadwyn (used by Airflow for migrations) and fastapi version 0.121.0 released recently. The fix adds an upper bound constraint on the fastapi version to prevent the incompatible version from being installed.
Key changes:
- Added fastapi version constraint to prevent installation of incompatible version 0.121.0
- Updated comment to reference the specific GitHub issue documenting the incompatibility
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tatiana
left a comment
There was a problem hiding this comment.
Thank you very much, @pankajkoti , happy for us to merge this once the checks pass 🎉
#2076) Our CI started failing after fastapi [0.121.0 ](https://pypi.org/project/fastapi/0.121.0/) was released yesterday. It's observed that cadwyn(that airflow uses for its migrations) is [incompatible](zmievsa/cadwyn#305) with the latest the release of fastapi. Hence, putting an upper bound for fastapi version which can be removed once cadwyn becomes compatible. Succesful run: https://github.com/astronomer/astronomer-cosmos/actions/runs/19061976838 closes: #2079 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Bug fixes * Fix ``ExecutionMode.WATCHER`` deadlock in Airflow 3.0 & 3.1 by @tatiana in #2087 * Fix ``ExecutionMode.AIRFLOW_ASYNC`` ``TaskGroup`` XCom issue by @tatiana in #2088 * Guard watcher callback exceptions to avoid hanging producer tasks by @pankajkoti in #2101 * Fix SQL templated field rendering for dynamically mapped tasks in Airflow 2 by @tatiana in #2119 Enhancements * Remove usage of contextmanager in plugins for accessing connections in Airflow >= 3.1.2 by @pankajkoti in #2073 Docs * Improve ``ExecutionMode.AIRFLOW_ASYNC`` docs by @tatiana in #2103 * Add note about experimenting threads count for the Watcher Execution mode by @pankajkoti in #2083 * Fix minor documentation formatting issue by @dnskrv in #2098 * Correct example YAML key from ``operator_args`` to ``operator_kwargs`` by @jx2lee in #2091 Others * Fix broken CI due to fastapi incompatibility with cadwyn for Airflow 3 by @pankajkoti in #2076 * pre-commit autoupdate in #2078, #2104 related: astronomer/oss-integrations-private#272
Bug fixes * Fix ``ExecutionMode.WATCHER`` deadlock in Airflow 3.0 & 3.1 by @tatiana in #2087 * Fix ``ExecutionMode.AIRFLOW_ASYNC`` ``TaskGroup`` XCom issue by @tatiana in #2088 * Guard watcher callback exceptions to avoid hanging producer tasks by @pankajkoti in #2101 * Fix SQL templated field rendering for dynamically mapped tasks in Airflow 2 by @tatiana in #2119 Enhancements * Remove usage of contextmanager in plugins for accessing connections in Airflow >= 3.1.2 by @pankajkoti in #2073 Docs * Improve ``ExecutionMode.AIRFLOW_ASYNC`` docs by @tatiana in #2103 * Add note about experimenting threads count for the Watcher Execution mode by @pankajkoti in #2083 * Fix minor documentation formatting issue by @dnskrv in #2098 * Correct example YAML key from ``operator_args`` to ``operator_kwargs`` by @jx2lee in #2091 Others * Fix broken CI due to fastapi incompatibility with cadwyn for Airflow 3 by @pankajkoti in #2076 * pre-commit autoupdate in #2078, #2104 Closes: astronomer/oss-integrations-private#272
**Context** Over the past few months, we have experienced recurring CI failures caused by dependency conflicts. These issues are not triggered by changes in Cosmos itself, but rather by unpinned and dynamically resolved dependencies. These conflicts have been disruptive, time-consuming to debug, and difficult to reproduce locally. Some recent examples: - #2268 - #2172 - #2076 - #1987 - #1909 - #1902 **Current Situation** We have tried several approaches to mitigate dependency issues: - Dynamically resolving dependencies while restricting requirements as little as possible - Handling Airflow version–specific dependencies individually - Sometimes relying on Airflow constraints (which do not include provider versions), sometimes not - Attempting to isolate dependencies in `pre-install-airflow.sh` More recently, however, Airflow began being reinstalled via `integration-setup.sh`, leading to overlapping installations and Python virtual environments with conflicting packages. Additionally, if we try to recreate the environment locally using the exact dependency list printed by the CI at the end of the “Install packages and dependencies” step, the environment cannot be created due to dependencies conflicts. This results in: - Non-deterministic Python package installation - CI failures that are difficult (or impossible) to reproduce locally - Significant frustration and lost engineering time **Proposed Approach** This PR proposes pinning dependencies more strictly to make our CI environments deterministic and reproducible. I do not believe this is a perfect solution. Some trade-offs include: - We will no longer automatically test against newly released dependency versions - Pinned versions may require manual updates, including potential security updates This PR also does not introduce pip constraints files (since we currently rely on pip install -r). However, it can be viewed as a step toward the approach discussed in: #967 I discussed this proposal with @pankajastro and @pankajkoti, and we agreed it is worth trying. If this strategy does not work well in practice, we can revert to the current approach. **Known Side Effects** The changes in this PR introduce a few limitations: - Tests no longer run the cross-project example DAG (dbt Loom) using the LoadMode.DBT_LS approach, as dbt Loom is now installed in a separate virtual environment due to dependency conflicts. - The S3 load manifest task is no longer executed in the corresponding DAG for Airflow 2.9, due to conflicts between aiobotocore and other dependencies.
Our CI started failing after fastapi 0.121.0 was released yesterday. It's observed that cadwyn(that airflow uses for its migrations) is incompatible with the latest the release of fastapi. Hence, putting an upper bound for fastapi version which can be removed once cadwyn becomes compatible.
Succesful run: https://github.com/astronomer/astronomer-cosmos/actions/runs/19061976838
closes: #2079