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.7.tar.gz (5.1 MB 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.7-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for afcli-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9ba568b143cbede94e527fe62519830c3c7fb6e01f82ba31bc6a3e42e789de91
MD5 c7590cbb0f629a9abfe566309ac702ce
BLAKE2b-256 70959348dcba4815c960ce66da245ae93aae193068078d2a92b910ac7e2fbcbc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for afcli-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4f712df66a142fa81ee4376a6a2cb1f963eeb0212d647689101a2233a22417b6
MD5 166d453497f40419fa0c72b302704479
BLAKE2b-256 8500cc08799c25275b45c060bb08188d2fe1d3ee78e7fa1cb1cc1ac8d7e2c1e7

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