Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address deprecations, make DeprecationWarning and RemovedInAirflow3Warning raise error #4951

Merged
merged 4 commits into from
Sep 18, 2024

Conversation

AetherUnbound
Copy link
Collaborator

Description

When running ov just catalog/test recently, I noticed that we had a few new deprecation errors:

================================================================================================= warnings summary =================================================================================================
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
tests/dags/common/sensors/test_utils.py:12
  /opt/airflow/catalog/tests/dags/common/sensors/test_utils.py:12: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    TEST_DAG = DAG(TEST_DAG_ID, default_args={"owner": "airflow"})

../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
../../../home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26
  /home/airflow/.local/lib/python3.12/site-packages/airflow/providers/elasticsearch/hooks/elasticsearch.py:26: DeprecationWarning: Importing from the 'elasticsearch.client' module is deprecated. Instead use 'elasticsearch' module for importing the client.
    from elasticsearch.client import SqlClient

tests/dags/providers/test_provider_dag_factory.py::test_apply_configuration_overrides
tests/dags/database/staging_database_restore/test_staging_database_restore.py::test_make_rename_task_group
tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_fails_if_external_dag_does_not_exist
tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_fails_if_external_dag_missing_sensor_task
tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_succeeds_if_no_running_dags
tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_retries_if_running_dags_with_completed_sensor_task
  /home/airflow/.local/lib/python3.12/site-packages/_pytest/python.py:159: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    result = testfunction(**testargs)

tests/dags/common/sensors/test_utils.py::test_get_most_recent_dag_run_returns_most_recent_execution_date
tests/dags/common/sensors/test_utils.py::test_get_most_recent_dag_run_returns_most_recent_execution_date
tests/dags/common/sensors/test_utils.py::test_get_most_recent_dag_run_returns_most_recent_execution_date
  /opt/airflow/catalog/tests/dags/common/sensors/test_utils.py:31: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    _create_dagrun(most_recent - timedelta(days=i), sample_dag_id_fixture)

tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_succeeds_if_no_running_dags
  /opt/airflow/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py:171: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    successful_dag = create_dag(

tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_succeeds_if_no_running_dags
  /opt/airflow/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py:175: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    failed_dag = create_dag("failed_dag", sample_dag_id_fixture, sample_pool_fixture)

tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_succeeds_if_no_running_dags
  /opt/airflow/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py:179: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    queued_dag = create_dag("queued_dag", sample_dag_id_fixture, sample_pool_fixture)

tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_retries_if_running_dags_with_completed_sensor_task
  /opt/airflow/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py:215: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    running_dag = create_dag("running_dag", sample_dag_id_fixture, sample_pool_fixture)

tests/dags/common/sensors/test_single_run_external_dags_sensor.py::test_retries_if_running_dags_with_completed_sensor_task
  /opt/airflow/catalog/tests/dags/common/sensors/test_single_run_external_dags_sensor.py:228: RemovedInAirflow3Warning: Creating a DAG with an implicit schedule is deprecated, and will stop working in a future release. Set `schedule=datetime.timedelta(days=1)` explicitly.
    successful_dependent_dag = create_dag(

This PR:

  1. Addresses the RemovedInAirflow3Warning by adding an enforced schedule to all the DAGs which are referenced in the warning
  2. Ignores the Elasticsearch DeprecationWarning, since that's an upstream issue within Airflow's providers
  3. Sets DeprecationWarning and RemovedInAirflow3Warning to raise an error when they occur

I believe this was the result of #4897, but by default we don't have a whole lot of visibility into deprecation warnings (since they don't show up as an error on CI). This PR changes the warnings so we have to address them as part of any version upgrades we're doing for the catalog. Because of the Airflow constraints file, we shouldn't run into out-of-band deprecation warnings on unrelated PRs; most of the versions of our packages & dependencies are pinned and won't change unless we're updating the version of Airflow itself.

Testing Instructions

  1. Make the following change locally:
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.py
index 5443c9a62..defe225a7 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", schedule=None):
+    with DAG(dag_id="test_make_rename_task_group"):
         group = staging_database_restore.make_rename_task_group("dibble", "crim", rule)
     assert group.group_id == "rename_dibble_to_crim"
     rename, await_rename = list(group)
  1. Run ov just catalog/test
  2. Observe that the RemovedInAirflow3Warning now becomes a test failure rather than appearing in the warnings summary.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@AetherUnbound AetherUnbound requested a review from a team as a code owner September 17, 2024 23:22
@AetherUnbound AetherUnbound added 🟩 priority: low Low priority and doesn't need to be rushed 🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Sep 17, 2024
@AetherUnbound AetherUnbound removed the request for review from a team September 17, 2024 23:22
@AetherUnbound AetherUnbound added the 🧱 stack: catalog Related to the catalog and Airflow DAGs label Sep 17, 2024
Copy link
Contributor

@stacimc stacimc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This PR changes the warnings so we have to address them as part of any version upgrades we're doing for the catalog.

➕ Fantastic, plus one! These are easy to miss.

@AetherUnbound AetherUnbound merged commit a4071d3 into main Sep 18, 2024
44 checks passed
@AetherUnbound AetherUnbound deleted the fix/airflow-implicit-schedule branch September 18, 2024 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖 aspect: dx Concerns developers' experience with the codebase 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟩 priority: low Low priority and doesn't need to be rushed 🧱 stack: catalog Related to the catalog and Airflow DAGs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants