Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Address deprecations, make DeprecationWarning and RemovedInAirflow3Warning raise error (#4951)
Madison Swain-Bowdena4071d3edc9f
diff --git a/catalog/pytest.ini b/catalog/pytest.iniindex 8599a3fea..ddf36bfee 100644--- a/catalog/pytest.ini+++ b/catalog/pytest.ini@@ -19,6 +19,13 @@ addopts =--allow-unix-socket++# ==ERRORS==+# Deprecation warnings and Airflow 3 warnings should be treated as errors so we+# can address them as soon as possible+# ==IGNORATIONS==+# The following warnings are due to upstream dependencies and are not within our+# control to fix. We will ignore them for now.# flask# https://docs.sqlalchemy.org/en/20/errors.html#error-b8d9# Warning in dependency, nothing we can do@@ -30,10 +37,16 @@ addopts =# https://github.com/marshmallow-code/marshmallow/issues/2227# Upstream dependency is fixed but Airflow constraints are keeping us on an# older version+# elasticsearch+# https://github.com/apache/airflow/pull/41871+# Warning in upstream Airflow hook, fixed in the next versionfilterwarnings=+ error::DeprecationWarning+ error::airflow.exceptions.RemovedInAirflow3Warningignore:.*is deprecated and will be (remoevd|removed) in Flask 2.3.:DeprecationWarningignore:datetime.datetime.utcnow:DeprecationWarning:botocoreignore::DeprecationWarning:marshmallow.*+ ignore:Importing from the 'elasticsearch.client' module is deprecated:DeprecationWarning:airflow.providers.elasticsearch.hooks.elasticsearch# Change the pytest cache location since Docker cannot write within the module file# structure due to permissions issuesdiff --git a/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py b/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.pyindex d0f962774..6b11acd98 100644--- a/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py+++ b/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py@@ -37,6 +37,7 @@ def create_dag():with DAG(f"{sample_dag_id_fixture}_{dag_id}",+ schedule=None,default_args={"owner": "airflow","start_date": DEFAULT_DATE,@@ -91,6 +92,7 @@ def test_fails_if_external_dag_does_not_exist(clean_db, setup_pool):):dag = DAG("test_missing_dag_error",+ schedule=None,default_args={"owner": "airflow","start_date": DEFAULT_DATE,@@ -134,6 +136,7 @@ def test_fails_if_external_dag_missing_sensor_task(clean_db, setup_pool):with pytest.raises(AirflowException, match=error_msg):dag = DAG("test_missing_task_error",+ schedule=None,default_args={"owner": "airflow","start_date": DEFAULT_DATE,@@ -182,6 +185,7 @@ def test_succeeds_if_no_running_dags(# Create the Test DAG and sensor with dependent dag Idsdag = DAG("test_dag_success",+ schedule=None,default_args={"owner": "airflow","start_date": DEFAULT_DATE,@@ -233,6 +237,7 @@ def test_retries_if_running_dags_with_completed_sensor_task(# Create the Test DAG and sensor and set up dependent dag Idsdag = DAG("test_dag_failure",+ schedule=None,default_args={"owner": "airflow","start_date": DEFAULT_DATE,diff --git a/catalog/tests/dags/common/sensors/test_utils.py b/catalog/tests/dags/common/sensors/test_utils.pyindex be28e65d9..ff416fd9d 100644--- a/catalog/tests/dags/common/sensors/test_utils.py+++ b/catalog/tests/dags/common/sensors/test_utils.py@@ -9,11 +9,13 @@ from common.sensors.utils import _get_most_recent_dag_runTEST_DAG_ID = "data_refresh_dag_factory_test_dag"-TEST_DAG = DAG(TEST_DAG_ID, default_args={"owner": "airflow"})+TEST_DAG = DAG(TEST_DAG_ID, schedule=None, default_args={"owner": "airflow"})def _create_dagrun(start_date, sample_dag_id_fixture, conf={}):- return DAG(sample_dag_id_fixture, default_args={"owner": "airflow"}).create_dagrun(+ return DAG(+ sample_dag_id_fixture, schedule=None, default_args={"owner": "airflow"}+ ).create_dagrun(start_date=start_date,execution_date=start_date,data_interval=(start_date, start_date),diff --git a/catalog/tests/dags/database/staging_database_restore/test_staging_database_restore.py b/catalog/tests/dags/database/staging_database_restore/test_staging_database_restore.pyindex bbe4da8e9..5443c9a62 100644--- a/catalog/tests/dags/database/staging_database_restore/test_staging_database_restore.py+++ b/catalog/tests/dags/database/staging_database_restore/test_staging_database_restore.py@@ -104,7 +104,7 @@ def test_get_staging_db_details(details, mock_rds_hook):def test_make_rename_task_group():rule = TriggerRule.NONE_FAILED- with DAG(dag_id="test_make_rename_task_group", start_date=datetime(1970, 1, 1)):+ with DAG(dag_id="test_make_rename_task_group", schedule=None):group = staging_database_restore.make_rename_task_group("dibble", "crim", rule)assert group.group_id == "rename_dibble_to_crim"rename, await_rename = list(group)diff --git a/catalog/tests/dags/providers/test_provider_dag_factory.py b/catalog/tests/dags/providers/test_provider_dag_factory.pyindex 9dfb868ad..3eab6397e 100644--- a/catalog/tests/dags/providers/test_provider_dag_factory.py+++ b/catalog/tests/dags/providers/test_provider_dag_factory.py@@ -1,4 +1,4 @@-from datetime import datetime, timedelta+from datetime import timedeltafrom unittest import mockimport pytest@@ -131,7 +131,7 @@ def test_apply_configuration_overrides():# Create a mock DAGdag = DAG(dag_id="test_dag",- start_date=datetime(1970, 1, 1),+ schedule=None,default_args={"execution_timeout": timedelta(hours=1)},)with dag: