Skip to content

Commit cc1136d

Browse files
committed
Migrate to connexion 2.15
This PR migrates Airflow to connexion 2.15 - which allows Airflow to bump a number of dependencies such as Flask, Werkzeug, flask-session. There are a few incompatibilities fixed during the migration introduced by breaking changes in those dependencies: * flask-session >= 0.8.0 manages it's own session table and we already managed it on our own, so we conditionally create/drop the table when running migrations. * flask-session >= 0.7.9 switched to use MsgSpec as default serializer and while it claims you can switch back to TagJSONSerializer, it's not workign out of the box because it relies on encode/decode methods of the serializer that are not present in TagJSONSerializer. But we cannot use MsgSpec serializer because it does not support some objects (Markup) that we use for Flash message serialization. We borrow a hack from ckan/ckan#8704 and provide our custom serializer deriving from TagJSONSerializer with encode/decode methods added * flask-session >= 0.8.0 switched to use "client" instead of "db" as interface field. Our code was adapted accordingly * Werkzeug >= 2.3.0 changed the way how percent-encoding is done - instead of percent-encoding every reserved character, only the reserved characters that have "reserved purpose" in the place of the URL that they are used are encoded - following WhatWG specification. This means for example that "&" is not encoded in path, "/:" are not encoded in url params, and "?" is not encoded after it is used to separate url from parameters. Our tests expected percent-encoding everywherei (previous Werkzeug behaviour), so they had to be updated. * Flask test client in newer versions of flask does not have "cookie_jar" - it exposes cookies via "get_cookie", tests were updated to use it. * Minimum versions of dependencies have been updated so that all the changes are compatible with them and we do not have to handle back-compatibility with older versions.
1 parent 3cd78b4 commit cc1136d

File tree

69 files changed

+2035
-2910
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+2035
-2910
lines changed

airflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
# under the License.
1818
from __future__ import annotations
1919

20-
__version__ = "2.11.0"
20+
__version__ = "2.11.1"
2121

2222
import os
2323
import sys

airflow/api_internal/internal_api_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _is_retryable_exception(exception: BaseException) -> bool:
135135
stop=tenacity.stop_after_attempt(10),
136136
wait=tenacity.wait_exponential(min=1),
137137
retry=tenacity.retry_if_exception(_is_retryable_exception),
138-
before_sleep=tenacity.before_log(logger, logging.WARNING),
138+
before_sleep=tenacity.before_log(logger, logging.WARNING), # type: ignore[arg-type]
139139
)
140140
def make_jsonrpc_request(method_name: str, params_json: str) -> bytes:
141141
signer = JWTSigner(

airflow/cli/commands/info_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ class FileIoException(Exception):
352352
stop=tenacity.stop_after_attempt(5),
353353
wait=tenacity.wait_exponential(multiplier=1, max=10),
354354
retry=tenacity.retry_if_exception_type(FileIoException),
355-
before=tenacity.before_log(log, logging.DEBUG),
356-
after=tenacity.after_log(log, logging.DEBUG),
355+
before=tenacity.before_log(log, logging.DEBUG), # type: ignore[arg-type]
356+
after=tenacity.after_log(log, logging.DEBUG), # type: ignore[arg-type]
357357
)
358358
def _upload_text_to_fileio(content):
359359
"""Upload text file to File.io service and return link."""

airflow/example_dags/example_branch_operator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def hello_world_with_external_python():
128128

129129
# [START howto_operator_branch_virtualenv]
130130
# Note: Passing a caching dir allows to keep the virtual environment over multiple runs
131-
# Run the example a second time and see that it re-uses it and is faster.
131+
# Run the example a second time and see that it reuses it and is faster.
132132
VENV_CACHE_PATH = Path(tempfile.gettempdir())
133133

134134
def branch_with_venv(choices):

airflow/example_dags/example_branch_operator_decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def some_ext_py_task():
114114

115115
# [START howto_operator_branch_virtualenv]
116116
# Note: Passing a caching dir allows to keep the virtual environment over multiple runs
117-
# Run the example a second time and see that it re-uses it and is faster.
117+
# Run the example a second time and see that it reuses it and is faster.
118118
VENV_CACHE_PATH = tempfile.gettempdir()
119119

120120
@task.branch_virtualenv(requirements=["numpy~=1.26.0"], venv_cache_path=VENV_CACHE_PATH)

airflow/kubernetes/pre_7_4_0_compatibility/kube_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def _enable_tcp_keepalive() -> None:
8686
else:
8787
log.debug("Unable to set TCP_KEEPCNT on this platform")
8888

89-
HTTPSConnection.default_socket_options = HTTPSConnection.default_socket_options + socket_options
90-
HTTPConnection.default_socket_options = HTTPConnection.default_socket_options + socket_options
89+
HTTPSConnection.default_socket_options = HTTPSConnection.default_socket_options + socket_options # type: ignore[operator]
90+
HTTPConnection.default_socket_options = HTTPConnection.default_socket_options + socket_options # type: ignore[operator]
9191

9292

9393
def get_kube_client(

airflow/migrations/versions/0095_2_2_4_add_session_table_to_db.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ def upgrade():
4949
sa.Column("expiry", sa.DateTime()),
5050
sa.PrimaryKeyConstraint("id"),
5151
sa.UniqueConstraint("session_id"),
52+
if_not_exists=True,
5253
)
5354

5455

5556
def downgrade():
5657
"""Unapply Create a ``session`` table to store web session data."""
57-
op.drop_table(TABLE_NAME)
58+
op.drop_table(TABLE_NAME, if_exists=True)

airflow/models/dag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ def _get_task_instances(
20142014
visited_external_tis = set()
20152015

20162016
p_dag = self.parent_dag.partial_subset(
2017-
task_ids_or_regex=r"^{}$".format(self.dag_id.split(".")[1]),
2017+
task_ids_or_regex=rf"^{self.dag_id.split('.')[1]}$",
20182018
include_upstream=False,
20192019
include_downstream=True,
20202020
)

airflow/operators/python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ def _ensure_venv_cache_exists(self, venv_cache_path: Path) -> Path:
820820
if hash_marker.exists():
821821
previous_hash_data = hash_marker.read_text(encoding="utf8")
822822
if previous_hash_data == hash_data:
823-
self.log.info("Re-using cached Python virtual environment in %s", venv_path)
823+
self.log.info("Reusing cached Python virtual environment in %s", venv_path)
824824
return venv_path
825825

826826
_, hash_data_before_upgrade = self._calculate_cache_hash(exclude_cloudpickle=True)

airflow/providers/alibaba/cloud/log/oss_task_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def set_context(self, ti):
7272
self.upload_on_close = not ti.raw
7373

7474
# Clear the file first so that duplicate data is not uploaded
75-
# when re-using the same path (e.g. with rescheduled sensors)
75+
# when reusing the same path (e.g. with rescheduled sensors)
7676
if self.upload_on_close:
7777
with open(self.handler.baseFilename, "w"):
7878
pass

0 commit comments

Comments
 (0)