Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Update Airflow to 2.11.1 (#5640)

Konstantin Obenlandfae50b00bf65
diff --git a/catalog/dags/common/sql.py b/catalog/dags/common/sql.py
index 33d8fac0f..e95d5b194 100644
--- a/catalog/dags/common/sql.py
+++ b/catalog/dags/common/sql.py
@@ -5,7 +5,7 @@ from airflow.decorators import task
from airflow.models import BaseOperator
from airflow.models.abstractoperator import AbstractOperator
from airflow.models.mappedoperator import MappedOperator
-from airflow.providers.common.sql.hooks.sql import fetch_one_handler
+from airflow.providers.common.sql.hooks.handlers import fetch_one_handler
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
from airflow.providers.postgres.hooks.postgres import (
PostgresHook as UpstreamPostgresHook,
diff --git a/catalog/dags/data_refresh/alter_data.py b/catalog/dags/data_refresh/alter_data.py
index 1a9481da4..b7ee52aeb 100644
--- a/catalog/dags/data_refresh/alter_data.py
+++ b/catalog/dags/data_refresh/alter_data.py
@@ -12,7 +12,10 @@ from textwrap import dedent
from airflow.decorators import task, task_group
from airflow.models.abstractoperator import AbstractOperator
-from airflow.providers.common.sql.hooks.sql import fetch_all_handler, fetch_one_handler
+from airflow.providers.common.sql.hooks.handlers import (
+ fetch_all_handler,
+ fetch_one_handler,
+)
from psycopg2.extras import Json
from common.constants import POSTGRES_API_CONN_IDS, Environment
diff --git a/catalog/dags/data_refresh/distributed_reindex.py b/catalog/dags/data_refresh/distributed_reindex.py
index 031a367df..fbd41ad47 100644
--- a/catalog/dags/data_refresh/distributed_reindex.py
+++ b/catalog/dags/data_refresh/distributed_reindex.py
@@ -16,7 +16,7 @@ from airflow.exceptions import AirflowSkipException
from airflow.models.connection import Connection
from airflow.operators.empty import EmptyOperator
from airflow.providers.amazon.aws.hooks.ec2 import EC2Hook
-from airflow.providers.common.sql.hooks.sql import fetch_one_handler
+from airflow.providers.common.sql.hooks.handlers import fetch_one_handler
from airflow.sensors.base import PokeReturnValue
from airflow.utils.trigger_rule import TriggerRule
from requests import Response
diff --git a/catalog/env.template b/catalog/env.template
index 9ddc0861e..3122145d3 100644
--- a/catalog/env.template
+++ b/catalog/env.template
@@ -19,6 +19,9 @@ AIRFLOW__CORE__HIDE_SENSITIVE_VAR_CONN_FIELDS=False
AIRFLOW__WEBSERVER__SECRET_KEY=sample-secret-key=
# Executor to use
AIRFLOW__CORE__EXECUTOR=LocalExecutor
+# Publish timer metrics in milliseconds, the Airflow 3 default. Airflow 2.11 warns
+# on import until this is set, and the test suite treats that warning as an error.
+AIRFLOW__METRICS__TIMER_UNIT_CONSISTENCY=True
# Environment this instance is being run in
AIRFLOW_VAR_ENVIRONMENT=local
diff --git a/catalog/pytest.ini b/catalog/pytest.ini
index ddf36bfee..f52d59455 100644
--- a/catalog/pytest.ini
+++ b/catalog/pytest.ini
@@ -43,7 +43,7 @@ addopts =
filterwarnings=
error::DeprecationWarning
error::airflow.exceptions.RemovedInAirflow3Warning
- ignore:.*is deprecated and will be (remoevd|removed) in Flask 2.3.:DeprecationWarning
+ ignore:.*is deprecated and will be (remoevd|removed) in Flask 2.[0-9].:DeprecationWarning
ignore:datetime.datetime.utcnow:DeprecationWarning:botocore
ignore::DeprecationWarning:marshmallow.*
ignore:Importing from the 'elasticsearch.client' module is deprecated:DeprecationWarning:airflow.providers.elasticsearch.hooks.elasticsearch
diff --git a/catalog/requirements-prod.txt b/catalog/requirements-prod.txt
index 6d22689cb..578620dbd 100644
--- a/catalog/requirements-prod.txt
+++ b/catalog/requirements-prod.txt
@@ -2,12 +2,12 @@
# Note: Unpinned packages have their versions determined by the Airflow constraints file
-apache-airflow[amazon,postgres,http,elasticsearch]==2.10.4
+apache-airflow[amazon,postgres,http,elasticsearch]==2.11.1
backoff==2.2.1
lxml
psycopg2-binary
requests-file
requests-oauthlib
-smart-open[s3]==7.1.0
+smart-open[s3]==7.5.0
tabulate==0.9.0
tldextract==5.3.2
diff --git a/catalog/tests/conftest.py b/catalog/tests/conftest.py
index 43bb28526..c9f0c6a6e 100644
--- a/catalog/tests/conftest.py
+++ b/catalog/tests/conftest.py
@@ -1,3 +1,6 @@
+# Registers the FAB `ab_user` table that `task_instance_note` references; without it,
+# deleting task instances fails to resolve the foreign key.
+import airflow.providers.fab.auth_manager.models # noqa: F401
import pytest
from airflow.models import DagRun, Pool, TaskInstance
from airflow.utils.session import create_session
diff --git a/catalog/tests/dags/common/test_ingestion_server.py b/catalog/tests/dags/common/test_ingestion_server.py
index 1f28e9adf..fac34b665 100644
--- a/catalog/tests/dags/common/test_ingestion_server.py
+++ b/catalog/tests/dags/common/test_ingestion_server.py
@@ -84,9 +84,7 @@ def test_index_readiness_check(
run_type=DagRunType.MANUAL,
)
- with mock.patch(
- "airflow.providers.http.hooks.http.requests.Session.send"
- ) as mock_session_send:
+ with mock.patch("requests.Session.send") as mock_session_send:
r = requests.Response()
r.status_code = response_code
r.reason = "test"