Skip to main content

A command-line utility for interacting with Apache Airflow REST API

Project description

Airflow CLI Wrapper

Test PyPI version Python versions Coverage

A command-line utility for interacting with the Airflow REST API. Compatible with both Airflow 2.9.x (basic auth) and 3.x (JWT auth).

Installation

uv tool install afcli

Or with pip:

pip install afcli

Configuration

Environment Variables

You can set authentication credentials using environment variables:

export AIRFLOW_HOST="airflow.example.com:8080"  # Default: localhost:8080
export AIRFLOW_USER="admin"
export AIRFLOW_PASSWORD="your-password"

Command Line Arguments

Command line arguments override environment variables:

afcli --host airflow.example.com:8080 --user admin --password secret list

Usage

Basic Usage

By default, the tool connects to localhost:8080:

# Using environment variables
afcli list

# Using command line arguments
afcli --user admin --password secret status my_dag

Available Commands

List DAGs

afcli list
afcli list --limit 10  # Show only 10 DAGs
afcli list --all       # Include inactive DAGs

View DAG Status

afcli status <dag_id>

Shows DAG configuration and recent runs with color-coded states.

Pause/Unpause DAG

afcli pause <dag_id>
afcli unpause <dag_id>

Trigger DAG

afcli trigger <dag_id>
afcli trigger <dag_id> --config '{"key": "value"}'

View Tasks and Their Status

afcli tasks <dag_id>
afcli tasks <dag_id> --run-id <specific_run_id>

Shows all tasks with color-coded states:

  • 🟢 Green: Success
  • 🔴 Red: Failed
  • 🟡 Yellow: Running/Retry
  • 🔵 Blue: Scheduled
  • 🟣 Purple: Skipped

View Task Logs

afcli logs <dag_id> <task_id>
afcli logs <dag_id> <task_id> --run-id <specific_run_id> --try-number 2

Clear Failed Tasks

# Clear all failed tasks in the latest run
afcli clear <dag_id>

# Clear a specific task
afcli clear <dag_id> --task-id <task_id>

# Skip confirmation prompt
afcli clear <dag_id> -y

Examples

# Set credentials via environment
export AIRFLOW_USER=admin
export AIRFLOW_PASSWORD=secret

# List all DAGs
afcli list

# Check status of example_dag
afcli status example_dag

# Trigger example_dag with configuration
afcli trigger example_dag --config '{"date": "2024-01-01"}'

# View all tasks in the latest run
afcli tasks example_dag

# View logs for a specific task
afcli logs example_dag process_data

# Clear all failed tasks
afcli clear example_dag

Authentication

The tool automatically detects and uses the appropriate authentication method:

  • Airflow 3.x: Uses JWT (JSON Web Token) authentication. The tool obtains a token from /auth/token and includes it in API requests.
  • Airflow 2.9.x: Falls back to basic authentication when JWT endpoint is not available.

Authentication happens transparently - simply provide your credentials and the tool will use the appropriate method.

Development

Installation for Development

# Install with test dependencies
uv pip install -e ".[test]"

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=afcli --cov-report=html

# Run specific test categories
pytest -m unit         # Unit tests only
pytest -m integration  # Integration tests only

# Use Makefile commands
make test              # All tests
make test-cov          # With coverage report
make test-unit         # Unit tests only

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

afcli-0.1.12.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

afcli-0.1.12-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file afcli-0.1.12.tar.gz.

File metadata

  • Download URL: afcli-0.1.12.tar.gz
  • Upload date:
  • Size: 51.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for afcli-0.1.12.tar.gz
Algorithm Hash digest
SHA256 6409f79c1add0ee4e797a4047a5a51c090567b44788104e9fef5aa3c101ae07c
MD5 31045eefa22d4ab177b868a007cc3bf4
BLAKE2b-256 30e25464334ea3cc701b59c151da9f8b8ec25c6df0aab08993957a13e3654c5a

See more details on using hashes here.

File details

Details for the file afcli-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: afcli-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 12.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.13

File hashes

Hashes for afcli-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 98166bea2738dca691a29c10feb44cc997c25ac729aea51a6908f0362ce23fef
MD5 85f24e8cbd6ebdd95211b7330b3e107e
BLAKE2b-256 d71bc706af37417b45bc1b8b18c68e6e6ab1e3896b386a71d21dd454ce1497db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page