More explicit mapped argument validation#21933
Merged
ashb merged 2 commits intoapache:mainfrom Mar 3, 2022
Merged
Conversation
Instead of always using MagicMock to validate mapped arguments, this implements a more sophisticated protocol that allows an operator to implement a 'validate_mapped_arguments' to provide custom validation logic. If an operator just wants to use __init__ for validation, however, they can set a flag 'mapped_arguments_validated_by_init' to get the behavior easily. (This does *not* use MagicMock, however, since any custom validation logic should be able to handle those on its own). The 'validate_mapped_arguments' flag is currently only set on PythonOperator. It can likely be used on a lot more operators down the road.
There's just too much magic during a task's initialization that tries to add it into the dependency graph. This flag is needed to work around all that, I think.
634d55d to
2f79835
Compare
ashb
reviewed
Mar 2, 2022
39636eb to
3cccb20
Compare
Member
Author
|
Should be ready! |
ashb
approved these changes
Mar 3, 2022
|
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. |
6a23699 to
3cccb20
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of always using MagicMock to validate mapped arguments, this implements a more sophisticated protocol that allows an operator to implement a
validate_mapped_argumentsto provide custom validation logic. If an operator just wants to use__init__for validation, however, they can set a flagmapped_arguments_validated_by_initto get the behavior easily. (This does not use MagicMock, however, since any custom validation logic should be able to handle those on its own).The
validate_mapped_argumentsflag is currently only set on PythonOperator. It can likely be used on a lot more operators down the road.