You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Lee-W (via GitHub)" <gi...@apache.org> on 2024/03/22 04:32:55 UTC

[PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Lee-W opened a new pull request, #38396:
URL: https://github.com/apache/airflow/pull/38396

   We notice some of the amazon triggers are not explicitly exiting a while loop like amazons://github.com/apache/airflow/blob/952d04a3c10a7b511e4c39528d6f7aca7d729df6/airflow/triggers/external_task.py#L112-L113
   
   <!--
    Licensed to the Apache Software Foundation (ASF) under one
    or more contributor license agreements.  See the NOTICE file
    distributed with this work for additional information
    regarding copyright ownership.  The ASF licenses this file
    to you under the Apache License, Version 2.0 (the
    "License"); you may not use this file except in compliance
    with the License.  You may obtain a copy of the License at
   
      http://www.apache.org/licenses/LICENSE-2.0
   
    Unless required by applicable law or agreed to in writing,
    software distributed under the License is distributed on an
    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, either express or implied.  See the License for the
    specific language governing permissions and limitations
    under the License.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   
   
   <!-- Please keep an empty line above the dashes. -->
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #38396:
URL: https://github.com/apache/airflow/pull/38396#issuecomment-2014786372

   I guess the main problem that how this implemented right now in many triggers.
   Instead of
   ```python
   while True:
       "do something"
       if foo == "bar"
           yield ...
           return
       elif spam == "egg"
           yield ...
           return
   ```
   
   It might be better then it implemented as (or as a decorator/context manager)
   
   ```python
   event = None
   try:
       while not event:
           "do something"
   except Exception:
       yield ...  # Error event
   else:
      yield event  # Error event
   ```
   
   But it still required to change the code and make sure that yield not happen inside of while syntax


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Posted by "hussein-awala (via GitHub)" <gi...@apache.org>.
hussein-awala merged PR #38396:
URL: https://github.com/apache/airflow/pull/38396


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on PR #38396:
URL: https://github.com/apache/airflow/pull/38396#issuecomment-2014401982

   https://github.com/apache/airflow/pull/31987 has a more general fix.


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Posted by "hussein-awala (via GitHub)" <gi...@apache.org>.
hussein-awala commented on PR #38396:
URL: https://github.com/apache/airflow/pull/38396#issuecomment-2014815945

   > #31987
   
   We are agreed on accepting coroutines and generators to fix this issue, but we are blocked by MyPy that doesn't support this implementation.


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Posted by "Taragolis (via GitHub)" <gi...@apache.org>.
Taragolis commented on PR #38396:
URL: https://github.com/apache/airflow/pull/38396#issuecomment-2014628202

   > https://github.com/apache/airflow/pull/31987 has a more general fix.
   
   This change not conflicting with that PR. It will work only on specific Airflow, however providers usually support minor versions of Airflow 2 for at least for 1 year. Like now it supports 2.6, 2.7, 2.8.
   
   When/if this PR merged and min supported version to provider will respect the version it might be removed from the provider codebes


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] add "return" statement to "yield" within a while loop in amazon triggers [airflow]

Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on PR #38396:
URL: https://github.com/apache/airflow/pull/38396#issuecomment-2014674051

   @Taragolis Understood, we have also implemented return statement after trigger event in our internal triggers. My point was more to add a context that the similar changes already present in google related providers were removed in https://github.com/apache/airflow/pull/31703 and then added back in https://github.com/apache/airflow/pull/31985 with discussion pointing out various subtle things in asyncio. It lead to the more general fix to be opened in https://github.com/apache/airflow/pull/31987.
   
   > If your trigger is designed to emit more than one event (not currently supported), then each emitted event must contain a payload that can be used to deduplicate events if the trigger is running in multiple places. If you only fire one event and don’t need to pass information back to the operator, you can just set the payload to None.
   
   Though currently not supported emitting multiple events is noted in this doc section.


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

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org