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

Filter XCOM by key when calculating map lengths #24530

Conversation

hinnefe2
Copy link
Contributor

@hinnefe2 hinnefe2 commented Jun 17, 2022

MappedOperator determines how many downstream task instances to create
by counting XCOMs associated with upstream mapped tasks. The current
implementation assumes each upstream mapped task has a single XCOM. When
upstream tasks push additional XCOMs beyond the default one then
MappedOperator will generate too many downstream task instances. This
change updates the XCOM counting query to only consider XCOMs with a key
matching the XCOM_RETURN_KEY constant.

close #24487
close #23792

MappedOperator determines how many downstream task instances to create
by counting XCOMs associated with upstream mapped tasks. The current
implementation assumes each upstream mapped task has a single XCOM. When
upstream tasks push additional XCOMs beyond the default one then
MappedOperator will generate too many downstream task instances. This
change updates the XCOM counting query to only consider XCOMs with a key
matching the XCOM_RETURN_KEY constant.
@boring-cyborg
Copy link

boring-cyborg bot commented Jun 17, 2022

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

Copy link
Member

@ashb ashb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks good - can you add to the tests please?

@ashb ashb added this to the Airflow 2.3.3 milestone Jun 17, 2022
@hinnefe2
Copy link
Contributor Author

Sure, I'll put a test or two in tests/models/test_mappedoperator.py unless somebody points out a better place.

@jedcunningham
Copy link
Member

@hinnefe2, gentle ping. It'd be great to get this into 2.3.3. That test file is the right spot. If you have further questions/get stuck, feel free to ping us in #development on Slack!

@hinnefe2
Copy link
Contributor Author

Thanks for the nudge. I'm having a little trouble getting the test to work as intended but I'll sort that out on Slack.

Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One styling nitpick, the logic looks good to me.

tests/test_utils/mock_operators.py Outdated Show resolved Hide resolved
Copy link
Member

@uranusjr uranusjr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a couple of commits to resolve conflicts and update the test.

@uranusjr
Copy link
Member

I’m going to make the call since this is straightfoward enough.

@uranusjr uranusjr changed the title Filter on XCOM key name when calculating map lengths in MappedOperator Filter XCOM by key when calculating map lengths Jul 27, 2022
@uranusjr uranusjr merged commit a69095f into apache:main Jul 27, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 27, 2022

Awesome work, congrats on your first merged pull request!

@hinnefe2
Copy link
Contributor Author

🎉 Thanks for the help getting this across the finish line!

@ephraimbuddy ephraimbuddy added the type:bug-fix Changelog: Bug Fixes label Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants