timecommunication commented on issue #29227:
URL: https://github.com/apache/airflow/issues/29227#issuecomment-1409828359

   ```python
   # -*- coding: utf-8 -*-
   
   # The DAG object; we'll need this to instantiate a DAG
   from airflow import DAG
   
   # Operators; we need this to operate!
   from airflow.operators.python import PythonOperator
   
   from datetime import datetime, timedelta
   from textwrap import dedent
   
   import time
   
   with DAG(
       'demo-dag-python',
       # These args will get passed on to each operator
       # You can override them on a per-task basis during operator 
initialization
       default_args={
           'depends_on_past': False,
   
           # alert email receiver list
           'email': [
               '[email protected]',
           ],
   
           'email_on_failure': True,
           'email_on_retry': False,
           'retry_delay': timedelta(seconds=5),
           'owner': 'demo'
       },
       description='only a demo with print func',
       schedule_interval=timedelta(hours=8),
       start_date=datetime(2022, 8, 1),
       catchup=False,
       tags=['demo', 'python', 'only-print-func', 'with-doc'],
   ) as dag:
   
       def write_some_code():
   
           print('do something in this func')
           print('start')
           print('end')
   
   
       def last_print():
           
           time.sleep(30)
   
           print('------ the finish line --------')
   
       task1 = PythonOperator(
           task_id='demo-task-node-1',
           python_callable=write_some_code,
           retries=3,
       )
   
       task2 = PythonOperator(
           task_id='demo-task-node-2',
           python_callable=last_print,
           retries=3,
       )
       
       task3 = PythonOperator(
           task_id='demo-task-node-3',
           python_callable=last_print,
           retries=3,
       )
   
       task1.doc_md = dedent("""
   # task1
   
   ........
   """
       )
   
       dag.doc_md = __doc__  # providing that you have a docstring at the 
beginning of the DAG
       dag.doc_md = """
   # dag doc
       
   ...
   """
   
       task3.set_upstream([task1, task2])
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to