Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - kaxil/airflowctl: A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects · GitHub
Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Repository files navigation

Warning

⚠️ ARCHIVED: The airflowctl PyPI package name has been moved to the Apache Airflow repo and is now maintained by the Airflow PMC. This repository is archived and no longer maintained. One of the goals was to make this project similar to what kubectl is for Kubernetes. This will now be possible with airflowctl and Airflow 3, thanks to AIP-81. and thanks to the advancements in uv, you can now easily run Airflow with a single command. Further development will continue to happen in airflow cli or astro CLI:

uvx --from "apache-airflow" airflow standalone

airflowctl

PyPILicensePythonPyPI - DownloadsCode style: blackpre-commit.ci status

airflowctl is a command-line tool for managing Apache Airflow™ projects. It provides a set of commands to initialize, build, start, stop, and manage Airflow projects. With airflowctl, you can easily set up and manage your Airflow projects, install specific versions of Apache Airflow, and manage virtual environments.

The main goal of airflowctl is for first-time Airflow users to install and setup Airflow using a single command and for existing Airflow users to manage multiple Airflow projects with different Airflow versions on the same machine.

Features

  • Project Initialization with Connections & Variables: Initialize a new Airflow project with customizable project name, Apache Airflow version, and Python version. It also allows you to manage Airflow connections and variables.
  • Automatic Virtual Environment Management: Automatically create and manage virtual environments for your Airflow projects, even for Python versions that are not installed on your system.
  • Airflow Version Management: Install and manage specific versions of Apache Airflow.
  • Background Process Management: Start and stop Airflow in the background with process management capabilities.
  • Live Logs Display: Continuously display live logs of background Airflow processes with optional log filtering.

Table of Contents

Installation

pip install airflowctl

Quickstart

To initialize a new Airflow project with the latest airflow version, build a Virtual environment and run the project, run the following command:

airflowctl init my_airflow_project --build-start

This will start Airflow and display the logs in the terminal. You can access the Airflow UI at http://localhost:8080. To stop Airflow, press Ctrl+C.

Usage

Step 1: Initialize a New Project

To create a new Apache Airflow project, use the init command. This command sets up the basic project structure, including configuration files, directories, and sample DAGs.

airflowctl init <project_name> --airflow-version <version> --python-version <version>

Example:

airflowctl init my_airflow_project --airflow-version 2.6.3 --python-version 3.8

This creates a new project directory with the following structure:

my_airflow_project
├── .env
├── .gitignore
├── dags
│ └── example_dag_basic.py
├── plugins
├── requirements.txt
└── settings.yaml

Description of the files and directories:

  • .env file contains the environment variables for the project.
  • .gitignore file contains the default gitignore settings.
  • dags directory contains the sample DAGs.
  • plugins directory contains the sample plugins.
  • requirements.txt file contains the project dependencies.
  • settings.yaml file contains the project settings, including the project name, Airflow version, Python version, and virtual environment path.

In our example settings.yaml file would look like this:

# Airflow version to be installedairflow_version: "2.6.3"# Python version for the projectpython_version: "3.8"# Path to a virtual environment to be used for the projectmode:
name: "uv"config:
venv_path: "PROJECT_DIR/.venv"# Airflow connectionsconnections:
# Example connection# - conn_id: example# conn_type: http# host: http://example.com# port: 80# login: user# password: pass# schema: http# extra:# example_extra_field: example-value# Airflow variablesvariables:
# Example variable# - key: example# value: example-value# description: example-description

Edit the settings.yaml file to customize the project settings.

Step 2: Build the Project

The build command creates the virtual environment, installs the specified Apache Airflow version, and sets up the project dependencies.

Run the build command from the project directory:

cd my_airflow_project
airflowctl build

The CLI relies on one of uv or pyenv to download and install a Python version if the version is not already installed.

Example, if you have Python 3.8 installed but you specify Python 3.7 in the settings.yaml file, the CLI will install Python 3.7 using uv or pyenv and create a virtual environment with Python 3.7 first.

Optionally, you can choose custom virtual environment path in case you have already installed apache-airflow package and other dependencies. Pass the existing virtualenv path using --venv_path option to the init command or in settings.yaml file. Make sure the existing virtualenv has same airflow and python version as your settings.yaml file states.

Step 3: Start Airflow

To start Airflow services, use the start command. This command activates the virtual environment and launches the Airflow web server and scheduler.

Example:

airflowctl start my_airflow_project

You can also start Airflow in the background with the --background flag:

airflowctl start my_airflow_project --background

Step 4: Monitor Logs

To monitor logs from the background Airflow processes, use the logs command. This command displays live logs and provides options to filter logs for specific components.

Example

airflowctl logs my_airflow_project

To filter logs for specific components:

# Filter logs for scheduler
airflowctl logs my_airflow_project -s
# Filter logs for webserver
airflowctl logs my_airflow_project -w
# Filter logs for triggerer
airflowctl logs my_airflow_project -t
# Filter logs for scheduler and webserver
airflowctl logs my_airflow_project -s -w

Step 5: Stop Airflow

To stop Airflow services if they are still running, use the stop command.

Example:

airflowctl stop my_airflow_project

Step 6: List Airflow Projects

To list all Airflow projects, use the list command.

