Skip to content

Commit

Permalink
Add conf parameter to CLI for airflow dags test
Browse files Browse the repository at this point in the history
  • Loading branch information
Schilling Christian (XC-AD/ETV5) authored and clellmann committed Aug 23, 2022
1 parent 63d38b8 commit be5f504
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions airflow/cli/cli_parser.py
Expand Up @@ -1170,6 +1170,7 @@ class GroupCommand(NamedTuple):
args=(
ARG_DAG_ID,
ARG_EXECUTION_DATE,
ARG_CONF,
ARG_SUBDIR,
ARG_SHOW_DAGRUN,
ARG_IMGCAT_DAGRUN,
Expand Down
5 changes: 5 additions & 0 deletions airflow/cli/commands/dag_command.py
Expand Up @@ -451,13 +451,18 @@ def dag_list_dag_runs(args, dag=None, session=NEW_SESSION):
@cli_utils.action_cli
def dag_test(args, session=None):
"""Execute one single DagRun for a given DAG and execution date, using the DebugExecutor."""
run_conf = None
if args.conf:
run_conf = json.loads(args.conf)

dag = get_dag(subdir=args.subdir, dag_id=args.dag_id)
dag.clear(start_date=args.execution_date, end_date=args.execution_date, dag_run_state=False)
try:
dag.run(
executor=DebugExecutor(),
start_date=args.execution_date,
end_date=args.execution_date,
conf=run_conf,
# Always run the DAG at least once even if no logical runs are
# available. This does not make a lot of sense, but Airflow has
# been doing this prior to 2.2 so we keep compatibility.
Expand Down

0 comments on commit be5f504

Please sign in to comment.