Hi, I've tried to create a simple DAG with Airflow 2 and launch it, with a
program like this -
-----
import os
# with open('../airflow/dags/uniqueId14.py', 'w') as fp:
# fcont = """
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.bash import BashOperator
with DAG(
dag_id='uniqueId15',
default_args={
'depends_on_past': False,
'email': ['[email protected]'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
},
description='A simple tutorial DAG',
schedule_interval=timedelta(days=1),
start_date=datetime(2022, 4, 11),
catchup=False,
tags=['example'],
) as dag:
t1 = BashOperator(
task_id='print_date',
bash_command='date',
)
t2 = BashOperator(
task_id='sleep',
depends_on_past=False,
bash_command='sleep 5',
retries=3,
)
t1 >> t2
globals()["uniqueId15"] = dag
# """
# fp.write(fcont)
os.system('airflow dags trigger uniqueId15')
-----
I've also tried to save the content of DAG file into Airflow dags folder. In
both cases the last command, to launch the DAG, returns something like
airflow.exceptions.DagNotFound: Dag id uniqueId15 not found in DagModel
Can it be done? If yes, how?
Thanks,
Alex