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 2019/07/19 09:28:30 UTC

[GitHub] [airflow] srivignessh opened a new pull request #5611: [AIRFLOW 4724] Make params dict to be templated for operators

srivignessh opened a new pull request #5611: [AIRFLOW 4724] Make params dict to be templated for operators
URL: https://github.com/apache/airflow/pull/5611
 
 
   Make sure you have checked _all_ steps below.
   
   ### Description
   
   I am proposing this change to fix the following bug
   ```
   EXEC_TIMESEPOCH =  "{{ execution_date.strftime('%s') }}"
   gcs_export_uri_template_filename = 'product_dwh-' + EXEC_TIMESEPOCH + '.csv'
   upload_file_ftp_op = BashOperator(
      task_id='upload_file_ftp_task',
      params={'filename':gcs_export_uri_template_filename},
      bash_command="python3.6 /home/ubuntu/airflow/scripts/ranker.py  '{{ params.filename }}'  " ,
     dag=dag)
   ```
   
   Gives:
   ```
   python3.6 /home/ubuntu/airflow/scripts/ranker.py  'product_dwh-{{ execution_date.strftime('%s') }}.csv'
   ```
   
   Expected:
   ```
   python3.6 /home/ubuntu/airflow/scripts/ranker.py  product_dwh-1433142000.csv
   ```
   
   I have noticed that params was available in jinja context but it wasn't templated as it was nested. 
   Hence, running the result once again in the same context obtained the required result.
   
   I request the reviewers for further comments.
   
   If this approach is good to go. I will append the commit with test cases.
   
   Thanks,
   Srivignessh

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


With regards,
Apache Git Services