[
https://issues.apache.org/jira/browse/AIRFLOW-4724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16889561#comment-16889561
]
ASF GitHub Bot commented on AIRFLOW-4724:
-----------------------------------------
BasPH commented on pull request #5611: [AIRFLOW-4724] Make params dict to be
templated for operators
URL: https://github.com/apache/airflow/pull/5611
----------------------------------------------------------------
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:
[email protected]
> Make params dict to be templated for operators
> ----------------------------------------------
>
> Key: AIRFLOW-4724
> URL: https://issues.apache.org/jira/browse/AIRFLOW-4724
> Project: Apache Airflow
> Issue Type: Bug
> Components: core, operators
> Affects Versions: 1.10.3
> Reporter: jack
> Priority: Major
> Fix For: 1.10.4
>
>
> Currently using params dict as:
> {code:java}
> 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)
> {code}
> Gives:
> {code:java}
> python3.6 /home/ubuntu/airflow/scripts/ranker.py 'product_dwh-{{
> execution_date.strftime('%s') }}.csv'{code}
>
> The BaseOperator says:
> {code:java}
> self.params = params or {} # Available in templates!{code}
> [https://github.com/apache/airflow/blob/master/airflow/models/baseoperator.py#L343]
> But as you can see above the code wasn't templated as expected.
>
> I worked-around this by not using params dict as:
> {code:java}
> cmd = """python3.6 /home/ubuntu/airflow/scripts/ranker.py 'product_dwh-{{
> execution_date.strftime('%s') }}.csv' """
> upload_file_ftp_op = BashOperator(
> task_id='upload_file_ftp_task',
> bash_command = cmd,
> dag=dag){code}
> This code works perfectly and while it's simpler and better the first code
> should have still work.
>
> A discussion about this has been on slack:
> [https://apache-airflow.slack.com/archives/CCQ7EGB1P/p1559134166151100]
>
> Since Slack doesn't save history forever [~feluelle] , [~dlamblin], if you
> have something to comment please post it here so there will be a reference to
> whomever pick this one up.
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)