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

Context deprecation warnings when they aren't used #20213

Closed
1 of 2 tasks
jedcunningham opened this issue Dec 10, 2021 · 3 comments · Fixed by #20217
Closed
1 of 2 tasks

Context deprecation warnings when they aren't used #20213

jedcunningham opened this issue Dec 10, 2021 · 3 comments · Fixed by #20217
Assignees
Labels
area:core kind:bug This is a clearly a bug
Milestone

Comments

@jedcunningham
Copy link
Member

jedcunningham commented Dec 10, 2021

Apache Airflow version

2.2.3rc1 (release candidate)

What happened

I ran a DAG that does nothing explicitly with context, so I'm surprised to see deprecation warnings about context being used (trimmed to cut down on noise):

baseoperator.py:1107 DeprecationWarning: Accessing 'execution_date' from the template is deprecated and will be removed in a future version. Please use 'data_interval_start' or 'logical_date' instead.
baseoperator.py:1107 DeprecationWarning: Accessing 'next_ds' from the template is deprecated and will be removed in a future version. Please use '{{ data_interval_end | ds }}' instead.
baseoperator.py:1107 DeprecationWarning: Accessing 'next_ds_nodash' from the template is deprecated and will be removed in a future version. Please use '{{ data_interval_end | ds_nodash }}' instead.
baseoperator.py:1107 DeprecationWarning: Accessing 'next_execution_date' from the template is deprecated and will be removed in a future version. Please use 'data_interval_end' instead.
baseoperator.py:1107 DeprecationWarning: Accessing 'prev_ds' from the template is deprecated and will be removed in a future version.
baseoperator.py:1107 DeprecationWarning: Accessing 'prev_ds_nodash' from the template is deprecated and will be removed in a future version.
baseoperator.py:1107 DeprecationWarning: Accessing 'prev_execution_date' from the template is deprecated and will be removed in a future version.
baseoperator.py:1107 DeprecationWarning: Accessing 'prev_execution_date_success' from the template is deprecated and will be removed in a future version. Please use 'prev_data_interval_start_success' instead.
baseoperator.py:1107 DeprecationWarning: Accessing 'tomorrow_ds' from the template is deprecated and will be removed in a future version.
baseoperator.py:1107 DeprecationWarning: Accessing 'tomorrow_ds_nodash' from the template is deprecated and will be removed in a future version.
baseoperator.py:1107 DeprecationWarning: Accessing 'yesterday_ds' from the template is deprecated and will be removed in a future version.
baseoperator.py:1107 DeprecationWarning: Accessing 'yesterday_ds_nodash' from the template is deprecated and will be removed in a future version.

What you expected to happen

I'd only expect to see deprecation warnings about things my DAG is actually interacting with.

How to reproduce

Run this DAG:

from datetime import datetime

from airflow import DAG
from airflow.operators.bash import BashOperator

with DAG(
    dag_id="no-context", schedule_interval=None, start_date=datetime(2021, 12, 10)
) as dag:
    BashOperator(task_id="sleep", bash_command="echo 'Hello!'")

Note: I also tried a TaskFlow DAG and that wasn't impacted.

Operating System

MacOS 11.6

Versions of Apache Airflow Providers

No response

Deployment

Virtualenv installation

Deployment details

No response

Anything else

This was introduced in #19886 (cc @uranusjr).

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

@uranusjr
Copy link
Member

We are unpacking the context too eagerly. The rendering functions need to use a much lower level Jinja2 interface.

@raphaelauv
Copy link
Contributor

raphaelauv commented Dec 11, 2021

Warnings are also present in /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87

[2021-12-11, 15:40:15 UTC] {standard_task_runner.py:77} INFO - Job 11: Subtask also_run_this
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'execution_date' from the template is deprecated and will be removed in a future version. Please use 'data_interval_start' or 'logical_date' instead.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'next_ds' from the template is deprecated and will be removed in a future version. Please use '{{ data_interval_end | ds }}' instead.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'next_ds_nodash' from the template is deprecated and will be removed in a future version. Please use '{{ data_interval_end | ds_nodash }}' instead.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'next_execution_date' from the template is deprecated and will be removed in a future version. Please use 'data_interval_end' instead.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'prev_ds' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'prev_ds_nodash' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'prev_execution_date' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'prev_execution_date_success' from the template is deprecated and will be removed in a future version. Please use 'prev_data_interval_start_success' instead.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'tomorrow_ds' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'tomorrow_ds_nodash' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'yesterday_ds' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/utils/log/file_task_handler.py:87 DeprecationWarning: Accessing 'yesterday_ds_nodash' from the template is deprecated and will be removed in a future version.
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} INFO - Running <TaskInstance: a_nice_dag.also_run_this scheduled__2021-12-10T00:00:00+00:00 [running]> on host c1353674fc71
[2021-12-11, 15:40:15 UTC] {logging_mixin.py:109} WARNING - /usr/local/lib/python3.9/site-packages/airflow/models/baseoperator.py:1107 DeprecationWarning: Accessing 'execution_date' from the template is deprecated and will be removed in a future version. Please use 'data_interval_start' or 'logical_date' instead.

@uranusjr
Copy link
Member

Thanks for spotting it, I’ll add the fix to the PR as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants