You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/11/16 23:43:00 UTC

[jira] [Commented] (AIRFLOW-5115) S3KeySensor template_fields for bucket_name & bucket_key do not support Jinja variables

    [ https://issues.apache.org/jira/browse/AIRFLOW-5115?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17233155#comment-17233155 ] 

ASF GitHub Bot commented on AIRFLOW-5115:
-----------------------------------------

boring-cyborg[bot] commented on pull request #12389:
URL: https://github.com/apache/airflow/pull/12389#issuecomment-728423059


   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, pylint and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/master/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/master/docs/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/master/BREEZE.rst) for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


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


> S3KeySensor template_fields for bucket_name & bucket_key do not support Jinja variables
> ---------------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-5115
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-5115
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: aws
>    Affects Versions: 1.9.0
>            Reporter: Dmitriy Synkov
>            Assignee: Dmitriy Synkov
>            Priority: Minor
>              Labels: easyfix, patch
>             Fix For: 2.0.0
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> In all Airflow operators (which inherit form {{BaseOperator}}) there is a {{template_fields}} attribute defined as ["which fields will get jinjafied"|https://github.com/apache/airflow/blob/master/airflow/models/baseoperator.py#L218-L219]). For the {{S3KeySensor}} op in specific, these are {{template_fields = ('bucket_key', 'bucket_name')}}.
> The {{bucket_key}} kwarg, however, has some input validation in that the {{bucket_key}} needs to begin with the S3 protocol {{s3://}}; this exception is thrown by the [constructor|https://github.com/apache/airflow/blob/master/airflow/sensors/s3_key_sensor.py#L71-L74], which makes it impossible to use Jinja strings as an arg to {{bucket_key}}, since these don't get rendered in the scope of the DAG {{*.py}} file itself. Below is an example; I'm using Airflow 1.9.0 with Python 3.5.3:
> Given the below DAG code, where "my_s3_key" is {{s3://bucket/prefix/object.txt:}}
> {code:java}
> dag = DAG('sample_dag', start_date=datetime(2019, 8, 1, 12, 15))
> s3_variable_sensor = S3KeySensor(
>     task_id='s3_variable_sensor',
>     bucket_key=Variable.get('my_s3_key'),
>     dag=dag
> )
> s3_jinja_sensor = S3KeySensor(
>     task_id='s3_jinja_sensor',
>     bucket_key="{{ var.value.my_s3_key }}",
>     dag=dag
> )
> {code}
> Executing the first task will run just fine while the next task will throw the following exception:
> {code:java}
> airflow.exceptions.AirflowException: Please provide a bucket_name.
> {code}
> This ticket is to propose a code change that will move input validation out of the constructor to allow for Jinja-templated strings to be passed into both {{bucket_name}} and {{bucket_key}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)