Add Airflow 3 compatibility for BiqQuery deferrable support (ExecutionMode.AIRFLOW_ASYNC)#1674
Merged
Conversation
143d902 to
6e6d083
Compare
✅ Deploy Preview for sunny-pastelito-5ecb04 canceled.
|
Deploying astronomer-cosmos with
|
| Latest commit: |
27a9681
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d471e8ff.astronomer-cosmos.pages.dev |
| Branch Preview URL: | https://fix-async-bigquery-af3.astronomer-cosmos.pages.dev |
✅ Deploy Preview for sunny-pastelito-5ecb04 canceled.
|
6e6d083 to
fe592f5
Compare
fe592f5 to
4cd2f6a
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1674 +/- ##
==========================================
- Coverage 97.09% 97.08% -0.01%
==========================================
Files 80 80
Lines 5022 5015 -7
==========================================
- Hits 4876 4869 -7
Misses 146 146 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds Airflow 3 compatibility for BigQuery deferrable support by removing the SQLAlchemy session dependency and updating the operator's inheritance, as well as adjusting the example DAG configuration.
- Removed SQLAlchemy session dependency and related DB ORM calls
- Updated base class initialization for DbtRunAirflowAsyncBigqueryOperator
- Added a symlink and updated settings for the Airflow 3 asynchronous DAG example
Reviewed Changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/operators/_asynchronous/test_bigquery.py | Updated test to patch _override_rtif instead of session-dependent RenderedTaskInstanceFields |
| scripts/airflow3/dags/simple_dag_async.py | Added a symlink to the example DAG in the dev directory |
| dev/dags/simple_dag_async.py | Modified path resolution, dataset reference, and schedule parameter for Airflow 3 |
| cosmos/operators/_asynchronous/bigquery.py | Removed session dependency and restructured inheritance for Airflow 3 compatibility |
Files not reviewed (2)
- scripts/airflow3/env.sh: Language not supported
- scripts/airflow3/requirements.txt: Language not supported
Comments suppressed due to low confidence (1)
cosmos/operators/_asynchronous/bigquery.py:110
- Reassigning bases here overrides the previous assignment, which may introduce unintended behavior in the operator's inheritance. Consolidate the modifications into a single base class assignment for clarity.
DbtRunAirflowAsyncBigqueryOperator.__bases__ = (BigQueryInsertJobOperator, AbstractDbtLocalBase,)
tatiana
approved these changes
Apr 17, 2025
Collaborator
tatiana
left a comment
There was a problem hiding this comment.
Excellent work, @pankajkoti !
pankajastro
reviewed
Apr 17, 2025
pankajastro
approved these changes
Apr 17, 2025
pankajastro
approved these changes
Apr 17, 2025
pankajkoti
commented
Apr 17, 2025
tatiana
pushed a commit
that referenced
this pull request
Apr 17, 2025
…nMode.AIRFLOW_ASYNC) (#1674) - Remove SQLAlchemy session dependency and calls to DB ORM - Fix base class inheritance for proper object initialisation wrt Airflow 3 - Add symlink in the airflow3 dags for the simple_dag_async.py example DAG - Set environment variables in airflow3 env to not use setup task for the async DAG until we resolve the Virtualenv execution mode - Add dbt-bigquery and Google provider to requirements.txt in Airflow 3 setup required for the example DAG Closes: #1634
Merged
ExecutionMode.AIRFLOW_ASYNC)
This was referenced Apr 17, 2025
tatiana
pushed a commit
that referenced
this pull request
Apr 17, 2025
PR #1230 introduced the `original_jaffle_shop` project for `ExecutionMode.AIRFLOW_ASYNC`, likely to support early customisations for async execution. Since Cosmos 1.9, we’ve shifted to relying on dbt to generate the SQL, making those customisations unnecessary. As this project isn’t used in any other example DAG, it now seems redundant. I’ve updated the test and example DAG to use `jaffle_shop` instead, which is consistently used across most of our examples. This is a follow-up PR from the discussion in #1674 (comment) related: #1677
tatiana
pushed a commit
that referenced
this pull request
Apr 17, 2025
Main is currently failing for AF3 after merging PR #1674, with the following error: ``` File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/Users/tati/Code/cosmos-fresh/astronomer-cosmos/cosmos/operators/airflow_async.py", line 8, in <module> from cosmos.operators._asynchronous.base import DbtRunAirflowAsyncFactoryOperator File "/Users/tati/Code/cosmos-fresh/astronomer-cosmos/cosmos/operators/_asynchronous/__init__.py", line 12, in <module> from cosmos.operators.virtualenv import DbtRunVirtualenvOperator File "/Users/tati/Code/cosmos-fresh/astronomer-cosmos/cosmos/operators/virtualenv.py", line 11, in <module> from airflow.utils.python_virtualenv import prepare_virtualenv ModuleNotFoundError: No module named 'airflow.utils.python_virtualenv' ``` (as reported by @tatiana) It looks like we need to update the import path for the python_virtualenv module. I had the necessary fix locally but didn’t commit it, as I didn’t realize it would break after removing the setup task. However, since it’s a top-level import, it seems we do need to include the fix after all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
closes: #1634