from datetime import datetime
from airflow import DAG
from airflow.decorators import task
from time import sleep
default_args = {
'owner': 'airflow',
'start_date': datetime(2023, 2, 1)
}
with DAG('scheduler', schedule="@daily", catchup=True, default_args=default_args):
@task()
def sleep():
sleep(3600)
sleep()
TypeError: too many positional arguments
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 829 in run
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 1092 in _execute_task
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 408 in wrapper
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 251 in execute
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 408 in wrapper
File "/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py", line 212 in execute
File "/opt/airflow/providers/standard/src/airflow/providers/standard/operators/python.py", line 235 in execute_callable
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/callback_runner.py", line 81 in run
File "/files/dags/scheduler.py", line 15 in sleep
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 363 in __call__
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 513 in apply_defaults
File "/opt/airflow/providers/standard/src/airflow/providers/standard/decorators/python.py", line 58 in __init__
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 513 in apply_defaults
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/decorator.py", line 239 in __init__
File "/usr/local/lib/python3.9/inspect.py", line 3045 in bind
File "/usr/local/lib/python3.9/inspect.py", line 2966 in _bind
The reason for this failure is because the python task has the exact name as the python function. My real code was more complex than the example I share here.. it took me several minutes to figure out what was the issue. Not sure if we can fix it but if we can improve the error message we should
Body
Given code:
It fails with:
The reason for this failure is because the python task has the exact name as the python function. My real code was more complex than the example I share here.. it took me several minutes to figure out what was the issue. Not sure if we can fix it but if we can improve the error message we should
Committer