Skip to main content

📖 Liberty Airflow

A Scalable and Extensible FastAPI and React Scheduler prebuilt with Airflow

Airflow Setup Guide

📌 Prerequisites

Before installing Airflow, ensure you have the following installed on your system:

  • Python 3.12
  • PostgreSQL (for database storage)
  • Git (if needed for repository usage)

🔧 Step 1: Create a .env File

Airflow requires environment variables to be set. Create a .env file in the project root and configure it as follows:

# Airflow and Python Version
AIRFLOW_VERSION=3.0.1
PYTHON_VERSION=3.12
AIRFLOW_INIT=true

# PostgreSQL Server
POSTGRES_HOST=localhost
POSTGRES_PORT=5432

# PostgreSQL Airflow
POSTGRES_AIRFLOW_DB=airflow
POSTGRES_AIRFLOW_USER=airflow
POSTGRES_AIRFLOW_PASSWORD=your_password_here  # Replace with a secure password

# PostgreSQL Liberty
POSTGRES_LIBERTY_DB=liberty
POSTGRES_LIBERTY_USER=liberty
POSTGRES_LIBERTY_PASSWORD=your_password_here  # Replace with a secure password

# PostgreSQL Liberty Airflow Repository
POSTGRES_LIBNARF_DB=libnarf
POSTGRES_LIBNARF_USER=libnarf
POSTGRES_LIBNARF_PASSWORD=your_password_here  # Replace with a secure password

# PostgreSQL Liberty Airflow Data
POSTGRES_NOMAARF_DB=nomaarf
POSTGRES_NOMAARF_USER=nomaarf
POSTGRES_NOMAARF_PASSWORD=your_password_here  # Replace with a secure password

# Admin PostgreSQL Config
POSTGRES_ADMIN_DB=liberty
POSTGRES_ADMIN_USER=liberty
POSTGRES_ADMIN_PASSWORD=your_admin_password_here  # Replace with a secure password

# Airflow Config
AIRFLOW_HOME="./"
AIRFLOW__CORE__LOAD_EXAMPLES="False"
AIRFLOW__DATABASE__LOAD_DEFAULT_CONNECTIONS="False"
AIRFLOW__WEBSERVER__EXPOSE_CONFIG="True"
AIRFLOW__CORE__EXECUTOR="LocalExecutor"
AIRFLOW__API__PORT=8081 # Replace with your port
AIRFLOW__API__BASE_URL="http://localhost:8081/airflow" # Replace with your URL
PYTHONWARNINGS="ignore::SyntaxWarning"
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN=postgresql+psycopg2://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
AIRFLOW__API_AUTH__JWT_SECRET=your_secret_key_here  # Replace with a secure secret key
AIRFLOW__API__AUTH_BACKENDS=airflow.api.auth.backend.basic_auth
AIRFLOW__CORE__AUTH_MANAGER="airflow.providers.fab.auth_manager.fab_auth_manager.FabAuthManager"
SCARF_ANALYTICS=false

# Default Airflow Admin User
AIRFLOW_ADMIN_USER=admin
AIRFLOW_ADMIN_EMAIL=admin@example.com
AIRFLOW_ADMIN_PASSWORD=your_admin_password_here  # Replace with a secure password
AIRFLOW_ADMIN_FIRSTNAME=Admin
AIRFLOW_ADMIN_LASTNAME=User

# FastAPI Config
FASTAPI_HOST="localhost"
FASTAPI_PORT=8082

⚠ IMPORTANT: Do not commit the .env file to version control. Keep credentials secure.


▶ Step 2: Install Liberty Airflow

pipx is recommended due to dependencies between liberty framework and airflow

pip install pipx
pipx ensurepath
pipx install liberty-airflow

This script will preconfigure the environment for Airflow installation

  installed package liberty-airflow, installed using Python 3.12.4
  These apps are now globally available
    - airflow-install
    - airflow-start
    - airflow-stop
    - liberty-airflow
done! ✨ 🌟 ✨

▶ Step 3: Install and configure Airflow

To install Airflow and set up the database, run:

airflow-install

This script will:

  • Install Airflow and required dependencies
  • Create the PostgreSQL database and user (if not already created)
  • Initialize the Airflow database
  • Create a default Airflow admin user

▶ Step 4: Start Liberty Airflow

To start Airflow services, run:

