Python Operator

Clase 13 de 29 • Curso de Fundamentos de Apache Airflow

Clase anteriorSiguiente clase
    Camilo Andrés Rodriguez Higuera

    Camilo Andrés Rodriguez Higuera

    student•
    hace 2 meses

    El resultado

    Jose Daniel Velasquez H

    Jose Daniel Velasquez H

    company_admin•
    hace 7 meses
    rogelio cortez

    rogelio cortez

    student•
    hace 8 meses

    from airflow import DAGfrom datetime import datetimefrom airflow.operators.python import PythonOperator

    #If you need access to Airflow context variables (e.g., ds, run_id), you must include **kwargs.def hello(country): #**kwaargs):    print(f"Hello {country}") with DAG (dag_id="pythonOperator", description="Python Operator DAG", start_date=datetime(2025, 3, 27), schedule="@once") as dag:     t1 = PythonOperator(task_id='taskPython', python_callable=hello,op_args=["Mexico"])     t2 = PythonOperator(task_id='taskPython2', python_callable=hello,op_kwargs={'countrty':"France"}) # op_args = you can pass a list of arguments to the function. if you have more than one argument you must pass the arguments in order in a list# op_kwargs = you can pass a dictionary where the keys are the name of the argumnet ant the values are the values you want to pass. if you have more than one argument you can pass them in any order.

    Cristian Decaroli

    Cristian Decaroli

    student•
    hace 8 meses
    Cristian Decaroli

    Cristian Decaroli

    student•
    hace 10 meses
    Python Operator successfull!!
    Gino G. Viloria

    Gino G. Viloria

    student•
    hace 10 meses
    Daniel Olave

    Daniel Olave

    student•
    hace un año
    Mario Alexander Vargas Celis

    Mario Alexander Vargas Celis

    student•
    hace un año
    Néstor Miguel González Flores

    Néstor Miguel González Flores

    student•
    hace un año

    ¿Cómo ejecuto SQLAlchemy 2 en los DAGs usando PythonOperatos? dado que Airflow usa la versión 1.4. pasa que tengo toda una estructura de código que está en un árbol de directorios por orden para hacer un ETL, y si usara el PythonEnvOperator no me toda los demás archivos.

    Cecilia Gabriela Rodríguez Flores

    Cecilia Gabriela Rodríguez Flores

    student•
    hace 2 años
    Álvaro José Polo Franco

    Álvaro José Polo Franco

    student•
    hace 2 años

    from airflow import DAGfrom airflow.operators.python import PythonOperatorfrom datetime import datetime def print_hello():    print("Hola de pruebas.") with DAG(dag_id="pythonoperator",         description="Nuestro primer DAG utilizando python operator",         schedule_interval="@once",         start_date=datetime(2022, 8, 1)) as dag:        t1 = PythonOperator(        task_id="hello_with_python",        python_callable=print_hello    ) t1

    Álvaro José Polo Franco

    Álvaro José Polo Franco

    student•
    hace 2 años
    Jesús Zelaya Contreras

    Jesús Zelaya Contreras

    student•
    hace 2 años
    Martin Macchia

    Martin Macchia

    student•
    hace 2 años
    Leidy Johana Alarcon Moya

    Leidy Johana Alarcon Moya

    student•
    hace 2 años
    Screenshot from 2023-08-01 12-28-34.png
    Andres Troaños

    Andres Troaños

    student•
    hace 2 años

    Ejecute ambos dags y ninguno de los dos me da la opción del pequeño cuadro verder y ambos aparecen como success, tampoco puedo ver lo logs

    1.png
    2.png

    Alguien sabe que debo hacer o que sucede?

      Eric Bellet

      Eric Bellet

      teacher•
      hace 2 años

      Me muestras el código?

    Luis Rodolfo Altuve Cáceres

    Luis Rodolfo Altuve Cáceres

    student•
    hace 2 años

    Ahora con Python Operator:

    airflow-log-python.png

      Eric Bellet

      Eric Bellet

      teacher•
      hace 2 años

      Buen trabajo Luis

    Elias Dudamel

    Elias Dudamel

    student•
    hace 2 años

    Me gusta la parte de que se se sigan podiendo reutilizar funciones, dejo ejemplo

    from airflow import DAG from airflow.operators.python import PythonOperator from datetime import datetime def print_hello(country, **kwargs): print(f'I am processing this {country}') with DAG(dag_id='pythonoperator' , description='Utilizando python operator' , start_date=datetime(2023, 6, 7) , schedule_interval='@once') as dag: t1 = PythonOperator(task_id='process_ar' , python_callable=print_hello , op_kwargs={'country':'AR'}) t2 = PythonOperator(task_id='process_uy' , python_callable=print_hello , op_kwargs={'country':'UY'}) t1 >> t2
    Elitsoft Chile

    Elitsoft Chile

    student•
    hace 2 años
    IMG_003-msg-pythonoperator.jpg
    Héctor Javier Herrera Espínola

    Héctor Javier Herrera Espínola

    student•
    hace 3 años

    Me sale este error: Probé instalar de mil maneras, en todas igual:

    Capture.PNG
      Eric Bellet

      Eric Bellet

      teacher•
      hace 3 años

      No me sale el error en tu pregunta