You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "0x26res (via GitHub)" <gi...@apache.org> on 2024/05/14 08:24:49 UTC
[PR] Fix default value for aws batch operator retry strategy [airflow]
0x26res opened a new pull request, #39608:
URL: https://github.com/apache/airflow/pull/39608
See https://github.com/apache/airflow/issues/39607
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1602120047
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
Yep! Agreed! I like the way it is now
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #39608:
URL: https://github.com/apache/airflow/pull/39608#issuecomment-2113454618
Awesome work, congrats on your first merged pull request! You are invited to check our [Issue Tracker](https://github.com/apache/airflow/issues) for additional contributions.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1600773364
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
I think just as many people may have been benefiting and enjoying the last defaulting implementation (adding the attempts), I don't see that as so clearly wrong here. The whole point of Airflow operators is to make it easy and convenient for users to build workflows without needing to know the minutiae of the underlying SDK, otherwise everyone would just use taskflow/python operator with the boto sdk directly. We default values on behalf of the user very frequently.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "0x26res (via GitHub)" <gi...@apache.org>.
0x26res commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1601137265
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
@o-nikolas I don't disagree with you, but specifying the default number of attempts explicitly is not necessary.
Prior to https://github.com/apache/airflow/pull/35789 and https://github.com/apache/airflow/pull/35808 the aws `BatchOperator` didn't specify any retryStrategy when submitting the job with boto. That meant it would **use the retry strategy set in the job definition**. The retry strategy specified in the job definition is either specified by the user, or if the user doesn't specify one, it will have one attempt. See "By default, each job is given one attempt to move to either the SUCCEEDED or FAILED job state" [here](https://docs.aws.amazon.com/batch/latest/userguide/job_retries.html)
The new behaviour after these 2 MRs is, if the user doesn't specify the retry policy, to **ignore the job definition retry strategy**. This constitute a breaking change / change in the API behaviour.
Now given when the job definition doesn't have a custom strategy, and the retry strategy is not specified in boto3, it will fallback to the default of 1 attempt, there is no need to specify a explicitly a `{"attempts":1}` in the retry strategy. So it's best to leave it to None. And then we will preserve the previous behaviour.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1600544579
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
If Batch will accept None then I guess it makes sense. But if that is the case, then I'm wondering why it was defaulting to {}.
Shouldn't we consider this a breaking change? If it used to default to 1 retry and now it does not, that seems like a breaking change to me.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "vincbeck (via GitHub)" <gi...@apache.org>.
vincbeck commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1600558492
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
It is breaking change but we should treat it as bug fix since the current behavior does not make sense
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "uranusjr (via GitHub)" <gi...@apache.org>.
uranusjr commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1599598861
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
```suggestion
if self.retry_strategy and not self.retry_strategy.get("attempts"):
```
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "o-nikolas (via GitHub)" <gi...@apache.org>.
o-nikolas commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1602112239
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
> The retry strategy specified in the job definition is either specified by the user, or if the user doesn't specify one, it will have one attempt. See "By default, each job is given one attempt to move to either the SUCCEEDED or FAILED job state" [here](https://docs.aws.amazon.com/batch/latest/userguide/job_retries.html)
This is a completely different story then, if the new default with no input provided still matches the previous default we had then we have no issue and I see no back-compat issues and the discussion is moot. @vincbeck @ferruzzi agreed?
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1602251302
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
Seeing as how Vincent has already approved, and Niko is happy with this conversation, I'll be the second approval and merge it. Thanks.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #39608:
URL: https://github.com/apache/airflow/pull/39608#issuecomment-2109578087
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 Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/contributing-docs/08_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/main/docs/apache-airflow/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/main/dev/breeze/doc/README.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/main/contributing-docs/05_pull_requests.rst#coding-style-and-best-practices).
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Fix default value for aws batch operator retry strategy [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1602250074
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
Ah, that does change things. Yeah, in that case I agree, this is a bugfix. Thanks for the clarification, I missed the context of the other two PRs breaking it.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "0x26res (via GitHub)" <gi...@apache.org>.
0x26res commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1600028210
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
Thanks for the suggestion.
I think in the case where `self.retry_strategy = {}`, the intention of the existing code is to update it to `{"attempts": 1}`. But `bool({})` evaluate to False. So unless I'm mistaken, I don't think your suggestion would work/preserve the existing behavior.
Having that said, that bit of code was introduced because retry_strategy was defaulting to `{}`, causing issue in aws batch. Given now it default to None, we don't have that issue any more (AWS batch can handle None, but can't handle `{}` for retry strategy). So I could just get rid of this. If the user wants to specify a retry_strategy, it's their responsibility to set the `attempts` correctly. We shouldn't be mutating the user input in place anyway.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "0x26res (via GitHub)" <gi...@apache.org>.
0x26res commented on code in PR #39608:
URL: https://github.com/apache/airflow/pull/39608#discussion_r1600341847
##########
airflow/providers/amazon/aws/operators/batch.py:
##########
@@ -206,8 +206,8 @@ def __init__(
self.scheduling_priority_override = scheduling_priority_override
self.array_properties = array_properties
self.parameters = parameters or {}
- self.retry_strategy = retry_strategy or {}
- if not self.retry_strategy.get("attempts", None):
+ self.retry_strategy = retry_strategy
+ if self.retry_strategy is not None and not self.retry_strategy.get("attempts", None):
Review Comment:
I've removed this for now, I think it makes more sense to not touch the retry_strategy and pass null if not provided.
Though I'd be curious to hear what @evgenyslab and @ferruzzi think about this.
--
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] Fix default value for aws batch operator retry strategy [airflow]
Posted by "ferruzzi (via GitHub)" <gi...@apache.org>.
ferruzzi merged PR #39608:
URL: https://github.com/apache/airflow/pull/39608
--
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