GitHub user franzwong created a discussion: Simplify QuickStart for Airflow 3 standalone mode
I have spent a few hours trying to set up Airflow and install a simple DAG. The [DAG page](https://airflow.apache.org/docs/apache-airflow/stable/tutorial/fundamentals.html) focuses too much on explaining what a DAG is, rather than on how to create one. As a beginner, I have these questions when I set it up. * I didn't know new DAG is detected every 5 minutes. * The DAG page asks to run `airflow db migrate`, shouldn't it be run after Airflow is started? Is it required to do that every new DAG is added? * Where can I find the user name and password to login. Anyway, I have summarized the steps how to set up Airflow and install DAG. Here is my note. # Setup ## Install Airflow ``` export AIRFLOW_HOME=$(pwd)/airflow mkdir -p ${AIRFLOW_HOME} mkdir -p ${AIRFLOW_HOME}/dags cat << EOF > requirements.txt --constraint https://raw.githubusercontent.com/apache/airflow/constraints-3.2.0/constraints-3.13.txt apache-airflow==3.2.0 graphviz==0.21 EOF echo "3.13" > .python-version python -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ## Initialize Airflow ``` airflow db migrate ``` ## Disable loading examples (You don't really need this step. But there are too many examples and they might be distracting.) ``` sed -i 's/load_examples = True/load_examples = False/g' ${AIRFLOW_HOME}/airflow.cfg ``` ## Start Airflow ``` airflow standalone ``` # Add DAG Create a file `my_example_dag.py` in `${AIRFLOW_HOME}/dags` with following content. ``` from airflow.sdk import DAG from airflow.providers.standard.operators.python import PythonOperator from datetime import datetime def greeting(): print("Hello world!") with DAG( "my_example_dag", start_date=datetime(2000, 1, 1), schedule="*/1 * * * *", catchup=False ) as dag: task = PythonOperator( task_id="greet_task", python_callable=greeting ) ``` # Check whether dag is loaded (By default, Airflow looks for new DAG every 5 minutes.) ``` airflow dags list ``` # Enable DAG ``` airflow dags unpaused my_example_dag ``` # Check DAG status Login to web console (`htttp://localhost:8080`). Default user name and password are stored in `${AIRFLOW_HOME}/simple_auth_manager_passwords.json.generated`. # Clean up ``` rm -rf airflow ``` GitHub link: https://github.com/apache/airflow/discussions/65074 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
