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

Uploaded Python 3

File details

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

File metadata

  • Download URL: afcli-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 5269ca93c02b2adddec517fb395039f7f9656a7fe6237f0dbf592efefa921ab9
MD5 7e6c86238f05566d9670fd7dfabae847
BLAKE2b-256 c20da343296b777346f2e7c0bad50fa6749124825d8de166556d64caf3c779b1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: afcli-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b6d2d1cc59c279817d9f511ca6fc3591c0b512a60556500f6c2ab3f012de64b8
MD5 ca9875136c4b5d6236b859d65f9a84c5
BLAKE2b-256 df3028aeb3b77179fb1fa4f7616146fe6b881e8114310ad71ae10e09fc373ee5

See more details on using hashes here.

Provenance

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