-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Fail a task if an inlet or and outlet asset is inactive #44831
base: main
Are you sure you want to change the base?
Fail a task if an inlet or and outlet asset is inactive #44831
Conversation
fc63134
to
5064159
Compare
2 test cases still need to be fixed but the overall implementation is wrapped up |
b93851a
to
e75afd4
Compare
e75afd4
to
71eb6f4
Compare
71eb6f4
to
78fc85c
Compare
Should we also fail if an inactive asset is added by the user to an asset alias? I feel we should for consistency. If that’s the case, this should better be done after the task is run (during the event-pushing phase) instead. |
Yes, this is also missed.
I'm not sure 🤔 If we already know the task should fail, I think we should fail it at earlier stage (i.e., inlets and outlets cases). If this is a super resource consumsing task, this helps saving resource. But for the asset alias case, this is not something we can handle before task execution, we should do it after task execution. |
e0e92bf
to
d686a1d
Compare
just handled |
…he_same_dag and test_run_with_inactive_assets_in_different_dags
… be able to be activated when adding
d686a1d
to
4082c6a
Compare
Why this change
In AIP-74, we introduce a new "name" column to the Asset. We do not expect to have assets with the same name or URI. For example,
Asset(name="test-name", uri="test://asset")
andAsset("test-name")
would be considered assets that violate this rule.Currently, we do nothing when a task has an unexpected asset as an inlet or outlet. The following example works fine now, even though it should not.
Back to #42612, we introduced the concept of AssetActive. These assets that are classified as inactive. While the first asset can still be activated, subsequent assets will not be activated. For example, if
Asset("test", "s3://my-bucket/my-key/")
is activated first, thenAsset("s3://my-bucket/my-key/")
will not be activated. This rule applies even if the assets are defined in different DAGs or in separate files.What's the change
The activation status of an asset has already been addressed in previous pull requests. In this pull request, we have implemented a task that checks for any inactive assets in the outlets or inlets. If any inactive assets are found, it raises an
AirflowExecuteWithInactiveAssetException
, which inherits fromAirflowFailException
, causing the task to fail.Closes: #44600
Test
Tested with the following test cases. All of them worked fine before this fix and received a similar error message to the screenshot below after this fix.
Inactive assets in inlets
Inactive assets in outlets
Inactive assets mixed in inlets and outlets
Inactive assets cross files
^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named
{pr_number}.significant.rst
or{issue_number}.significant.rst
, in newsfragments.