Add Airflow 3.2 in test matrix#2472
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2472 +/- ##
==========================================
+ Coverage 97.97% 98.07% +0.09%
==========================================
Files 103 103
Lines 7455 7465 +10
==========================================
+ Hits 7304 7321 +17
+ Misses 151 144 -7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…st DAGs Resolve merge conflicts with main in cosmos/__init__.py (keep lazy settings import to avoid circular import on Airflow 3.2, use version from main) and tests/test_example_dags.py (take main's version). Upgrade Airflow 3.2 from beta2 to rc2 which contains the ObjectStoragePath credential resolution fix. Remove the redundant 3.2.0b2 special-case in integration-setup.sh. Remove the Airflow >3.1 .airflowignore entries for cosmos_manifest_example.py, cosmos_manifest_selectors_example.py, and cross_project_manifest_dag.py from both test_example_dags.py and test_example_dags_no_connections.py so these DAGs are tested in CI again. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Airflow 3.2 changed the initialization order of airflow.configuration, causing circular imports when providers import conf from it during startup. The official migration path (apache/airflow#60000) is to use the compat SDK import instead. Add type annotations for settings variables used by cache.py since the compat conf lacks the same type stubs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Airflow 3.2 compat conf raises airflow.sdk._shared.configuration.exceptions.AirflowConfigException instead of airflow.exceptions.AirflowConfigException. Catch the SDK exception class when available. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace eager imports with lazy loading via module-level __getattr__. Imports are deferred until first access, which: - Avoids circular imports during Airflow >= 3.2 provider discovery where airflow.configuration is not yet fully initialized - Reduces memory footprint by only loading modules that are used - Makes the enable_memory_optimised_imports setting unnecessary Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Needed for the cross_project_manifest_dag example DAG. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace multiple uv pip install calls with a single pinned requirements file for Airflow 3.2, matching the pattern used by other Airflow versions. Generated via uv pip compile to ensure dependency consistency. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove numpy, scikit-learn, scipy, pandas, db-dtypes, google-cloud-aiplatform, networkx, and paradime-io pins that have Python-version-specific constraints. These are transitive dependencies resolved differently per Python version. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace rc2 with stable 3.2.0 in requirements and remove the --prerelease=allow flag from the pre-install script. Regenerate the requirements file without pre-release packages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pin numpy, scikit-learn, scipy, pandas, networkx, paradime-io, db-dtypes, google-cloud-aiplatform, joblib, and threadpoolctl using versions resolved for Python 3.10, which are compatible across all supported Python versions (3.10-3.13). Also fix RST table alignment in scheduling docs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds Apache Airflow 3.2 to the project’s CI/test matrix and updates Cosmos + tests to remain compatible across Airflow 2.x–3.2, mainly by handling Airflow 3.2 import-path and API changes via backward-compatible fallbacks.
Changes:
- Add Airflow 3.2 to CI/hatch test matrices and add a pinned requirements set for Airflow 3.2 + dbt 1.11.
- Update Airflow imports (Context/context_merge/DagBag/DatasetAlias/conf) with try/except fallbacks for cross-version compatibility.
- Adjust tests/utilities to handle Airflow 3.2 TaskInstance/WeightRule differences via a shared helper.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/utils.py | Use new Airflow 3.2 DagBag import path with fallback to legacy location. |
| tests/operators/test_local.py | Switch to shared TaskInstance factory and update Context import for Airflow 3.2+. |
| tests/operators/test_kubernetes.py | Switch to shared TaskInstance factory and update Context import for Airflow 3.2+. |
| tests/operators/test_gcp_cloud_run_job.py | Update Context import for Airflow 3.2+ compatibility. |
| tests/operators/test_docker.py | Update Context import for Airflow 3.2+ compatibility. |
| tests/operators/test_base.py | Update Context import for Airflow 3.2+ compatibility. |
| tests/operators/test_azure_container_instance.py | Update Context import for Airflow 3.2+ compatibility. |
| tests/operators/test_aws_ecs.py | Update Context import for Airflow 3.2+ compatibility. |
| tests/conftest.py | Add make_task_instance helper to handle Airflow 3.2 WeightRule/TaskInstance behavior. |
| scripts/test/pre-install-airflow.sh | Add install branch for Airflow 3.2 pinned requirements. |
| scripts/test/integration-setup.sh | Harden Airflow version parsing and log detected version. |
| requirements/requirements-airflow-3.2-dbt-1.11.txt | Add fully pinned dependency set for Airflow 3.2 + dbt 1.11. |
| pyproject.toml | Add Airflow 3.2 to hatch test matrix. |
| docs/index.rst | Fix indentation in the main docs toctree. |
| docs/guides/run_dbt/customization/scheduling.rst | Adjust table formatting in scheduling guide. |
| cosmos/settings.py | Use compat conf import and handle SDK config exception differences in Airflow 3.2. |
| cosmos/plugin/airflow3.py | Use compat conf import for Airflow 3.2+. |
| cosmos/operators/kubernetes.py | Update context_merge import to Airflow 3.2 SDK location with fallback. |
| cosmos/operators/base.py | Update context_merge import to Airflow 3.2 SDK location with fallback. |
| cosmos/operators/_asynchronous/bigquery.py | Handle DatasetAlias→AssetAlias import move with fallback for older Airflow. |
| cosmos/init.py | Bump package version to 1.14.0a7. |
| .github/workflows/test.yml | Add Airflow 3.2 to CI matrices and adjust workflow push branch trigger. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fix RST table column alignment in scheduling.rst and fix toctree indentation in index.rst. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
tatiana
left a comment
There was a problem hiding this comment.
Thanks @pankajastro for starting the work, and @pankajkoti for taking it over - Airlfow 3.2.0 was just released, and it will be great to have Cosmos official support to it.
I'm pre-approving the PR, and the merge is subject to the tests passing.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This reverts commit e314270.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 22 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add try/except for Context import in bigquery.py and databricks.py to handle Airflow 3.2 where Context moved to airflow.sdk. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
All tests have passed https://github.com/astronomer/astronomer-cosmos/actions/runs/24088244912?pr=2472 except for the Kubernetes test that appears to be remaining stuck after the merge of PR #2529. Hence, I am going ahead with the merge. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _read_target_sources_json, | ||
| ) | ||
| from cosmos.profiles import PostgresUserPasswordProfileMapping | ||
| from tests.conftest import make_task_instance |
There was a problem hiding this comment.
Avoid importing from tests.conftest in test modules: pytest loads conftest.py as a special plugin module (typically under the name conftest), so importing it as tests.conftest can execute the file a second time under a different module name. Consider moving make_task_instance into a dedicated helper module (e.g., tests/utils_task_instance.py or tests/utils.py) and importing it from there; conftest.py can also import/re-export it if needed.
| from tests.conftest import make_task_instance | |
| from conftest import make_task_instance |
| DbtTestWarningHandler, | ||
| ) | ||
| from cosmos.profiles import PostgresUserPasswordProfileMapping | ||
| from tests.conftest import make_task_instance |
There was a problem hiding this comment.
Avoid importing from tests.conftest in test modules: pytest loads conftest.py as a special plugin module (typically under the name conftest), so importing it as tests.conftest can execute the file a second time under a different module name. Consider moving make_task_instance into a dedicated helper module (e.g., tests/utils_task_instance.py or tests/utils.py) and importing it from there; conftest.py can also import/re-export it if needed.
| from tests.conftest import make_task_instance | |
| from conftest import make_task_instance |
Add Airflow 3.2 to the Cosmos test matrix and resolve all compatibility issues.
Changes
Airflow 3.2 compatibility
requirements-airflow-3.2-dbt-1.11.txtwith versions resolved for Python3.10 compatibility across all supported Python versions
Import path changes for Airflow 3.2
airflow.utils.context.Context→airflow.sdk.definitions.context.Contextairflow.utils.context.context_merge→airflow.sdk.definitions.context.context_mergeairflow.datasets.DatasetAlias→airflow.sdk.definitions.asset.AssetAliasairflow.models.dagbag.DagBag,sync_bag_to_db→airflow.dag_processing.dagbagairflow.configuration.conf→airflow.providers.common.compat.sdk.conf(perUpdate conf imports in providers to use airflow.sdk.configuration apache/airflow#60000)
All import changes use try/except to maintain backward compatibility with older Airflow
versions.
Other fixes
tests/conftest.py)cosmos/settings.py(different exception class inAirflow 3.2)
closes: #2403
Co-authored-by: Pankaj Koti pankajkoti699@gmail.com