Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix max_active_tis_per_dagrun for Dynamic Task Mapping #31406

Merged
merged 4 commits into from
Jun 7, 2023

Conversation

mdembiczak
Copy link
Contributor

@mdembiczak mdembiczak commented May 19, 2023

In reference to #29084 and #29094

This PR fixes a new operator parameter max_active_tis_per_dagrun to control the number of task instances of the task that can be running in parallel in the same DagRun. In the previous implementation filtering by run_id didn't affect on variable. The max_active_tis_per_dagrun setting was not working properly

@boring-cyborg
Copy link

boring-cyborg bot commented May 19, 2023

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 (ruff, mypy and type annotations). Our pre-commits 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 Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment 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 for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    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

@eladkal eladkal added this to the Airflow 2.6.2 milestone May 23, 2023
@ferruzzi
Copy link
Contributor

Would you be able to add a unit test to make sure this doesn't break again, or is that a major operation for a query like this?

@mdembiczak
Copy link
Contributor Author

Would you be able to add a unit test to make sure this doesn't break again, or is that a major operation for a query like this?

I have a problem with running tests locally and I'm not experienced with python. So I found a bug and fixed it, but writing tests may be a problem.

@uranusjr
Copy link
Member

It’s easier to run tests with Docker and our internal tool Breeze. See documentation for details: https://github.com/apache/airflow/blob/main/BREEZE.rst

@potiuk
Copy link
Member

potiuk commented May 30, 2023

Would you be able to add a unit test to make sure this doesn't break again, or is that a major operation for a query like this?

I have a problem with running tests locally and I'm not experienced with python. So I found a bug and fixed it, but writing tests may be a problem.

Yes. Running tests should be really straightforward. And it should be part of the PR @mdembiczak

Breeze give you a setup that does not require any special setup/env (except docker and docker compose installed) so you should be able to just install it. Run breeze and then run pytest tests/..../test_nam.py and it should work. Also most tests that even do not require breeze (majority of our unit tests in core and this is one that you are going to modify) is likely to be able to run in just standard Local Virtualenv: https://github.com/apache/airflow/blob/main/LOCAL_VIRTUALENV.rst and you should be able to run it easily within any IDE of your choice. We have instructions (including setup screenshots) for Pycharm https://github.com/apache/airflow/blob/main/CONTRIBUTORS_QUICK_START_PYCHARM.rst VSCOde https://github.com/apache/airflow/blob/main/CONTRIBUTORS_QUICK_START_VSCODE.rst and even gitpod or codespaces.

It might seem not needed if you look at it from your side @mdembiczak but this is crucial part of the fix to also provide a unit test for it.

Whe we absolutely need tests ? Because when we cherry-pick the changes to released airflow we run the tests to see if the cherry-picked fix is actually still working there. It might be that it is breaking something else in that branch so only having a unit test together with the change is a way to see if it still works after we cherry-pick it. Also we might in the future introduce other changes that might cause regressions and having unit tests is the way to prevent the regressions. We are as much into fixing the issues as we are about preventing them from re-occuring in the future.

If you need any help with that and if you describe what problems you had when trying to run the tests and add a new one, we will be happy to help, but we need the test for the above reasons.

@mdembiczak
Copy link
Contributor Author

Thanks for your help @potiuk and @uranusjr. I was able to use breeze to run the tests. I added one test and hope it's ok.

tests/models/test_taskinstance.py Outdated Show resolved Hide resolved
tests/models/test_taskinstance.py Outdated Show resolved Hide resolved
@uranusjr
Copy link
Member

Also please fix the code style according to static checks.

@mdembiczak mdembiczak requested a review from uranusjr May 30, 2023 14:40
@ephraimbuddy ephraimbuddy merged commit 342b4fe into apache:main Jun 7, 2023
42 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 7, 2023

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@eladkal eladkal added the type:bug-fix Changelog: Bug Fixes label Jun 8, 2023
eladkal pushed a commit that referenced this pull request Jun 8, 2023
* assign filter output to variable

* add tests for max_active_tis_per_dagrun

* fix tests and code style

(cherry picked from commit 342b4fe)
eladkal pushed a commit that referenced this pull request Jun 9, 2023
* assign filter output to variable

* add tests for max_active_tis_per_dagrun

* fix tests and code style

(cherry picked from commit 342b4fe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug-fix Changelog: Bug Fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants