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/12/04 23:18:50 UTC

[GitHub] [airflow] kaxil edited a comment on issue #12757: Graph View is empty when Operator has multiline string in args (v2.0)

kaxil edited a comment on issue #12757:
URL: https://github.com/apache/airflow/issues/12757#issuecomment-739071256


   I am not able to reproduce this with the DAG you had provided:
   
   ![image](https://user-images.githubusercontent.com/8811558/101224401-6270a880-3686-11eb-9e5c-23e5465f2a65.png)
   ![image](https://user-images.githubusercontent.com/8811558/101224599-fd698280-3686-11eb-8edc-d6428effe229.png)
   
   Your DAG:
   
   ```python
   """Demo DAG"""
   from datetime import timedelta
   from airflow import DAG
   from airflow.contrib.operators.kubernetes_pod_operator import KubernetesPodOperator
   from airflow.utils.dates import days_ago
   args = {
       'owner': 'airflow',
   }
   dag = DAG(
       dag_id='demo_test',
       default_args=args,
       schedule_interval='0 0 * * *',
       start_date=days_ago(2),
       dagrun_timeout=timedelta(minutes=60),
       tags=['demo'],
       params={
           "pod_op_image": "localhost:5000/my-image:latest",
           "pod_op_image_pull_policy": "IfNotPresent",
       },
   )
   env_params = {
       "TEST_ENV_VAR": "TEST ENV VAR",
   }
   normal_op = KubernetesPodOperator(
       dag=dag,
       name='normal_op',
       task_id='normal_op',
       namespace='airflow',
       image="{{ dag_run.conf['pod_op_image'] }}",
       image_pull_policy="{{ dag_run.conf['pod_op_image_pull_policy'] }}",
       env_vars=env_params,
       cmds=["/bin/bash", "-c"],
       arguments=["echo $TEST_ENV_VAR"],
   )
   #below is templated multi-string var which is used as argument further
   templated_command = """
           echo "{{ var.value.TEST_VAR}}"
           echo "{{ params.my_param }}"
       """
   templated_op = KubernetesPodOperator(
       dag=dag,
       name='templated_op',
       task_id='templated_op',
       namespace='airflow',
       image="{{ dag_run.conf['pod_op_image'] }}",
       image_pull_policy="{{ dag_run.conf['pod_op_image_pull_policy'] }}",
       cmds=["bash", "-c"],
       arguments=[templated_command],
       params={'my_param': 'Passed_Parameter'},
   )
   normal_op >> templated_op
   if __name__ == "__main__":
       dag.cli()
   ```


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