You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/05/19 13:11:42 UTC

[GitHub] [airflow] ashb edited a comment on pull request #8652: [AIP-31] Implement XComArg model to functionally pass output from one operator to the next

ashb edited a comment on pull request #8652:
URL: https://github.com/apache/airflow/pull/8652#issuecomment-630806879


   > > So this `.output` wasn't in the AIP proposal.
   > 
   > @ashb #8055 , main idea was to be able to mix functional and non-functional ops in one DAG.
   
   Will the example from the AIP still (eventually) work?
   
   ```python
   with DAG(
       'send_server_ip', default_args=default_args, schedule_interval=None
   ) as dag:
   
     # Using default connection as it's set to httpbin.org by default
     get_ip = SimpleHttpOperator(
         task_id='get_ip', endpoint='get', method='GET', xcom_push=True
     )
   
     @dag.task(add_context=True)
     def email_subject_generator(context: dict, raw_json: str) -> str:
       external_ip = json.loads(raw_json)['origin']
       return f"Server connected from {external_ip}"
   
     @task
     def email_body_generator(raw_json: str) -> str:
       return """
       Seems like today your server executing Airflow is connected from the external IP {origin}<br>
       <br>
       Have a nice day!
       """.format(**json.loads(raw_json))
   
     send_email = EmailOperator(
         task_id='send_email',
         to="example@example.com",
         subject='',
         html_content=''
     )
   
     ip_info = get_ip()
     subject = email_subject_generator(ip_info)
     body = email_body_generator(ip_info)
     send_email(subject=subject, html_content=body)
   ```


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org