0

Just trying to run the example in: https://github.com/apache/airflow/blob/main/airflow/example_dags/tutorial_etl_dag.py

But basically getting this (removed the try/except at the and and some comments, so line numbers might not match).

Is there something special I need to install?

Traceback (most recent call last):
  File "/usr/local/airflow/d/dags/tc70_test_script.py", line 27, in <module>
    tc70_test_script = tc70_test_script()
  File "/usr/local/lib/python3.6/site-packages/airflow/models/dag.py", line 2984, in factory
    f(**f_kwargs)
  File "/usr/local/airflow/d/dags/tc70_test_script.py", line 9, in tc70_test_script
    @task.docker()
  File "/usr/local/lib/python3.6/site-packages/airflow/decorators/__init__.py", line 33, in __getattr__
    raise AttributeError(f"task decorator {name!r} not found")
AttributeError: task decorator 'docker' not found
Elad Kalif
  • 14,110
  • 2
  • 17
  • 49
Sonny D
  • 11
  • 3

1 Answers1

1

You asked about tutorial_etl_dag.py but your traceback shows tc70_test_script.py which you didn't share the code of that script. The tutorial DAG you shared doesn't use docker.

Docker decorator is part of the docker provider and works only for Airflow >= 2.2.0 & docker provider >=2.2.0 (It's just a coincidence that both has the same version) If you don't have the provider installed you can get it with:

pip install apache-airflow-providers-docker>=2.2.0

Then you can use @task.docker as shown in this example dag.

Elad Kalif
  • 14,110
  • 2
  • 17
  • 49
  • I copied the script to a different file so I could remove things trying to see if I could narrow it down more. I got the same error on the full script, just posted the traceback from the reduced script. Guess I need to update my pip install apache-airflow-providers-docker>=2.2.0 thanks, will try it – Sonny D Feb 11 '22 at 14:34