You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "zachliu (via GitHub)" <gi...@apache.org> on 2024/10/08 20:04:52 UTC

Re: [I] "execute cannot be called outside TaskInstance" warning fired despite being in a TaskInstance [airflow]

zachliu commented on issue #41470:
URL: https://github.com/apache/airflow/issues/41470#issuecomment-2400722201

   @SKalide i think you can simplify your example:
   
   ```python
   from airflow import DAG
   from airflow.utils.dates import days_ago
   from airflow.operators.bash import BashOperator
   
   
   class MyBashOperator(BashOperator):
       def execute(self, context):
           self.log.info(f"Executing {self.__class__.__name__}")
           return super().execute(context)
   
   
   dag = DAG(
       "test_bash_execution",
       default_args={
           "start_date": days_ago(1),
       },
       description="A simple DAG to test MyBashOperator execution",
       schedule_interval=None,
   )
   
   task = MyBashOperator(
       task_id="my_bash_operator",
       bash_command="ls -lah",
       dag=dag,
   )
   ```
   
   this produces the same warning message
   by using this simpler example, i believe it's more convincing that this issue is "serious" :grin: 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org