liberty-airflow

This will:

  • Start the Airflow Scheduler
  • Start the Airflow API Server
  • Start the Airflow Dag Processor
  • Start FastAPI

Once started, you can access at: 👉 Airflow UI: http://localhost:8081/airflow 👉 Frontend: http://localhost:8082 👉 API: http://localhost:8082/api


⏹ Step 5: Stop Airflow

To stop all running Airflow processes, run:

airflow-stop

This will:

  • Stop the Airflow Scheduler
  • Stop the Airflow API Server
  • Stop the Airflow Dag Processor

🛠 Troubleshooting

  • If Airflow does not start, check the logs in the logs/ directory.
  • Ensure PostgreSQL is running and accessible

✅ Next Steps

  • Configure DAGs inside $AIRFLOW_HOME/dags/.
  • Add Git integration using the configured GIT_URL.
  • Secure your instance by updating passwords and secret keys.

✅ Prebuilt Dags

Daily DAGs

  • airflow-purge-daily-1: Purges old Airflow logs and metadata on a daily schedule (@daily).
  • database-backup-daily-1: Backs up databases every day at 01:00 AM (00 1 * * *).

Weekly DAGs

  • database-purge-weekly-1: Performs database cleanup and purging on a weekly schedule (@weekly).

Unscheduled DAGs

  • airflow-sync-1: Synchronizes repositories as needed (manually triggered).


✅ Variables

The DAGs rely on Airflow Variables for configuration. These can be set in the Airflow UI (Admin -> Variables) or via the Airflow CLI.

Variable Name Description Default Value
airflow_retention_days Number of days to retain Airflow logs 1
backup_directory Directory where backups are stored /opt/git/backup
backup_repository Name of the backup repository liberty-backup
backup_retention_days Number of days to retain database backups 0
backup_to_git Whether to push backups to Git (True or False) True

✅ Connections

The DAGs require predefined Airflow Connections to interact with external systems. These can be configured via Airflow UI (Admin -> Connections).

Git Connection (git_conn)

  • Connection Type: generic
  • Description: Used for performing Git operations (pull, push, etc.)
  • Required Fields: login, password, host

PostgreSQL Connection (liberty_conn)

  • Connection Type: postgres
  • Description: Database connection for Liberty Framework
  • Required Fields: login, password, host, port, schema
  • Defaults:
    • login: liberty
    • host: localhost
    • port: 5432

💖 Sponsorship

If you find Liberty Ariflow useful and would like to support its development, consider sponsoring us. Your contributions help maintain the project, add new features, and improve the documentation. Every contribution, big or small, is greatly appreciated!

To sponsor, visit: GitHub Sponsors or reach out to us directly.


📜 License

Liberty Airflow is open-source software licensed under the AGPL License.


📧 Contact & Support

If you have questions or need support:


⭐ If you find Liberty Airflow useful, consider giving it a star on GitHub!

git clone https://github.com/fblettner/liberty-airflow.git
cd liberty-framework

🚀 Let's build the future of business applications together! 🚀

Metadata

Release files for liberty-airflow 1.0.20

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for liberty-airflow 1.0.20
File Size Uploaded
liberty_airflow-1.0.20.tar.gz 15.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for liberty-airflow 1.0.20
File Interpreter ABI Platform
liberty_airflow-1.0.20-py3-none-any.whl Python 3 none any Details

Total release size: 31.6 MB

Release files / liberty_airflow-1.0.20.tar.gz

Download URL liberty_airflow-1.0.20.tar.gz
Size 15.7 MB
Tags Source
SHA-256 checksum
How to use checksums
2c97bb9fd04e553015620286f04a1dd20bb0b1de4f8bc6b10e66330f347c23e5
BLAKE2b-256 checksum
How to use checksums
d3e393d677a9705cb23121e9170522911348618c9b54031cb8fb88bc79338116
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / liberty_airflow-1.0.20-py3-none-any.whl

Download URL liberty_airflow-1.0.20-py3-none-any.whl
Size 15.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
708a63f01f6de97ae31170f356a9f41c966cfa084d57bac33c8471c4dae92be2
BLAKE2b-256 checksum
How to use checksums
f59ff3e8c44d1596aafc0d720f1feba21ac04e1a9c9c3099a63c2e23d84da884
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

1.0.20 This release

2 release files

1.0.19

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page