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

Uploaded Python 3

File details

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

File metadata

  • Download URL: afcli-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 e3c91aadbcf6dd58fed05f7b553f8333240b22ac8f9c9f694f70f868bae9d109
MD5 a82df44402e6e4e6022421900a464842
BLAKE2b-256 3645664e995aba592755bec5b1de81fcddf91801c375ca8377635ef42393ef95

See more details on using hashes here.

Provenance

The following attestation bundles were made for afcli-0.1.4.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.4-py3-none-any.whl.

File metadata

  • Download URL: afcli-0.1.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 61fc4ed37d9ac572f46723c12bf7c589b321db31e1b8bb2fdc754be0f9c011e7
MD5 e683d1c164bfbaafec39633c3b42282d
BLAKE2b-256 f7b7c64b858486b582bed74ae0d514afa561d05cf653aea924f3b0ece5141edb

See more details on using hashes here.

Provenance

The following attestation bundles were made for afcli-0.1.4-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