You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/05/20 12:52:51 UTC
[GitHub] [airflow] domagojrazum opened a new pull request, #23829: Add disable retry flag on backfill
domagojrazum opened a new pull request, #23829:
URL: https://github.com/apache/airflow/pull/23829
<!--
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 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/
-->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+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 newsfragement file, named `{pr_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
[GitHub] [airflow] potiuk commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1295111192
@ashb? I just rebased it, and this one is blocked with your comment (responded to)
--
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
[GitHub] [airflow] potiuk commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1223967451
I ihnk this one needs rebase/confict resolving and @ashb re-review afterwards @domagojrazum
--
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
[GitHub] [airflow] domagojrazum commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r880448987
##########
airflow/jobs/backfill_job.py:
##########
@@ -627,6 +629,11 @@ def to_keep(key: TaskInstanceKey) -> bool:
for new_ti in new_mapped_tis:
new_ti.set_state(TaskInstanceState.SCHEDULED, session=session)
+ # Set state to failed for running TIs that are set up for retry if disable-retry flag is set
+ for ti in list(ti_status.running.values()):
Review Comment:
You are right, it's not needed. Removed.
--
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
[GitHub] [airflow] domagojrazum commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1252569096
@potiuk thank you. Looks like checks have passed.
--
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
[GitHub] [airflow] domagojrazum commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r881485763
##########
airflow/models/dag.py:
##########
@@ -2193,6 +2193,7 @@ def run(
run_backwards=False,
run_at_least_once=False,
continue_on_failures=False,
+ disable_retry=False,
Review Comment:
Thank you for the reply.
I was following the same principles for `disable_retry` as the other backfill flags were implemented (e.g. continue_on_failures).
`dag_backfill` is called inside dag_command.py, and it's calling `run` on DAG instance with all of the backfill arguments.
Can you please elaborate the comment if I misunderstood something
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r944182562
##########
airflow/models/dag.py:
##########
@@ -2193,6 +2193,7 @@ def run(
run_backwards=False,
run_at_least_once=False,
continue_on_failures=False,
+ disable_retry=False,
Review Comment:
I think this addition is unavoidable without some major refactoring (which we should do, but that’s a much bigger undertaking…)
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r881255653
##########
airflow/cli/cli_parser.py:
##########
@@ -340,7 +340,7 @@ def string_lower_type(val):
action="store_true",
)
ARG_DISABLE_RETRY = Arg(
- ("-dr", "--disable-retry"),
+ ("--disable-retry"),
Review Comment:
```suggestion
("--disable-retry",),
```
--
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
[GitHub] [airflow] potiuk commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1296559462
Static checks need fixing then/
--
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
[GitHub] [airflow] potiuk commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1252798403
@ashb?
--
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
[GitHub] [airflow] potiuk commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1252282940
Rebased to test it all works fine for the smaller set of tests.
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r991786988
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
You put `assert` at the wrong place 😉
Also it’s better to use `DagRunState.FAILED` here since `State.FAILED` is `TaskInstanceState.FAILED` (they both equal to the string `"failed"` but it’s still beneficial to use the correct state class)
--
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
[GitHub] [airflow] potiuk merged pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
potiuk merged PR #23829:
URL: https://github.com/apache/airflow/pull/23829
--
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
[GitHub] [airflow] boring-cyborg[bot] commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1132867219
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/main/CONTRIBUTING.rst)
Here are some useful points:
- Pay attention to the quality of your code (flake8, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/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/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/main/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.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [airflow] github-actions[bot] commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1133876469
The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.
--
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
[GitHub] [airflow] dstandish commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r991833529
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
LOL wow
--
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
[GitHub] [airflow] dstandish commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r991513061
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
Review Comment:
what's the purpose of mocking try number 2 above if it still ends up having try number 1 here?
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
```suggestion
dag_run.state == assert State.FAILED
```
asserts are `actual == expected`
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
one thing i recommend you do is parametrize this test with args `disable_retry, expected` (values [True, FAILED] and [False, UP_FOR_RETRY] )
this isn't a bad thing to verify, but it also makes it really clear for a reviewer that the test is working properly. e.g. what if the task happened to be in failed for some reason other than the logic you added.
--
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
[GitHub] [airflow] domagojrazum commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1299830607
@potiuk fixed
--
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
[GitHub] [airflow] domagojrazum commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1272956314
@ashb @potiuk
--
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
[GitHub] [airflow] dstandish commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r991510279
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
```suggestion
assert dag_run.state == State.FAILED
```
asserts are `actual == expected`
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r878969620
##########
airflow/cli/cli_parser.py:
##########
@@ -339,6 +339,11 @@ def string_lower_type(val):
help=("if set, the backfill will keep going even if some of the tasks failed"),
action="store_true",
)
+ARG_DISABLE_RETRY = Arg(
+ ("-dr", "--disable-retry"),
Review Comment:
The `-dr` flag feels unnecessary, and I don’t think we have a precedence for multi-character short options.
```suggestion
("--disable-retry",),
```
--
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
[GitHub] [airflow] uranusjr commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
uranusjr commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r878969191
##########
airflow/jobs/backfill_job.py:
##########
@@ -627,6 +629,11 @@ def to_keep(key: TaskInstanceKey) -> bool:
for new_ti in new_mapped_tis:
new_ti.set_state(TaskInstanceState.SCHEDULED, session=session)
+ # Set state to failed for running TIs that are set up for retry if disable-retry flag is set
+ for ti in list(ti_status.running.values()):
Review Comment:
Why the `list()` call?
--
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
[GitHub] [airflow] ashb commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
ashb commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r880629304
##########
airflow/models/dag.py:
##########
@@ -2193,6 +2193,7 @@ def run(
run_backwards=False,
run_at_least_once=False,
continue_on_failures=False,
+ disable_retry=False,
Review Comment:
I don't think we need to add this to the `dag.run` API -- the fact it currently uses Backfil to achieve it is an implementation detail.
--
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
[GitHub] [airflow] domagojrazum commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r1000554435
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
Thank you for the review.
You can check latest commit.
Test is parametrized, but in a different way (['disable_retry', 'try_number', 'exception']). Final state of DagRun is not important in this case, but `try_number` is. That's why I left fixed `assert dag_run.state == DagRunState.FAILED`.
--
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
[GitHub] [airflow] dstandish commented on a diff in pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #23829:
URL: https://github.com/apache/airflow/pull/23829#discussion_r991833876
##########
tests/jobs/test_backfill_job.py:
##########
@@ -1812,3 +1812,41 @@ def test_task_instances_are_not_set_to_scheduled_when_dagrun_reset(self, dag_mak
states = [ti.state for _, ti in tasks_to_run.items()]
assert TaskInstanceState.SCHEDULED in states
assert State.NONE in states
+
+ def test_backfill_disable_retry(self, dag_maker):
+ with dag_maker(
+ dag_id='test_disable_retry',
+ schedule_interval="@daily",
+ default_args={
+ 'retries': 3,
+ 'retry_delay': datetime.timedelta(seconds=3),
+ },
+ ) as dag:
+ task1 = EmptyOperator(task_id="task1")
+ dag_run = dag_maker.create_dagrun(state=None)
+
+ executor = MockExecutor(parallelism=16)
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=1)
+ ] = State.UP_FOR_RETRY
+ executor.mock_task_results[
+ TaskInstanceKey(dag.dag_id, task1.task_id, dag_run.run_id, try_number=2)
+ ] = State.UP_FOR_RETRY
+ job = BackfillJob(
+ dag=dag,
+ executor=executor,
+ start_date=DEFAULT_DATE,
+ end_date=DEFAULT_DATE,
+ disable_retry=True,
+ )
+ with pytest.raises(BackfillUnfinished):
+ job.run()
+ ti = dag_run.get_task_instance(task_id=task1.task_id)
+
+ assert ti._try_number == 1
+
+ dag_run.refresh_from_db()
+
+ assert State.FAILED == dag_run.state
Review Comment:
nothing but top quality reviews here
--
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
[GitHub] [airflow] domagojrazum commented on pull request #23829: Add disable retry flag on backfill
Posted by GitBox <gi...@apache.org>.
domagojrazum commented on PR #23829:
URL: https://github.com/apache/airflow/pull/23829#issuecomment-1236958542
Rebased and conflicts are resolved. @potiuk
--
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