Kimuksung
Kimuksung μ•ˆλ…•ν•˜μ„Έμš”. λΆ„μ‚°μ²˜λ¦¬μ— 관심이 λ§Žμ€ μƒκ°ν•˜λŠ” μ£Όλ‹ˆμ–΄ Data Enginnerμž…λ‹ˆλ‹€.

Airflow PythonOperator

Airflow PythonOperator
Python Operator

1
2
3
4
5
6
7
8
9
classairflow.operators.python.PythonOperator(
    *, 
    python_callable: Callable, 
    op_args: Optional[List] = None, 
    op_kwargs: Optional[Dict] = None, 
    templates_dict: Optional[Dict] = None, 
    templates_exts: Optional[List[str]] = None, 
    **kwargs
)
  • op_kwargs : dictionary argument
  • op_args : list argument
1
from airflow.operators.python import PythonOperator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
default_args = {
    'owner': 'airflow',
    'start_date': datetime(2023, 10, 23)
}

dag = DAG('python_operator', default_args=default_args, schedule_interval='@daily')

start_task = DummyOperator(task_id='start_task', dag=dag)

end_task = DummyOperator(task_id='end_task', dag=dag)

def test_func():
    print(f'Test function Executed')

task1 = PythonOperator(
    task_id= "task1",
    python_callable= test_function
    op_kwargs= { "key" : "value"},
    dag=dag
)

start_task >> task_1 >> end_task
μ°Έμ‘°

https://avinashnavlani.medium.com/airflow-operators-161f16102403