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

pip install -r requirements.txt

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:

python af.py --host airflow.example.com:8080 --user admin --password secret list

Usage

Basic Usage

By default, the tool connects to localhost:8080:

# Using environment variables
python af.py list

# Using command line arguments
python af.py --user admin --password secret status my_dag

Available Commands

List DAGs

python af.py list
python af.py list --limit 10  # Show only 10 DAGs
python af.py list --all       # Include inactive DAGs

View DAG Status

python af.py status <dag_id>

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

Pause/Unpause DAG

python af.py pause <dag_id>
python af.py unpause <dag_id>

Trigger DAG

python af.py trigger <dag_id>
python af.py trigger <dag_id> --config '{"key": "value"}'

View Tasks and Their Status

python af.py tasks <dag_id>
python af.py 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

python af.py logs <dag_id> <task_id>
python af.py logs <dag_id> <task_id> --run-id <specific_run_id> --try-number 2

Clear Failed Tasks

# Clear all failed tasks in the latest run
python af.py clear <dag_id>

# Clear a specific task
python af.py clear <dag_id> --task-id <task_id>

# Skip confirmation prompt
python af.py clear <dag_id> -y

Examples

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

# List all DAGs
python af.py list

# Check status of example_dag
python af.py status example_dag

# Trigger example_dag with configuration
python af.py trigger example_dag --config '{"date": "2024-01-01"}'

# View all tasks in the latest run
python af.py tasks example_dag

# View logs for a specific task
python af.py logs example_dag process_data

# Clear all failed tasks
python af.py 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]"

Releasing

# Create a new release (replace 0.2.0 with desired version)
./scripts/release.sh 0.2.0

This will:

  1. Create and push a git tag
  2. Guide you to create a GitHub release
  3. Automatically trigger CI/CD to publish to PyPI

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

Test Suite

  • 81 comprehensive tests covering all functionality
  • 88% code coverage with detailed reporting
  • No external dependencies - all API calls mocked
  • Fast execution - full suite runs in <1 second

Test categories:

  • Unit tests for AirflowClient class methods
  • Integration tests for CLI commands
  • Authentication and error handling tests
  • Utility function tests

See tests/README.md for detailed testing documentation.

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.1.tar.gz (73.1 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.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: afcli-0.1.1.tar.gz
  • Upload date:
  • Size: 73.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for afcli-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5c46c63a48e9c3fd73f5accd82b57e1723a445d59628fc08317c49e3f9f0ac0a
MD5 1adbdf1438053dad7fee00fe42e606d0
BLAKE2b-256 d10cfd6cfaf9d7bfb07ac2a005cdaff97520994aee277471b44e5cc4cea019c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for afcli-0.1.1.tar.gz:

Publisher: release.yml on ouachitalabs/af

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: afcli-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for afcli-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89d48c396640eee46e3c9af9145e037f1c305c3c015bfff8bf5add8e29a8c66c
MD5 0c82648f5ea51fe6b9efec7780f8ec91
BLAKE2b-256 7b835e91dd667483cb05b90d09938e311ec0bd57f80133614818b205a7d9b041

See more details on using hashes here.

Provenance

The following attestation bundles were made for afcli-0.1.1-py3-none-any.whl:

Publisher: release.yml on ouachitalabs/af

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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