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

[airflow]: extend removed method calls (AIR302) #15054

Merged
merged 2 commits into from
Dec 20, 2024

Conversation

Lee-W
Copy link
Contributor

@Lee-W Lee-W commented Dec 19, 2024

Summary

Airflow 3.0 removes various deprecated functions, members, modules, and other values. They have been deprecated in 2.x, but the removal causes incompatibilities that we want to detect. This PR deprecates the following names and add a function for removed methods

  • airflow.datasets.manager.DatasetManager.register_dataset_changeairflow.assets.manager.AssetManager.register_asset_change
  • airflow.datasets.manager.DatasetManager.create_datasetsairflow.assets.manager.AssetManager.create_assets
  • airflow.datasets.manager.DatasetManager.notify_dataset_createdairflow.assets.manager.AssetManager.notify_asset_created
  • airflow.datasets.manager.DatasetManager.notify_dataset_changedairflow.assets.manager.AssetManager.notify_asset_changed
  • airflow.datasets.manager.DatasetManager.notify_dataset_alias_createdairflow.assets.manager.AssetManager.notify_asset_alias_created
  • airflow.providers.amazon.auth_manager.aws_auth_manager.AwsAuthManager.is_authorized_datasetairflow.providers.amazon.auth_manager.aws_auth_manager.AwsAuthManager.is_authorized_asset
  • airflow.lineage.hook.HookLineageCollector.create_datasetairflow.lineage.hook.HookLineageCollector.create_asset
  • airflow.lineage.hook.HookLineageCollector.add_input_datasetairflow.lineage.hook.HookLineageCollector.add_input_asset
  • airflow.lineage.hook.HookLineageCollector.add_output_datasetairflow.lineage.hook.HookLineageCollector.dd_output_asset
  • airflow.lineage.hook.HookLineageCollector.collected_datasetsairflow.lineage.hook.HookLineageCollector.collected_assets
  • airflow.providers_manager.ProvidersManager.initialize_providers_dataset_uri_resourcesairflow.providers_manager.ProvidersManager.initialize_providers_asset_uri_resources

Test Plan

A test fixture is included in the PR.

* `airflow.datasets.manager.DatasetManager.register_dataset_change` → `airflow.assets.manager.AssetManager.register_asset_change`
* `airflow.datasets.manager.DatasetManager.create_datasets` → `airflow.assets.manager.AssetManager.create_assets`
* `airflow.datasets.manager.DatasetManager.notify_dataset_created` → `airflow.assets.manager.AssetManager.notify_asset_created`
* `airflow.datasets.manager.DatasetManager.notify_dataset_changed` → `airflow.assets.manager.AssetManager.notify_asset_changed`
* `airflow.datasets.manager.DatasetManager.notify_dataset_alias_created` → `airflow.assets.manager.AssetManager.notify_asset_alias_created`
* `airflow.providers.amazon.auth_manager.aws_auth_manager.AwsAuthManager.is_authorized_dataset` → `airflow.providers.amazon.auth_manager.aws_auth_manager.AwsAuthManager.is_authorized_asset`
* `airflow.lineage.hook.HookLineageCollector.create_dataset` → `airflow.lineage.hook.HookLineageCollector.create_asset`
* `airflow.lineage.hook.HookLineageCollector.add_input_dataset` → `airflow.lineage.hook.HookLineageCollector.add_input_asset`
* `airflow.lineage.hook.HookLineageCollector.add_output_dataset` → `airflow.lineage.hook.HookLineageCollector.dd_output_asset`
* `airflow.lineage.hook.HookLineageCollector.collected_datasets` → `airflow.lineage.hook.HookLineageCollector.collected_assets`
* `airflow.providers_manager.ProvidersManager.initialize_providers_dataset_uri_resources` → `airflow.providers_manager.ProvidersManager.initialize_providers_asset_uri_resources`
@Lee-W Lee-W changed the title feat(AIR302): add the following rules for method name changes [airflow]: extend removed method calls (AIR302) Dec 19, 2024
Copy link
Contributor

github-actions bot commented Dec 19, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule preview Related to preview mode features labels Dec 19, 2024
@@ -607,6 +714,8 @@ pub(crate) fn removed_in_3(checker: &mut Checker, expr: &Expr) {
if let Some(qualname) = checker.semantic().resolve_qualified_name(func) {
removed_argument(checker, &qualname, arguments);
};

removed_method(checker, func);
Copy link
Member

Choose a reason for hiding this comment

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

Can we skip calling removed_method if the resolved_qualified_name call was successful or does it need both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think both are needed.

Copy link
Contributor Author

@Lee-W Lee-W Dec 19, 2024

Choose a reason for hiding this comment

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

e.g.,

from airflow.datasets.manager import DatasetManager

d = DatasetManager()
d.register_dataset_change()

needs 2 warnings

  1. import error
  2. method call error

@MichaReiser MichaReiser merged commit 14a5a26 into astral-sh:main Dec 20, 2024
21 checks passed
MichaReiser added a commit that referenced this pull request Dec 20, 2024
## Summary

Smaller nits follow up to #15054
because I wasn't able to push to the branch directly.

## Test Plan

`cargo test`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
preview Related to preview mode features rule Implementing or modifying a lint rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants