Skip to content

use of debugpy to run airflow components via breeze #51763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rawwar
Copy link
Contributor

@rawwar rawwar commented Jun 15, 2025

Using debugpy to run airflow components so that we can use IDE's as Vscode to attach to the component to debug.

Ports for components are as follows:

BREEZE_DEBUG_SCHEDULER_PORT = "50231"
BREEZE_DEBUG_DAG_PROCESSOR_PORT = "50232"
BREEZE_DEBUG_API_SERVER_PORT = "50233"
BREEZE_DEBUG_CELERY_WORKER_PORT = "50234"
BREEZE_DEBUG_EDGE_PORT = "50235"
BREEZE_DEBUG_FLOWER_PORT = "50236"

Env variables to use debugpy to run a component are below

BREEZE_DEBUG_SCHEDULER
BREEZE_DEBUG_APISERVER or BREEZE_DEBUG_WEBSERVER
BREEZE_DEBUG_TRIGGERER_PORT
BREEZE_DEBUG_CELERY_WORKER_PORT
BREEZE_DEBUG_FLOWER
BREEZE_DEBUG_EDGE
BREEZE_DEBUG_DAG_PROCESSOR

When using breeze, we can add above env to files/airflow-breeze-config/environment_variables.env.

For example, to run the scheduler via debugpy:

BREEZE_DEBUG_SCHEDULER=true

debugpy will be listening at port 50231. I use VS Code. So, I can add the following to the configuration in "launch.json" and start debugging:

{
            "name": "Scheduler Debug(Breeze)",
            "type": "debugpy",
            "request": "attach",
            "justMyCode": false,
            "connect": {
                "host": "localhost",
                "port": 50231,
            },
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "/opt/airflow"
                }
            ]
        },

Once I start breeze, the Scheduler pane will be waiting as shown in the screenshot:
image

In VSCode, I can place an arbitrary debug point and start debugging and it will pause as shown below:

image

I am sure this can be done via PyCharm as well, but I haven't tested it yet.

@rawwar rawwar requested review from jason810496 and jscheffl June 15, 2025 16:17
Copy link
Contributor

@jscheffl jscheffl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty cool!

Can you add something about this into the Contribution docs as well?
...and would it make sense adding this to breeze CLI as command line instead of ENV?

@rawwar
Copy link
Contributor Author

rawwar commented Jun 15, 2025

Pretty cool!

Can you add something about this into the Contribution docs as well? ...and would it make sense adding this to breeze CLI as command line instead of ENV?

Yes. I'm adding CLI support as well. And, I'll update docs.

@potiuk
Copy link
Member

potiuk commented Jun 15, 2025

Pretty cool!

Can you add something about this into the Contribution docs as well? ...and would it make sense adding this to breeze CLI as command line instead of ENV?

Very much agree with Jens here .... and that's nice. I usually use intelliJ's debug server, there, it works a bit differently (you need to add debug code to connect to server running in IntelliJ) - but maybe we could do something similar.

@rawwar
Copy link
Contributor Author

rawwar commented Jun 15, 2025

Very much agree with Jens here .... and that's nice. I usually use intelliJ's debug server, there, it works a bit differently (you need to add debug code to connect to server running in IntelliJ) - but maybe we could do something similar.

I just looked into how to do this in IntelliJ and yeah, its different. No option to directly connect to debugpy. But, I'll look into it and add something similar

@rawwar rawwar changed the title conditional use of debugpy to run airflow components via breeze use of debugpy to run airflow components via breeze Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants