You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have spent a few hours trying to set up Airflow and install a simple DAG. The DAG page 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.
(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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I have spent a few hours trying to set up Airflow and install a simple DAG. The DAG page 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.
airflow db migrate, shouldn't it be run after Airflow is started? Is it required to do that every new DAG is added?Anyway, I have summarized the steps how to set up Airflow and install DAG. Here is my note.
Setup
Install Airflow
Initialize Airflow
Disable loading examples
(You don't really need this step. But there are too many examples and they might be distracting.)
Start Airflow
Add DAG
Create a file
my_example_dag.pyin${AIRFLOW_HOME}/dagswith following content.Check whether dag is loaded
(By default, Airflow looks for new DAG every 5 minutes.)
Enable 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
Beta Was this translation helpful? Give feedback.
All reactions