You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/08/07 08:07:18 UTC

[GitHub] [airflow] dKosarevsky opened a new issue, #25576: AttributeError: 'TaskInstance' object has no attribute 'task'

dKosarevsky opened a new issue, #25576:
URL: https://github.com/apache/airflow/issues/25576

   ### Apache Airflow version
   
   2.3.3
   
   ### What happened
   
   Try to run task from code and get error:
   
   ```py
   Traceback (most recent call last):
     File "/home/airflow/.local/lib/python3.10/site-packages/airflow/operators/python.py", line 171, in execute
       return_value = self.execute_callable()
     File "/home/airflow/.local/lib/python3.10/site-packages/airflow/operators/python.py", line 189, in execute_callable
       return self.python_callable(*self.op_args, **self.op_kwargs)
     File "/home/airflow/.local/lib/python3.10/site-packages/airflow/utils/session.py", line 71, in wrapper
       return func(*args, session=session, **kwargs)
     File "/opt/airflow/dags/repo/dags/pik_digital/pik_dags/_queued_tasks_runner/__init__.py", line 39, in run_queued_tasks
       ti.dry_run()
     File "/home/airflow/.local/lib/python3.10/site-packages/airflow/models/taskinstance.py", line 1820, in dry_run
       self.task = self.task.prepare_for_execution()
   AttributeError: 'TaskInstance' object has no attribute 'task'
   ```
   
   ### What you think should happen instead
   
   Instead of error task should run. I think it chained with [Hide some task instance attributes in details page #23338](https://github.com/apache/airflow/pull/23338)
   
   ### How to reproduce
   
   ```py
   @provide_session
   def run_queued_tasks(session):
       filter_ = [
           or_(TaskInstance.state == State.QUEUED, TaskInstance.state == State.NONE),
           TaskInstance.queued_dttm < datetime.now(timezone.utc) - timedelta(minutes=20)
       ]
       tis = session.query(TaskInstance).filter(*filter_).all()
   
       if not len(tis):
           raise AirflowSkipException("Skipped. Empty task instances list.")
   
       logger.info(f"Updating {len(tis)} task instances:")
       for ti in tis:
           logger.info(dict(
               dag_id=ti.dag_id,
               task_id=ti.task_id,
               state=ti.state,
               execution_date=ti.execution_date,
           ))
           ti.run(session=session)
   
       session.commit()
       logger.info("Done.")
   ```
   
   ### Operating System
   
   Debian GNU/Linux 11 (bullseye)
   
   ### Versions of Apache Airflow Providers
   
   apache-airflow-providers-amazon==4.0.0
   apache-airflow-providers-celery==3.0.0
   apache-airflow-providers-cncf-kubernetes==4.1.0
   apache-airflow-providers-common-sql==1.0.0
   apache-airflow-providers-docker==3.0.0
   apache-airflow-providers-elasticsearch==4.0.0
   apache-airflow-providers-ftp==3.0.0
   apache-airflow-providers-google==8.1.0
   apache-airflow-providers-grpc==3.0.0
   apache-airflow-providers-hashicorp==3.0.0
   apache-airflow-providers-http==3.0.0
   apache-airflow-providers-imap==3.0.0
   apache-airflow-providers-microsoft-azure==4.0.0
   apache-airflow-providers-microsoft-mssql==3.1.0
   apache-airflow-providers-mysql==3.0.0
   apache-airflow-providers-odbc==3.0.0
   apache-airflow-providers-postgres==5.0.0
   apache-airflow-providers-redis==3.0.0
   apache-airflow-providers-sendgrid==3.0.0
   apache-airflow-providers-sftp==3.0.0
   apache-airflow-providers-slack==5.0.0
   apache-airflow-providers-sqlite==3.0.0
   apache-airflow-providers-ssh==3.0.0
   apache-airflow-providers-telegram==3.0.0
   apache-airflow-providers-vertica==3.1.0
   
   
   
   ### Deployment
   
   Official Apache Airflow Helm Chart
   
   ### Deployment details
   
   terraform, helm, k8s, cloud
   
   ### Anything else
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [ ] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
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.apache.org

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


[GitHub] [airflow] potiuk closed issue #25576: AttributeError: 'TaskInstance' object has no attribute 'task'

Posted by GitBox <gi...@apache.org>.
potiuk closed issue #25576: AttributeError: 'TaskInstance' object has no attribute 'task'
URL: https://github.com/apache/airflow/issues/25576


-- 
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


[GitHub] [airflow] potiuk commented on issue #25576: AttributeError: 'TaskInstance' object has no attribute 'task'

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #25576:
URL: https://github.com/apache/airflow/issues/25576#issuecomment-1207366614

   Nope. You are doing it wrong. Why do you want to run() ti method from within Python Callable ? this is an absolutely unsupported way of using Airflow and expecting it would work is a huge leap of faith.
   
   Where did you get the idea to do it from? can you please point out to the documents, blogs or anything mentioning that you should do it? We need to make a coment that this is something that is completely wrong.


-- 
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