Example:

airflowctl list

Step 7: Show Project Info

To show project info, use the info command.

Example:

# From the project directory
airflowctl info
# From outside the project directory
airflowctl info my_airflow_project

Step 8: Running Airflow commands

To run Airflow commands, use the airflowctl airflow command. All the commands after airflowctl airflow are passed to the Airflow CLI.:

# From the project directory
airflowctl airflow <airflow_command>

Example:

$ airflowctl airflow version
2.6.3

You can also run airflowctl airflow --help to see the list of available commands.

$ airflowctl airflow --help
Usage: airflowctl airflow [OPTIONS] COMMAND [ARGS]...
Run Airflow commands.
Positional Arguments:
GROUP_OR_COMMAND
Groups:
celery Celery components
config View configuration
connections Manage connections
dags Manage DAGs
db Database operations
jobs Manage jobs
kubernetes Tools to help run the KubernetesExecutor
pools Manage pools
providers Display providers
roles Manage roles
tasks Manage tasks
users Manage users
variables Manage variables
Commands:
cheat-sheet Display cheat sheet
dag-processor Start a standalone Dag Processor instance
info Show information about current Airflow and environment
kerberos Start a kerberos ticket renewer
plugins Dump information about loaded plugins
rotate-fernet-key
Rotate encrypted connection credentials and variables
scheduler Start a scheduler instance
standalone Run an all-in-one copy of Airflow
sync-perm Update permissions for existing roles and optionally DAGs
triggerer Start a triggerer instance
version Show the version
webserver Start a Airflow webserver instance
Options:
-h, --help show this help message and exit

Example:

# Listing dags
$ airflowctl airflow dags list
dag_id | filepath | owner | paused
==================+======================+=========+=======
example_dag_basic | example_dag_basic.py | airflow | True
# Running standalone
$ airflowctl airflow standalone

Or you can activate the virtual environment first and then run the commands as shown below.

Example:

# From the project directorysource .venv/bin/activate
# Source all the environment variablessource .env
airflow version

To add a new DAG, add the DAG file to the dags directory.

To edit an existing DAG, edit the DAG file in the dags directory. The changes will be reflected in the Airflow web server.

Step 9: Changing Airflow Configurations

airflowctl by default uses SQLite as the backend database and SequentialExecutor as the executor. However, if you want to use other databases or executors, you can stop the project and either a) edit the airflow.cfg file or b) add environment variables to the .env file.

Example:

# Stop the project
airflowctl stop my_airflow_project
# Changing the executor to LocalExecutor# Change the database to PostgreSQL if you already have it installedecho"AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://airflow:airflow@localhost:5432/airflow">> .env
echo"AIRFLOW__CORE__EXECUTOR=LocalExecutor">> .env
# Start the project
airflowctl start my_airflow_project

Check the Airflow documentation for all the available Airflow configurations.

Using Local Executor with SQLite

For Airflow >= 2.6, you can run LocalExecutor with sqlite as the backend database by adding the following environment variable to the .env file:

_AIRFLOW__SKIP_DATABASE_EXECUTOR_COMPATIBILITY_CHECK=1
AIRFLOW__CORE__EXECUTOR=LocalExecutor

Warning

Sqlite is not recommended for production use. Use it only for development and testing only.

Other Commands

For more information and options, you can use the --help flag with each command.

Using with other Airflow tools

airflowctl can be used with other Airflow projects as long as the project structure is the same.

Astro CLI

airflowctl can be used with Astro CLI projects too.

While airflowctl is a tool that allows you to run Airflow locally using virtual environments, Astro CLI allows you to run Airflow locally using docker.

airflowctl can read the airflow_settings.yaml file generated by Astro CLI for reading connections & variables. It will then reuse it as settings file for airflowctl.

For example, if you have an Astro CLI project:

  • Run the airflowctl init . --build-start command to initialize airflowctl from the project directory. Press y to continue when prompted.
  • It will then ask you for the Airflow version, enter the version you are using, by default uses the latest Airflow version, press enter to continue
  • It will use the installed Python version as the project's python version. If you want to use a different Python version, you can specify it in the airflow_settings.yaml file in the python_version field.
# From the project directory
$ cd astro_project
$ airflowctl init . --build-start
Directory /Users/xyz/astro_project is not empty. Continue? [y/N]: y
Project /Users/xyz/astro_project added to tracking.
Airflow project initialized in /Users/xyz/astro_project
Detected Astro project. Using Astro settings file (/Users/kaxilnaik/Desktop/proj1/astro_project/airflow_settings.yaml).
'airflow_version' not found in airflow_settings.yaml file. What is the Airflow version? [2.6.3]:
Virtual environment created at /Users/xyz/astro_project/.venv
...
...

If you see an error like the following, remove airflow.cfg file from the project directory and remove AIRFLOW_HOME from .env file if it exists and try again.

Error: there might be a problem with your project starting up.
The webserver health check timed out after 1m0s but your project will continue trying to start.
Run 'astro dev logs --webserver | --scheduler'for details.

License

This project is licensed under the terms of the Apache 2.0 License

About

A CLI tool to streamline getting started with Apache Airflow™ and managing multiple Airflow projects

Topics

Resources

Stars

225 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages