-
|
Sometimes when I want to investigate something, it's easiest to it in an interactive shell. In Airflow 2, I could fire up a python shell and run something like: But with Airflow 3, I get:
Is there a way to make this work with Airflow 3? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
Hi, |
Beta Was this translation helpful? Give feedback.
-
|
Generally - in Airflow 3 - see https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html#airflow-3-0-0-2025-04-22 - you are not allowed to use direct DB connection from worker. Your worker is not supposed to connect to the database at all - it uses execution API to retrieve the connection, This is part of the new architecture of Airflow. So it really depends where and in what context you start the shell. If you start it on scheduler, I think it might work, but only via Connection public API in scheduler, not interactive session as you do. The interactive session behaviour you described was never a Public interface of Airflow. You have not described how you start your interactive shell and what stacktrace you get, but generally speaking I think we've never thought about using it this way. If you describe it in detail in a feature request (i.e. allowing to do stuff interactively - with exact proposal on how you would like to intereact with airflow) - I guess we might consider it and turn it into "actual public API" of airflow and we could make it work in specific circumstances. But it should start with describing a general feature for it, what you would like to do, typical operations you think should work etc. Also this might still change in Airflow 3.2 -> we are workign on completing task isolation and when it is done, you will have limited access to Airflow packages on worker and no task-sdk on scheduler, so behaviour of it might still change. One of the things with Airflow 2 and the way you use it that people (like you) used some bits of pieces of Airlfow in their own ways and while it worked "accidentally" - it was never part of the public interface of Airflow. This changed in Airflow 3 where a lot of architectural changes made some things to stop working - and the right way of fixing it is to listen to our users, see how they want to use airflow and implement something they can use in a form of maintainable, publc interface. So if you would like to describe a more complete use case of "interactive use fo some of the airflow components" or similar - that is a good start to have it implemented. |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @potiuk . The DAGs do run on the workers, and they do deal with open connections to DBs. I hear what you are saying though, and think it's a good idea to have a feature request for an interactive shell. For info, here is some workaround code that I'm currently using. I then call |
Beta Was this translation helpful? Give feedback.
Generally - in Airflow 3 - see https://airflow.apache.org/docs/apache-airflow/stable/release_notes.html#airflow-3-0-0-2025-04-22 - you are not allowed to use direct DB connection from worker. Your worker is not supposed to connect to the database at all - it uses execution API to retrieve the connection, This is part of the new architecture of Airflow.
So it really depends where and in what context you start the shell. If you start it on scheduler, I think it might work, but only via Connection public API in scheduler, not interactive session as you do.
The interactive session behaviour you described was never a Public interface of Airflow.
You have not described how you start your intera…