Skip to main content

Develop Airflow DAGs locally with VS Code

This example shows how to set up VS Code for local development with Airflow and the Astro CLI. Setting up a local development environment allows you to iterate more quickly when developing DAGs by taking advantage of IDE features like code autocompletion, identifying deprecated or unused imports, and error and warning syntax highlighting.

Before you start

Before trying this example, make sure you have:

Write Airflow code with VS Code

Follow these steps to start writing your DAGs in VS Code.

  1. Open the folder containing your Astro Project in VS Code. In the bottom left corner of your VS Code window, click the green containers icon and select Open Folder in Container...

    Open Folder

  2. The Finder/File Explorer will open prompting you to select the project folder. Ensure that your Astro project is selected and click Open, then From 'Dockerfile'.

    A new VS Code window appears. Note in the lower left corner of the window that your IDE is now pointing to that running Docker container.

  3. Install the Python Extension to your new session of VS Code. Go to the Extensions nav bar option, search for Python, and the first result should be the extension published by Microsoft. Install it by clicking the button Install in Container <your container name>.

    Extension

  4. Ensure the Python interpreter is configured properly by opening the dags/example_dag_basic.py file in your Astro project dags/ folder and start writing some Python.

After you configure the integration, VScode starts showing warnings and autocompletion suggestions for Airflow. In the example below, you can see that the Python interpreter is attempting to auto-complete the import line.

Code

See also

Was this page helpful?

Sign up for Developer Updates

Get a summary of new Astro features once a month.

You can unsubscribe at any time.
By proceeding you agree to our Privacy Policy, our Website Terms and to receive emails from Astronomer.