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

Rename CLI flag that specifies execution date #44282

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions airflow/cli/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import argparse
import json
import os
import sys
import textwrap
from collections.abc import Iterable
from typing import Callable, NamedTuple, Union
Expand Down Expand Up @@ -70,6 +71,24 @@ def error(self, message):
self.exit(2, f"\n{self.prog} command error: {message}, see help above.\n")


class _StoreLogicalDateAction(argparse.Action):
"""
Custom action to store a --logical-date value.

Due to backward compatibility, we also accept -e and --exec-date flags. This
custom action emits a deprecation warning when those two flags are used.
"""

def __call__(self, parser, namespace, values, option_string=None):
if option_string in ("-e", "--exec-date"):
sys.stderr.write(
f"Using {option_string} to specify a logical date is "
f"deprecated and will be removed in the future. Please use "
f"--logical-date or -l instead.",
)
super().__call__(parser, namespace, values, option_string=option_string)


# Used in Arg to enable `None' as a distinct value from "not passed"
_UNSET = object()

Expand Down Expand Up @@ -411,7 +430,12 @@ 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 logical date of the DAG", type=parsedate)
ARG_LOGICAL_DATE_FLAG = Arg(
("-l", "--logical-date", "-e", "--exec-date"),
help="The logical date of the DAG",
action=_StoreLogicalDateAction,
type=parsedate,
)
ARG_REPLACE_MICRO = Arg(
("--no-replace-microseconds",),
help="whether microseconds should be zeroed",
Expand Down Expand Up @@ -1136,7 +1160,7 @@ class GroupCommand(NamedTuple):
ARG_SUBDIR,
ARG_RUN_ID,
ARG_CONF,
ARG_EXEC_DATE,
ARG_LOGICAL_DATE_FLAG,
ARG_VERBOSE,
ARG_REPLACE_MICRO,
ARG_OUTPUT,
Expand Down
Loading