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.

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 uses JWT (JSON Web Token) authentication. It automatically obtains a token using the provided credentials and includes it in all API requests.

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.6.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.6-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: afcli-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 db8afede131ef414cb303a191bf1e7c66e82051fbfd3f897ac67842e8a2bc374
MD5 402dc55fda184df32395e0bef6f61e76
BLAKE2b-256 e5053de49ae6e7ccb5b263cce1b4a7c1a34a75c295e800aba565329f3b4df412

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for afcli-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 82ef8182692fb2ef4e4a1c855c970a3eb47445ce9fea0e25d27d556278742113
MD5 132780c49b9f564a43c94064da2d6993
BLAKE2b-256 b51716cc4b62dbf247f9ec62d6a060d16147c1d249bc35751a536f9f1d550036

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