Skip to content

Commit

Permalink
Don't explicitly set include_examples to False on task run command (a…
Browse files Browse the repository at this point in the history
…pache#27813)

The speed optimization in apache#26750 where I set include_examples to False
is making it impossible to run the example dag's tasks on the command line.

Removing this to now depend on load_examples config setting.
  • Loading branch information
ephraimbuddy authored Nov 21, 2022
1 parent d8dbdcc commit b9729d9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion airflow/cli/commands/task_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def task_run(args, dag=None):
print(f"Loading pickle id: {args.pickle}")
dag = get_dag_by_pickle(args.pickle)
elif not dag:
dag = get_dag(args.subdir, args.dag_id, include_examples=False)
dag = get_dag(args.subdir, args.dag_id)
else:
# Use DAG from parameter
pass
Expand Down
9 changes: 3 additions & 6 deletions airflow/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from typing import TYPE_CHECKING, Callable, TypeVar, cast

from airflow import settings
from airflow.configuration import conf
from airflow.exceptions import AirflowException
from airflow.utils import cli_action_loggers
from airflow.utils.log.non_caching_file_handler import NonCachingFileHandler
Expand Down Expand Up @@ -212,9 +211,7 @@ def _search_for_dag_file(val: str | None) -> str | None:
return None


def get_dag(
subdir: str | None, dag_id: str, include_examples=conf.getboolean("core", "LOAD_EXAMPLES")
) -> DAG:
def get_dag(subdir: str | None, dag_id: str) -> DAG:
"""
Returns DAG of a given dag_id
Expand All @@ -225,11 +222,11 @@ def get_dag(
from airflow.models import DagBag

first_path = process_subdir(subdir)
dagbag = DagBag(first_path, include_examples=include_examples)
dagbag = DagBag(first_path)
if dag_id not in dagbag.dags:
fallback_path = _search_for_dag_file(subdir) or settings.DAGS_FOLDER
logger.warning("Dag %r not found in path %s; trying path %s", dag_id, first_path, fallback_path)
dagbag = DagBag(dag_folder=fallback_path, include_examples=include_examples)
dagbag = DagBag(dag_folder=fallback_path)
if dag_id not in dagbag.dags:
raise AirflowException(
f"Dag {dag_id!r} could not be found; either it does not exist or it failed to parse."
Expand Down

0 comments on commit b9729d9

Please sign in to comment.