- Зачем: - убрать мелкие противоречия между спецификациями, учебным планом и заданиями. - сделать сценарий csv_to_postgres и csv_to_postgres_dq понятнее для студентов. - Что: - уточнено, что csv_to_postgres отвечает за загрузку и предпросмотр данных, а DQ вынесен в отдельный DAG. - добавлены явные указания про каталог data/output и соединение postgres_training. - исправлены ссылки на задачу data_quality_summary в учебных заданиях. - Проверка: - git diff -- airflow-docker/dag-specifications.md airflow-docker/educational-setup-plan.md airflow-docker/educational-tasks.md.
4.1 KiB
4.1 KiB
Educational Airflow Setup Plan for Beginners
Current Issues Identified
1. Docker Compose Structure Problems
- Duplicate
services:sections indocker-compose.yml - Inconsistent container naming
2. Missing Directory Structure
- No
airflow/dags/directory - No
data/directory for sample files - No initialization scripts
Proposed Simple Educational Setup
Core Components
1. Fixed Docker Compose Structure
services:
# PostgreSQL for Airflow metadata
postgres-metadata:
image: postgres:16
environment:
POSTGRES_USER: airflow
POSTGRES_PASSWORD: airflow
POSTGRES_DB: airflow
ports:
- "5434:5432"
volumes:
- pgmeta:/var/lib/postgresql/data
# PostgreSQL for training exercises
postgres-training:
image: postgres:16
environment:
POSTGRES_USER: student
POSTGRES_PASSWORD: student
POSTGRES_DB: training
ports:
- "5432:5432"
volumes:
- pg_data:/var/lib/postgresql/data
# Airflow services
airflow-webserver:
image: apache/airflow:2.9.2
environment:
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
ports:
- "8080:8080"
volumes:
- ./dags:/opt/airflow/dags
- ./data:/opt/airflow/data
airflow-scheduler:
image: apache/airflow:2.9.2
environment:
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
volumes:
- ./dags:/opt/airflow/dags
- ./data:/opt/airflow/data
airflow-init:
image: apache/airflow:2.9.2
environment:
AIRFLOW__CORE__LOAD_EXAMPLES: "False"
AIRFLOW__DATABASE__SQL_ALCHEMY_CONN: postgresql+psycopg2://airflow:airflow@postgres-metadata:5432/airflow
2. Hardcoded Environment Variables
Create .env file with all variables hardcoded:
- Airflow admin: admin/admin
- PostgreSQL metadata: airflow/airflow
- PostgreSQL training: student/student
3. Educational DAG Examples
Level 1: Basic Concepts
hello_world_dag.py- Simple print statementssql_basic_dag.py- Basic SQL operationsfile_operations_dag.py- CSV file processing
Level 2: Intermediate
csv_to_postgres.py- CSV to PostgreSQL pipelinecsv_to_postgres_dq.py- separate data quality checks for loaded ordersdata_processing_dag.py- ETL pipeline with multiple stepsbranching_dag.py- Conditional task execution
4. Sample Data Structure
data/
├── input/
│ ├── customers.csv
│ ├── orders.csv
│ └── products.csv
├── output/
└── logs/
5. Learning Progression
Week 1: Airflow Basics
- DAG structure and syntax
- Basic operators (PythonOperator, BashOperator)
- Task dependencies
Week 2: SQL Integration
- PostgreSQL connections
- SQL execution in tasks
- Data transformation
Week 3: Real-world Scenarios
- Error handling and retries
- Parameter passing
- Scheduling
Implementation Steps
- Fix Docker Compose - Remove duplicate sections, add missing services
- Create .env file - Hardcode all environment variables
- Setup directories - Create dags/, data/input/, data/output/
- Create sample DAGs - From simple to complex
- Add sample data - CSV files for practical exercises
- Create requirements.txt - Essential Python packages
- Update documentation - Clear step-by-step instructions
- Test setup - Ensure everything works end-to-end
Key Educational Principles
- Simplicity First - Start with minimal configuration
- Progressive Complexity - Build skills step by step
- Practical Focus - Real data processing tasks
- Immediate Feedback - Students see results quickly
Sample Exercise Structure
Each DAG will include:
- Clear comments explaining each component
- Step-by-step task definitions
- Expected output descriptions
- Common pitfalls and solutions
Technical Requirements
- Docker and Docker Compose
- Basic Python knowledge
- Basic SQL knowledge
- Web browser for Airflow UI