You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "tomans-storygize (via GitHub)" <gi...@apache.org> on 2025/07/19 00:47:52 UTC

[D] Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner [airflow]

GitHub user tomans-storygize created a discussion: Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner

Apologies in advance if this is covered somewhere, I couldn't find any documentation around this.

My use case is that I want to call the Kubernetes Operator with dynamic arguments based on the context. For example if I am running a backfill I would like to read the current interval from the context and pass them as arguments to my pod command. 

However, since I cannot access the context outside of a task - I cannot leverage the current context while defining off the shelf operators. 

I see this flag and deprecation warning `allow_nested_operators` https://github.com/apache/airflow/blob/4eb776ae19e90ca8aa2c3be890766ec880d925b4/task-sdk/src/airflow/sdk/bases/operator.py#L793-L808

My question is: what is the recommended way to implement `MyOperator(some_config=value_from_context) `

I see the code comment says something to the effect of: working code today will break in the future when the warning turns into an error. 

Any guidance appreciated,
Thanks!

GitHub link: https://github.com/apache/airflow/discussions/53515

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org


Re: [D] Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner [airflow]

Posted by "tomans-storygize (via GitHub)" <gi...@apache.org>.
GitHub user tomans-storygize edited a discussion: Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner

Apologies in advance if this is covered somewhere, I couldn't find any documentation on the topic.

Running 3.0.3

My use case is that I want to call the Kubernetes Operator with dynamic arguments based on the context. 

In particular I am running a backfill and I would like to read the current interval from the context and pass them as arguments to my pod command. 

However, since I cannot access the context outside of a task - I cannot leverage the current context while defining off the shelf operators. 

I see this flag and deprecation warning `allow_nested_operators` https://github.com/apache/airflow/blob/4eb776ae19e90ca8aa2c3be890766ec880d925b4/task-sdk/src/airflow/sdk/bases/operator.py#L793-L808

My question is: what is the recommended way to implement `MyOperator(some_config=value_from_context)`.

I see the code comment says something to the effect of: working code today will break in the future when the warning turns into an error. 

Any guidance appreciated,
Thanks!

GitHub link: https://github.com/apache/airflow/discussions/53515

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org


Re: [D] Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner [airflow]

Posted by "tomans-storygize (via GitHub)" <gi...@apache.org>.
GitHub user tomans-storygize edited a discussion: Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner

Apologies in advance if this is covered somewhere, I couldn't find any documentation around this.

Running 3.0.3

My use case is that I want to call the Kubernetes Operator with dynamic arguments based on the context. For example if I am running a backfill I would like to read the current interval from the context and pass them as arguments to my pod command. 

However, since I cannot access the context outside of a task - I cannot leverage the current context while defining off the shelf operators. 

I see this flag and deprecation warning `allow_nested_operators` https://github.com/apache/airflow/blob/4eb776ae19e90ca8aa2c3be890766ec880d925b4/task-sdk/src/airflow/sdk/bases/operator.py#L793-L808

My question is: what is the recommended way to implement `MyOperator(some_config=value_from_context) `

I see the code comment says something to the effect of: working code today will break in the future when the warning turns into an error. 

Any guidance appreciated,
Thanks!

GitHub link: https://github.com/apache/airflow/discussions/53515

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org


Re: [D] Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner [airflow]

Posted by "tomans-storygize (via GitHub)" <gi...@apache.org>.
GitHub user tomans-storygize edited a discussion: Guidance around nested operators: WARNING: execute cannot be called outside of the Task Runner

Apologies in advance if this is covered somewhere, I couldn't find any documentation on the topic.

Running 3.0.3

My use case is that I want to call the Kubernetes Operator with dynamic arguments based on the context. For example if I am running a backfill I would like to read the current interval from the context and pass them as arguments to my pod command. 

However, since I cannot access the context outside of a task - I cannot leverage the current context while defining off the shelf operators. 

I see this flag and deprecation warning `allow_nested_operators` https://github.com/apache/airflow/blob/4eb776ae19e90ca8aa2c3be890766ec880d925b4/task-sdk/src/airflow/sdk/bases/operator.py#L793-L808

My question is: what is the recommended way to implement `MyOperator(some_config=value_from_context) `

I see the code comment says something to the effect of: working code today will break in the future when the warning turns into an error. 

Any guidance appreciated,
Thanks!

GitHub link: https://github.com/apache/airflow/discussions/53515

----
This is an automatically sent email for commits@airflow.apache.org.
To unsubscribe, please send an email to: commits-unsubscribe@airflow.apache.org