From commits-return-60641-archive-asf-public=cust-asf.ponee.io@airflow.apache.org Wed Aug 7 16:25:14 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id DE9C9180643 for ; Wed, 7 Aug 2019 18:25:13 +0200 (CEST) Received: (qmail 41240 invoked by uid 500); 7 Aug 2019 16:25:11 -0000 Mailing-List: contact commits-help@airflow.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@airflow.apache.org Delivered-To: mailing list commits@airflow.apache.org Received: (qmail 41180 invoked by uid 99); 7 Aug 2019 16:25:11 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Aug 2019 16:25:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id CA75CC0F86 for ; Wed, 7 Aug 2019 16:25:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -112.999 X-Spam-Level: X-Spam-Status: No, score=-112.999 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id AhTHGyQI3Bh9 for ; Wed, 7 Aug 2019 16:25:08 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.244.88.153; helo=mail.apache.org; envelope-from=jira@apache.org; receiver= Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with SMTP id 545457DD32 for ; Wed, 7 Aug 2019 16:25:06 +0000 (UTC) Received: (qmail 38764 invoked by uid 99); 7 Aug 2019 16:25:05 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Aug 2019 16:25:05 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 2C521E2FDA for ; Wed, 7 Aug 2019 16:25:04 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 810442667B for ; Wed, 7 Aug 2019 16:25:03 +0000 (UTC) Date: Wed, 7 Aug 2019 16:25:03 +0000 (UTC) From: "Kaxil Naik (JIRA)" To: commits@airflow.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AIRFLOW-4724) Make params dict to be templated for operators MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AIRFLOW-4724?page=3Dcom.atlass= ian.jira.plugin.system.issuetabpanels:all-tabpanel ] Kaxil Naik updated AIRFLOW-4724: -------------------------------- Fix Version/s: (was: 1.10.4) 2.0.0 > 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: 2.0.0 > > > Currently using params dict as: > {code:java} > EXEC_TIMESEPOCH =3D=C2=A0 "{{ execution_date.strftime('%s') }}" > gcs_export_uri_template_filename =3D 'product_dwh-' + EXEC_TIMESEPOCH + '= .csv' > upload_file_ftp_op =3D BashOperator( > =C2=A0=C2=A0 task_id=3D'upload_file_ftp_task', > =C2=A0=C2=A0 params=3D{'filename':gcs_export_uri_template_filename}, > =C2=A0=C2=A0 bash_command=3D"python3.6 /home/ubuntu/airflow/scripts/ranke= r.py=C2=A0 '{{ params.filename }}'=C2=A0 " , > =C2=A0 dag=3Ddag) > {code} > Gives: > {code:java} > python3.6 /home/ubuntu/airflow/scripts/ranker.py=C2=A0 'product_dwh-{{ ex= ecution_date.strftime('%s') }}.csv'{code} > =C2=A0 > The BaseOperator says: > {code:java} > self.params =3D params or {} # Available in templates!{code} > [https://github.com/apache/airflow/blob/master/airflow/models/baseoperato= r.py#L343] > But as you can see above the code wasn't templated as expected. > =C2=A0 > I worked-around this by not using params dict as: > {code:java} > cmd =3D """python3.6 /home/ubuntu/airflow/scripts/ranker.py 'product_dwh-= {{ execution_date.strftime('%s') }}.csv' """ > upload_file_ftp_op =3D BashOperator( > =C2=A0=C2=A0=C2=A0 task_id=3D'upload_file_ftp_task', > =C2=A0=C2=A0=C2=A0 bash_command =3D cmd, > =C2=A0=C2=A0 =C2=A0dag=3Ddag){code} > This code works perfectly and while it's simpler and better the first cod= e should have still work. > =C2=A0 > A discussion about this has been on slack: > [https://apache-airflow.slack.com/archives/CCQ7EGB1P/p1559134166151100] > =C2=A0 > Since Slack doesn't save history forever [~feluelle] , [~dlamblin], if yo= u have something to comment please post it here so there will be a referenc= e to whomever pick this one up. -- This message was sent by Atlassian JIRA (v7.6.14#76016)