-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Rename execution_date to logical_date across codebase #43902
base: main
Are you sure you want to change the base?
Rename execution_date to logical_date across codebase #43902
Conversation
ea36b6c
to
65f9b8e
Compare
This needs a news fragment. Rewording the above summary would work fine. See existing files in |
Oh wait, we’re not removing those in this PR yet, so this should not be mentioned at all. |
@@ -410,7 +410,7 @@ def string_lower_type(val): | |||
# trigger_dag | |||
ARG_RUN_ID = Arg(("-r", "--run-id"), help="Helps to identify this run") | |||
ARG_CONF = Arg(("-c", "--conf"), help="JSON string that gets pickled into the DagRun's conf attribute") | |||
ARG_EXEC_DATE = Arg(("-e", "--exec-date"), help="The execution date of the DAG", type=parsedate) | |||
ARG_EXEC_DATE = Arg(("-e", "--exec-date"), help="The logical date of the DAG", type=parsedate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also rename this flag in a future PR.
providers/src/airflow/providers/cncf/kubernetes/cli/kubernetes_command.py
Outdated
Show resolved
Hide resolved
5184a34
to
12bc242
Compare
12bc242
to
9897584
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs to mention that some keys in the context have been removed.
@@ -451,7 +426,6 @@ def context_copy_partial(source: Context, keys: Container[str]) -> Context: | |||
:meta private: | |||
""" | |||
new = Context({k: v for k, v in source._context.items() if k in keys}) | |||
new._deprecation_replacements = source._deprecation_replacements.copy() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should not be removed.
logical_date = ( | ||
dag_run.logical_date.isoformat() if AIRFLOW_V_3_0_PLUS else dag_run.execution_date.isoformat() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logical_date = ( | |
dag_run.logical_date.isoformat() if AIRFLOW_V_3_0_PLUS else dag_run.execution_date.isoformat() | |
) | |
logical_date = dag_run.logical_date.isoformat() |
dag_run.logical_date
is available on Airflow 2.
AIRFLOW_VERSION = Version(airflow_version) | ||
AIRFLOW_V_3_0_PLUS = Version(AIRFLOW_VERSION.base_version) >= Version("3.0.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed anymore?
AIRFLOW_VERSION = Version(airflow_version) | ||
AIRFLOW_V_3_0_PLUS = Version(AIRFLOW_VERSION.base_version) >= Version("3.0.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed?
logical_date = ( | ||
dag_run.logical_date.isoformat() if AIRFLOW_V_3_0_PLUS else dag_run.execution_date.isoformat() | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logical_date = ( | |
dag_run.logical_date.isoformat() if AIRFLOW_V_3_0_PLUS else dag_run.execution_date.isoformat() | |
) | |
logical_date = dag_run.logical_date.isoformat() |
return ( | ||
log_id_template.format( | ||
dag_id=ti.dag_id, | ||
task_id=ti.task_id, | ||
run_id=getattr(ti, "run_id", ""), | ||
data_interval_start=data_interval_start, | ||
data_interval_end=data_interval_end, | ||
logical_date=logical_date, | ||
try_number=try_number, | ||
map_index=getattr(ti, "map_index", ""), | ||
) | ||
if AIRFLOW_V_3_0_PLUS | ||
else log_id_template.format( | ||
dag_id=ti.dag_id, | ||
task_id=ti.task_id, | ||
run_id=getattr(ti, "run_id", ""), | ||
data_interval_start=data_interval_start, | ||
data_interval_end=data_interval_end, | ||
execution_date=logical_date, | ||
try_number=try_number, | ||
map_index=getattr(ti, "map_index", ""), | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ( | |
log_id_template.format( | |
dag_id=ti.dag_id, | |
task_id=ti.task_id, | |
run_id=getattr(ti, "run_id", ""), | |
data_interval_start=data_interval_start, | |
data_interval_end=data_interval_end, | |
logical_date=logical_date, | |
try_number=try_number, | |
map_index=getattr(ti, "map_index", ""), | |
) | |
if AIRFLOW_V_3_0_PLUS | |
else log_id_template.format( | |
dag_id=ti.dag_id, | |
task_id=ti.task_id, | |
run_id=getattr(ti, "run_id", ""), | |
data_interval_start=data_interval_start, | |
data_interval_end=data_interval_end, | |
execution_date=logical_date, | |
try_number=try_number, | |
map_index=getattr(ti, "map_index", ""), | |
) | |
) | |
return log_id_template.format( | |
dag_id=ti.dag_id, | |
task_id=ti.task_id, | |
run_id=getattr(ti, "run_id", ""), | |
data_interval_start=data_interval_start, | |
data_interval_end=data_interval_end, | |
execution_date=logical_date, # Airlow 2 Compatibility. | |
logical_date=logical_date, | |
try_number=try_number, | |
map_index=ti.map_index, | |
) |
task_info = { | ||
"dag_id": context_var["dag_id"], | ||
"task_id": context_var["task_id"], | ||
"execution_date": context_var["execution_date"], | ||
date_key: context_var["logical_date"] if AIRFLOW_V_3_0_PLUS else context_var["execution_date"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date_key: context_var["logical_date"] if AIRFLOW_V_3_0_PLUS else context_var["execution_date"], | |
date_key: context_var["logical_date"], |
@@ -310,7 +309,7 @@ def get_tasks_to_skip(): | |||
self.skip( | |||
dag_run=dag_run, | |||
tasks=to_skip, | |||
execution_date=cast("DateTime", dag_run.execution_date), # type: ignore[call-arg] | |||
execution_date=cast("DateTime", dag_run.execution_date), # type: ignore[call-arg, union-attr] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execution_date=cast("DateTime", dag_run.execution_date), # type: ignore[call-arg, union-attr] | |
execution_date=cast("DateTime", dag_run.logical_date), # type: ignore[call-arg, union-attr] |
"prev_data_interval_end_success", | ||
"prev_data_interval_start_success", | ||
"prev_execution_date", | ||
"prev_execution_date_success", | ||
"prev_start_date_success", | ||
"prev_end_date_success", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can not be deleted; the operator will not work correctly on Airflow 2. We can add comments these should be deleted when we drop Airflow 2 support on the provider.
task_info = { | ||
"dag_id": context_var["dag_id"], | ||
"task_id": context_var["task_id"], | ||
"execution_date": context_var["execution_date"], | ||
date_key: context_var["logical_date"] if AIRFLOW_V_3_0_PLUS else context_var["execution_date"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
date_key: context_var["logical_date"] if AIRFLOW_V_3_0_PLUS else context_var["execution_date"], | |
date_key: context_var["logical_date"], |
AIRFLOW_VERSION = Version(airflow_version) | ||
AIRFLOW_V_3_0_PLUS = Version(AIRFLOW_VERSION.base_version) >= Version("3.0.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed?
Motivation
This PR renames
execution_date
tological_date
across the codebase. The shift towardslogical_date
helps move away from the limitations ofexecution_date
, particularly with dynamic DAG runs and cases where multiple runs occur at the same time.Key Changes
execution_date
withlogical_date
including models.execution_date
in the database to allow multiple DAG runs with the same logical time.How
execution_date
andlogical_date
WorkTransitioning from
execution_date
execution_date
.run_id
for human-readable identifiers.data_interval_start
/data_interval_end
for data partitioning in future.id
(auto-incremented) is recommended for ordering DAG runs.execution_date
, switch to usingdata_interval_start
ordata_interval_end
for identifying time ranges.Testing
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.