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/03 14:46:36 UTC

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

ielizarov commented on issue #12757:
URL: https://github.com/apache/airflow/issues/12757#issuecomment-738040222


   @kaxil Sure, here it is. I simplified my DAG, this version gives the same error exactly. You'll need to add TEST_VAR to Airflow DB.
   
   `"""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(
       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