Skip to content

Commit c91f015

Browse files
committed
Enable ignoring missing constraints on py3.14
1 parent d1cc5b5 commit c91f015

7 files changed

Lines changed: 93 additions & 1 deletion

File tree

Dockerfile.ci

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,7 @@ ARG CONSTRAINTS_GITHUB_REPOSITORY="apache/airflow"
17431743
ARG AIRFLOW_CONSTRAINTS_MODE="constraints-source-providers"
17441744
ARG AIRFLOW_CONSTRAINTS_REFERENCE=""
17451745
ARG AIRFLOW_CONSTRAINTS_LOCATION=""
1746+
ARG ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE="false"
17461747
ARG DEFAULT_CONSTRAINTS_BRANCH="constraints-main"
17471748
# By default fallback to installation without constraints because in CI image it should always be tried
17481749
ARG AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION="true"
@@ -1775,6 +1776,7 @@ ENV AIRFLOW_REPO=${AIRFLOW_REPO}\
17751776
AIRFLOW_CONSTRAINTS_MODE=${AIRFLOW_CONSTRAINTS_MODE} \
17761777
AIRFLOW_CONSTRAINTS_REFERENCE=${AIRFLOW_CONSTRAINTS_REFERENCE} \
17771778
AIRFLOW_CONSTRAINTS_LOCATION=${AIRFLOW_CONSTRAINTS_LOCATION} \
1779+
ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE=${ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE} \
17781780
AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION=${AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION} \
17791781
DEFAULT_CONSTRAINTS_BRANCH=${DEFAULT_CONSTRAINTS_BRANCH} \
17801782
AIRFLOW_CI_BUILD_EPOCH=${AIRFLOW_CI_BUILD_EPOCH} \

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,11 +1429,15 @@ def generate_constraints(
14291429
f"--upgrade-to-newer-dependencies\n"
14301430
)
14311431
sys.exit(1)
1432+
# TODO: Remove the Python 3.14 special-case once constraints-3.14.txt exists on the constraints branch.
14321433
if run_in_parallel:
14331434
python_version_list = get_python_version_list(python_versions)
14341435
shell_params_list = [
14351436
ShellParams(
14361437
airflow_constraints_mode=airflow_constraints_mode,
1438+
airflow_fallback_no_constraints_installation=(
1439+
allow_missing_previous_constraints_file and python == "3.14"
1440+
),
14371441
allow_missing_previous_constraints_file=allow_missing_previous_constraints_file,
14381442
github_repository=github_repository,
14391443
python=python,
@@ -1453,6 +1457,9 @@ def generate_constraints(
14531457
else:
14541458
shell_params = ShellParams(
14551459
airflow_constraints_mode=airflow_constraints_mode,
1460+
airflow_fallback_no_constraints_installation=(
1461+
allow_missing_previous_constraints_file and python == "3.14"
1462+
),
14561463
allow_missing_previous_constraints_file=allow_missing_previous_constraints_file,
14571464
github_repository=github_repository,
14581465
python=python,

dev/breeze/src/airflow_breeze/params/build_ci_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ def prepare_arguments_for_docker_build_command(self) -> list[str]:
6868
self._req_arg(
6969
"AIRFLOW_PYTHON_VERSION", ALL_PYTHON_VERSION_TO_PATCHLEVEL_VERSION.get(self.python, self.python)
7070
)
71+
# TODO: Remove this Python 3.14 bootstrap once constraints-source-providers-3.14.txt exists.
72+
if self.python == "3.14":
73+
self._req_arg("ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE", True)
7174
if self.upgrade_to_newer_dependencies:
7275
self._opt_arg("UPGRADE_RANDOM_INDICATOR_STRING", f"{random.randrange(2**32):x}")
7376
# optional build args

dev/breeze/src/airflow_breeze/params/shell_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class ShellParams:
163163
airflow_constraints_location: str = ""
164164
airflow_constraints_mode: str = ALLOWED_CONSTRAINTS_MODES_CI[0]
165165
airflow_constraints_reference: str = ""
166+
airflow_fallback_no_constraints_installation: bool = False
166167
airflow_extras: str = ""
167168
allow_missing_previous_constraints_file: bool = False
168169
allow_pre_releases: bool = False
@@ -631,6 +632,11 @@ def env_variables_for_docker_commands(self) -> dict[str, str]:
631632
"ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE",
632633
self.allow_missing_previous_constraints_file,
633634
)
635+
_set_var(
636+
_env,
637+
"AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION",
638+
self.airflow_fallback_no_constraints_installation,
639+
)
634640
_set_var(_env, "BACKEND", self.backend)
635641
if self.backend == "custom":
636642
_set_var(_env, "AIRFLOW__DATABASE__SQL_ALCHEMY_CONN", self.custom_db_url or None)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
from __future__ import annotations
18+
19+
from airflow_breeze.params.build_ci_params import BuildCiParams
20+
21+
22+
def test_build_ci_params_enables_bootstrap_constraints_download_override_for_python_3_14():
23+
build_args = BuildCiParams(python="3.14").prepare_arguments_for_docker_build_command()
24+
25+
assert "ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE=true" in build_args
26+
27+
28+
def test_build_ci_params_keeps_bootstrap_constraints_download_override_disabled_for_older_python():
29+
build_args = BuildCiParams(python="3.13").prepare_arguments_for_docker_build_command()
30+
31+
assert "ALLOW_MISSING_PREVIOUS_CONSTRAINTS_FILE=true" not in build_args

dev/breeze/tests/test_release_management_commands.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from airflow_breeze.utils.confirm import Answer
2020

2121

22-
def test_generate_constraints_forwards_allow_missing_previous_constraints_file(monkeypatch):
22+
def test_generate_constraints_enables_bootstrap_flags_for_python_3_14(monkeypatch):
2323
import airflow_breeze.commands.release_management_commands as module
2424

2525
captured_shell_params = {}
@@ -50,3 +50,38 @@ def fake_run_generate_constraints(shell_params, output):
5050
)
5151

5252
assert captured_shell_params["value"].allow_missing_previous_constraints_file is True
53+
assert captured_shell_params["value"].airflow_fallback_no_constraints_installation is True
54+
55+
56+
def test_generate_constraints_keeps_no_constraints_fallback_disabled_for_older_python(monkeypatch):
57+
import airflow_breeze.commands.release_management_commands as module
58+
59+
captured_shell_params = {}
60+
61+
monkeypatch.setattr(module, "perform_environment_checks", lambda: None)
62+
monkeypatch.setattr(module, "check_remote_ghcr_io_commands", lambda: None)
63+
monkeypatch.setattr(module, "fix_ownership_using_docker", lambda: None)
64+
monkeypatch.setattr(module, "cleanup_python_generated_files", lambda: None)
65+
monkeypatch.setattr(module, "user_confirm", lambda *args, **kwargs: Answer.YES)
66+
67+
def fake_run_generate_constraints(shell_params, output):
68+
captured_shell_params["value"] = shell_params
69+
return 0, "constraints-source-providers:3.13"
70+
71+
monkeypatch.setattr(module, "run_generate_constraints", fake_run_generate_constraints)
72+
73+
module.generate_constraints.callback(
74+
airflow_constraints_mode="constraints-source-providers",
75+
allow_missing_previous_constraints_file=True,
76+
debug_resources=False,
77+
github_repository="apache/airflow",
78+
parallelism=1,
79+
python="3.13",
80+
python_versions="3.13",
81+
run_in_parallel=False,
82+
skip_cleanup=False,
83+
use_uv=True,
84+
)
85+
86+
assert captured_shell_params["value"].allow_missing_previous_constraints_file is True
87+
assert captured_shell_params["value"].airflow_fallback_no_constraints_installation is False

dev/breeze/tests/test_shell_params.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@
166166
},
167167
id="allow missing previous constraints file",
168168
),
169+
pytest.param(
170+
{},
171+
{"airflow_fallback_no_constraints_installation": True},
172+
{
173+
"AIRFLOW_FALLBACK_NO_CONSTRAINTS_INSTALLATION": "true",
174+
},
175+
id="airflow fallback no constraints installation",
176+
),
169177
pytest.param(
170178
{"PYTHONWARNINGS": "default"},
171179
{},

0 commit comments

Comments
 (0)