Skip to content

AgremE/AirframeUI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Airflow DAG Generator

This tool generates Airflow DAG files from a JSON configuration file, with a user-friendly web interface for creating and visualizing DAGs.

Project Structure

.
├── ui/                  # Frontend React application
│   ├── src/              # React source code
│   ├── public/           # Static files
│   └── package.json      # Frontend dependencies
├── dag_generator/        # Backend Python package
│   ├── core/            # Core generation logic
│   ├── utils/           # Utility functions
│   └── tests/           # Unit tests
├── main.py              # Main entry point
├── requirements.txt     # Python dependencies
└── README.md           # This file

Setup

Prerequisites

  1. Python 3.8 or higher
  2. Node.js 14 or higher
  3. npm or yarn

Backend Setup

  1. Create and activate a Python virtual environment (recommended):
# Windows
python -m venv venv
venv\Scripts\activate

# Linux/Mac
python3 -m venv venv
source venv/bin/activate
  1. Install the required Python dependencies:
pip install -r requirements.txt
  1. Verify the installation:
python -m main -jfp sample_dag.json

Frontend Setup

  1. Navigate to the frontend directory:
cd ui
  1. Install Node.js dependencies:
npm install
# or if using yarn
yarn install

Development

Starting the Development Environment

  1. Start the frontend development server (in one terminal):
cd ui
npm start
# or
yarn start
  1. The backend will be used when generating DAGs from the UI.

Creating and Generating DAGs

  1. Use the web interface to:

    • Create tasks by selecting operators and configuring them
    • Define dependencies between tasks by connecting them
    • Set DAG-level configurations (schedule, start date, etc.)
  2. Export the DAG configuration:

    • Click the "Generate DAG JSON" button to download the JSON configuration
    • Save the file (e.g., my_dag.json)
  3. Generate the DAG file:

python -m main -jfp my_dag.json

The generated DAG file will be created in the output/dags directory.

JSON Configuration Format

The JSON configuration should follow this structure:

{
  "dag_id": "your_dag_id",
  "description": "DAG description",
  "schedule_interval": "@daily",
  "start_date": "YYYY-MM-DD",
  "catchup": false,
  "tasks": [
    {
      "task_id": "task_name",
      "operator_type": "OperatorType",
      "config": {
        // Operator specific configuration
      }
    }
  ],
  "dependencies": [
    {
      "source": "task_id_1",
      "target": "task_id_2"
    }
  ]
}

Supported Operators

  • PythonOperator
  • BashOperator
  • PostgresOperator
  • EmailOperator
  • HttpOperator
  • S3Hook
  • FileSensor
  • TimeSensor
  • SqlSensor
  • DockerOperator
  • SlackWebhookOperator

Development

Running Tests

# Backend tests
pytest dag_generator/tests/

# Frontend tests (from ui directory)
cd ui
npm test
# or
yarn test

Code Style

The project follows PEP 8 style guidelines for Python and ESLint for JavaScript. Use linters to ensure code quality:

# Python linting
flake8 dag_generator/

# JavaScript linting (from ui directory)
cd ui
npm run lint
# or
yarn lint

Troubleshooting

  1. If the UI fails to start:

    • Ensure Node.js is installed
    • Check if port 3000 is available
    • Verify all frontend dependencies are installed
    • Try clearing npm cache: npm cache clean --force
  2. If DAG generation fails:

    • Check if all required Python packages are installed
    • Verify the JSON configuration format
    • Ensure the output directory is writable
    • Check Python virtual environment is activated
  3. Common issues:

    • Missing dependencies: Run pip install -r requirements.txt again
    • Port conflicts: Change the frontend port in package.json
    • Permission errors: Check directory permissions in output/
    • Node modules issues: Delete node_modules and run npm install again

About

Give your Airflow DAGs a sturdy frame.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors