Skip to content

Commit f5b2e89

Browse files
amoghrajeshpotiuk
authored andcommitted
[v3-0-test] Add Python <=> Airflow compat filtering for breeze (#52386)
(cherry picked from commit 3ef4744) Co-authored-by: Amogh Desai <amoghrajesh1999@gmail.com>
1 parent c776d74 commit f5b2e89

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

dev/breeze/src/airflow_breeze/commands/release_management_commands.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
DEFAULT_PYTHON_MAJOR_MINOR_VERSION,
9999
DESTINATION_LOCATIONS,
100100
MULTI_PLATFORM,
101+
PYTHON_TO_MIN_AIRFLOW_MAPPING,
101102
UV_VERSION,
102103
)
103104
from airflow_breeze.params.shell_params import ShellParams
@@ -2756,6 +2757,21 @@ def generate_issue_content_core(
27562757
)
27572758

27582759

2760+
def is_airflow_version_supported_for_python(airflow_version: str, python_version: str) -> bool:
2761+
from packaging.version import Version
2762+
2763+
min_airflow_version = PYTHON_TO_MIN_AIRFLOW_MAPPING.get(python_version)
2764+
if not min_airflow_version:
2765+
return False
2766+
return Version(airflow_version) >= Version(min_airflow_version)
2767+
2768+
2769+
def get_airflow_versions_supported_by_python(
2770+
all_airflow_versions: list[str], python_version: str
2771+
) -> list[str]:
2772+
return [v for v in all_airflow_versions if is_airflow_version_supported_for_python(v, python_version)]
2773+
2774+
27592775
def get_all_constraint_files(
27602776
refresh_constraints: bool,
27612777
python_version: str,
@@ -2764,6 +2780,13 @@ def get_all_constraint_files(
27642780
if refresh_constraints:
27652781
shutil.rmtree(CONSTRAINTS_CACHE_PATH, ignore_errors=True)
27662782
all_airflow_versions, airflow_release_dates = get_active_airflow_versions(confirm=False)
2783+
2784+
get_console().print(
2785+
f"[info]Filtering to only use airflow versions supported by current python version: {python_version}[/]"
2786+
)
2787+
2788+
all_airflow_versions = get_airflow_versions_supported_by_python(all_airflow_versions, python_version)
2789+
27672790
if not CONSTRAINTS_CACHE_PATH.exists():
27682791
with ci_group(f"Downloading constraints for all Airflow versions for Python {python_version}"):
27692792
CONSTRAINTS_CACHE_PATH.mkdir(parents=True, exist_ok=True)

dev/breeze/src/airflow_breeze/global_constants.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
# Checked before putting in build cache
4747
ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS = ["3.9", "3.10", "3.11", "3.12"]
4848
DEFAULT_PYTHON_MAJOR_MINOR_VERSION = ALLOWED_PYTHON_MAJOR_MINOR_VERSIONS[0]
49+
50+
# Maps each supported Python version to the minimum Airflow version that supports it.
51+
# Used to filter Airflow versions incompatible with a given Python runtime.
52+
PYTHON_TO_MIN_AIRFLOW_MAPPING = {"3.10": "2.4.0"}
53+
4954
ALLOWED_ARCHITECTURES = [Architecture.X86_64, Architecture.ARM]
5055
# Database Backends used when starting Breeze. The "none" value means that the configuration is invalid.
5156
# No database will be started - access to a database will fail.

0 commit comments

Comments
 (0)