contributing-docs/20_debugging_airflow_components.rst
.. Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
.. http://www.apache.org/licenses/LICENSE-2.0
.. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Breeze provides debugging support for Airflow components using the --debug and --debugger flags
in the breeze start-airflow command.
To start Airflow with debugging enabled, use the --debug flag to specify which components you want to debug:
.. code-block:: bash
# Debug the scheduler
breeze start-airflow --debug scheduler
# Debug multiple components
breeze start-airflow --debug scheduler --debug triggerer
# Debug all components
breeze start-airflow --debug scheduler --debug triggerer --debug api-server --debug dag-processor
# Debug with CeleryExecutor
breeze start-airflow -b postgres -P 17 --executor CeleryExecutor --debug scheduler --debug dag-processor --debug api-server --debug triggerer --debug celery-worker
# Debug Webserver for Airflow 2.x
breeze start-airflow --debug webserver
Breeze supports two debugger options:
.. code-block:: bash
# Use debugpy (default)
breeze start-airflow --debug scheduler --debugger debugpy
# Use PyCharm debugger
breeze start-airflow --debug scheduler --debugger pydevd-pycharm
By default, breeze start-airflow uses tmux to manage multiple Airflow components. You can use
mprocs as an alternative process manager with the --use-mprocs flag:
.. code-block:: bash
# Use mprocs instead of tmux
breeze start-airflow --use-mprocs
# Use mprocs with debugging
breeze start-airflow --use-mprocs --debug scheduler --debug triggerer
Benefits of mprocs:
Install Required Extensions
Install the following VSCode extensions:
Create Launch Configuration
Create or update your .vscode/launch.json file. The easiest way is to run the setup script:
.. code-block:: bash
uv run dev/ide_setup/setup_vscode.py
This will create debug configurations for all Airflow components. Here's an example configuration for the scheduler:
.. code-block:: json
{
"name": "Debug Airflow Scheduler",
"type": "debugpy",
"request": "attach",
"justMyCode": false,
"connect": {
"host": "localhost",
"port": 50231
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/opt/airflow"
}
]
}
Port Mapping
Each component uses a different debug port. These ports are automatically assigned by Breeze when you start Airflow with debugging enabled:
These ports are exposed from the Breeze container to your host machine, allowing your IDE to connect to the debugger running inside the container.
Start Airflow with Debug Support
.. code-block:: bash
breeze start-airflow --debug scheduler --debugger debugpy
Set Breakpoints
In VSCode, set breakpoints in your Airflow code by clicking in the gutter next to line numbers.
Attach Debugger
Trigger Debugging
Perform an action that will trigger the code path with your breakpoint:
Debug Session
Once the breakpoint is hit: