Skip to content

First task in Quick Start fails #27799

Closed

Description

@bertiewooster

Apache Airflow version

2.4.3

What happened

When I ran

airflow tasks run example_bash_operator runme_0 2015-01-01

I got the error

(venv) myusername@MacBook-Air airflow % airflow tasks run example_bash_operator runme_0 2015-01-01
[2022-11-14 23:49:19,228] {dagbag.py:537} INFO - Filling up the DagBag from /Users/myusername/airflow/dags
[2022-11-14 23:49:19,228] {cli.py:225} WARNING - Dag '\x1b[01mexample_bash_operator\x1b[22m' not found in path /Users/myusername/airflow/dags; trying path /Users/myusername/airflow/dags
[2022-11-14 23:49:19,228] {dagbag.py:537} INFO - Filling up the DagBag from /Users/myusername/airflow/dags
Traceback (most recent call last):
  File "/Users/myusername/airflow/venv/bin/airflow", line 8, in <module>
    sys.exit(main())
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/__main__.py", line 39, in main
    args.func(args)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/cli/cli_parser.py", line 52, in command
    return func(*args, **kwargs)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/utils/cli.py", line 103, in wrapper
    return f(*args, **kwargs)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/cli/commands/task_command.py", line 366, in task_run
    dag = get_dag(args.subdir, args.dag_id, include_examples=False)
  File "/Users/myusername/airflow/venv/lib/python3.10/site-packages/airflow/utils/cli.py", line 228, in get_dag
    raise AirflowException(
airflow.exceptions.AirflowException: Dag 'example_bash_operator' could not be found; either it does not exist or it failed to parse.

What you think should happen instead

Successful completion of the task

How to reproduce

  1. Create a Python venv based on Python 3.10
  2. Follow the Quick Start instructions through airflow tasks run example_bash_operator runme_0 2015-01-01
  3. The error should appear

Operating System

MacOS 12.5.1

Versions of Apache Airflow Providers

Not applicable

Deployment

Other

Deployment details

This is just on my local machine

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Activity

  1. tirkarthi commented on Nov 20, 2022

    @tirkarthi
    Contributor

    I guess include_examples=False is passed as discussed in commit ce07117 (#26750 (comment)) that could be causing this issue. cc: @ephraimbuddy

  2. ephraimbuddy commented on Nov 21, 2022

    @ephraimbuddy
    Contributor

    Ok. That gained us some speed. I will see if there's a workaround

  3. Almenon commented on Jan 10, 2023

    @Almenon

    I still see this, should this be working as of 2.5.0? Note that I have airflow running in another terminal tab while I execute the command.

    ➜  ~ airflow version
    2.5.0
    ➜  ~ airflow tasks run example_bash_operator runme_0 2015-01-01
    
    [2023-01-10 14:10:48,347] {dagbag.py:538} INFO - Filling up the DagBag from /Users/almenon/airflow/dags
    [2023-01-10 14:10:48,378] {example_local_kubernetes_executor.py:39} WARNING - Could not import DAGs in example_local_kubernetes_executor.py
    Traceback (most recent call last):
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/example_dags/example_local_kubernetes_executor.py", line 37, in <module>
        from kubernetes.client import models as k8s
    ModuleNotFoundError: No module named 'kubernetes'
    [2023-01-10 14:10:48,380] {example_local_kubernetes_executor.py:40} WARNING - Install Kubernetes dependencies with: pip install apache-airflow[cncf.kubernetes]
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): create_entry_group>, delete_entry_group already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): delete_entry_group>, create_entry_group already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): create_entry_gcs>, delete_entry already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): delete_entry>, create_entry_gcs already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): create_tag>, delete_tag already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): delete_tag>, create_tag already registered for DAG: example_complex
    [2023-01-10 14:10:48,389] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,389] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,389] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {example_python_operator.py:90} WARNING - The virtalenv_python example task requires virtualenv, please install it.
    [2023-01-10 14:10:48,391] {tutorial_taskflow_api_virtualenv.py:29} WARNING - The tutorial_taskflow_api_virtualenv example DAG requires virtualenv, please install it.
    [2023-01-10 14:10:48,501] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): prepare_email>, send_email already registered for DAG: example_dag_decorator
    [2023-01-10 14:10:48,501] {taskmixin.py:205} WARNING - Dependency <Task(EmailOperator): send_email>, prepare_email already registered for DAG: example_dag_decorator
    /Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/models/dag.py:3492 RemovedInAirflow3Warning: Param `schedule_interval` is deprecated and will be removed in a future release. Please use `schedule` instead.
    [2023-01-10 14:10:48,518] {example_kubernetes_executor.py:41} WARNING - The example_kubernetes_executor example DAG requires the kubernetes provider. Please install it with: pip install apache-airflow[cncf.kubernetes]
    Traceback (most recent call last):
      File "/Users/almenon/Library/Python/3.9/bin/airflow", line 8, in <module>
        sys.exit(main())
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/__main__.py", line 39, in main
        args.func(args)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/cli_parser.py", line 52, in command
        return func(*args, **kwargs)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/utils/cli.py", line 108, in wrapper
        return f(*args, **kwargs)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/commands/task_command.py", line 384, in task_run
        ti, _ = _get_ti(task, args.map_index, exec_date_or_run_id=args.execution_date_or_run_id, pool=args.pool)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/utils/session.py", line 75, in wrapper
        return func(*args, session=session, **kwargs)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/commands/task_command.py", line 159, in _get_ti
        dag_run, dr_created = _get_dag_run(
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/commands/task_command.py", line 115, in _get_dag_run
        raise DagRunNotFound(
    airflow.exceptions.DagRunNotFound: DagRun for example_bash_operator with run_id or execution_date of '2015-01-01' not found
    
  4. gxcuit commented on Jan 13, 2023

    @gxcuit
    Contributor

    I still see this, should this be working as of 2.5.0? Note that I have airflow running in another terminal tab while I execute the command.

    ➜  ~ airflow version
    2.5.0
    ➜  ~ airflow tasks run example_bash_operator runme_0 2015-01-01
    
    [2023-01-10 14:10:48,347] {dagbag.py:538} INFO - Filling up the DagBag from /Users/almenon/airflow/dags
    [2023-01-10 14:10:48,378] {example_local_kubernetes_executor.py:39} WARNING - Could not import DAGs in example_local_kubernetes_executor.py
    Traceback (most recent call last):
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/example_dags/example_local_kubernetes_executor.py", line 37, in <module>
        from kubernetes.client import models as k8s
    ModuleNotFoundError: No module named 'kubernetes'
    [2023-01-10 14:10:48,380] {example_local_kubernetes_executor.py:40} WARNING - Install Kubernetes dependencies with: pip install apache-airflow[cncf.kubernetes]
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): create_entry_group>, delete_entry_group already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): delete_entry_group>, create_entry_group already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): create_entry_gcs>, delete_entry already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): delete_entry>, create_entry_gcs already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): create_tag>, delete_tag already registered for DAG: example_complex
    [2023-01-10 14:10:48,387] {taskmixin.py:205} WARNING - Dependency <Task(BashOperator): delete_tag>, create_tag already registered for DAG: example_complex
    [2023-01-10 14:10:48,389] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,389] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,389] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): print_the_context>, log_sql_query already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): log_sql_query>, print_the_context already registered for DAG: example_python_operator
    [2023-01-10 14:10:48,390] {example_python_operator.py:90} WARNING - The virtalenv_python example task requires virtualenv, please install it.
    [2023-01-10 14:10:48,391] {tutorial_taskflow_api_virtualenv.py:29} WARNING - The tutorial_taskflow_api_virtualenv example DAG requires virtualenv, please install it.
    [2023-01-10 14:10:48,501] {taskmixin.py:205} WARNING - Dependency <Task(_PythonDecoratedOperator): prepare_email>, send_email already registered for DAG: example_dag_decorator
    [2023-01-10 14:10:48,501] {taskmixin.py:205} WARNING - Dependency <Task(EmailOperator): send_email>, prepare_email already registered for DAG: example_dag_decorator
    /Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/models/dag.py:3492 RemovedInAirflow3Warning: Param `schedule_interval` is deprecated and will be removed in a future release. Please use `schedule` instead.
    [2023-01-10 14:10:48,518] {example_kubernetes_executor.py:41} WARNING - The example_kubernetes_executor example DAG requires the kubernetes provider. Please install it with: pip install apache-airflow[cncf.kubernetes]
    Traceback (most recent call last):
      File "/Users/almenon/Library/Python/3.9/bin/airflow", line 8, in <module>
        sys.exit(main())
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/__main__.py", line 39, in main
        args.func(args)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/cli_parser.py", line 52, in command
        return func(*args, **kwargs)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/utils/cli.py", line 108, in wrapper
        return f(*args, **kwargs)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/commands/task_command.py", line 384, in task_run
        ti, _ = _get_ti(task, args.map_index, exec_date_or_run_id=args.execution_date_or_run_id, pool=args.pool)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/utils/session.py", line 75, in wrapper
        return func(*args, session=session, **kwargs)
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/commands/task_command.py", line 159, in _get_ti
        dag_run, dr_created = _get_dag_run(
      File "/Users/almenon/Library/Python/3.9/lib/python/site-packages/airflow/cli/commands/task_command.py", line 115, in _get_dag_run
        raise DagRunNotFound(
    airflow.exceptions.DagRunNotFound: DagRun for example_bash_operator with run_id or execution_date of '2015-01-01' not found
    

    same issue

  5. tirkarthi commented on Jan 14, 2023

    @tirkarthi
    Contributor

    The initial issue was due to dag not being found since example dags were not loaded. This is due to the execution_date or run_id not found. This is also reported in #28912 . Maybe the example can be improved to use airflow tasks test that creates the dag run and deletes it in the end.

  6. potiuk commented on Jan 15, 2023

    @potiuk
    Member

    Fixed in #28949

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions