Hello here,
I have seen recently at least a few times that our users started to use a
strange pattern
@task(task_id='some_id', provide_context=True)
def some_dummy_task(**context):
ti = context['ti']
cmd2 = 'echo "pushing 2"'
dbt_task = BashOperator(task_id='some_dummy_task_id',
bash_command=cmd2,
do_xcom_push=True)
dbt_task.execute(context)`
This **works** for them but then - for example - they complain that xcom is
not pushed (well of course it's not if you use operator and manually run
execute).
Now - while this is a bad pattern - obviously - it seems that our users
**think** they can do itl. And maybe we can do something to prevent them
shooting themselves in their foot?
I do not know that well the @task decoration magic, but maybe we could
somehow detect the case where someone instantiates the operator (and runs
execute) inside a decorated task and give a helpful error in this case? I
am afraid people will start using it more and more and the sooner we add
protection against it, the better chance we have to contain it.
J.