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 class attributes and more methods (AIR302) #15083

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Lee-W
Copy link
Contributor

@Lee-W Lee-W commented Dec 20, 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 methods and add a function for removed class attributes

  • airflow.providers_manager.ProvidersManager.dataset_factoriesairflow.providers_manager.ProvidersManager.asset_factories
  • airflow.providers_manager.ProvidersManager.dataset_uri_handlersairflow.providers_manager.ProvidersManager.asset_uri_handlers
  • airflow.providers_manager.ProvidersManager.dataset_to_openlineage_convertersairflow.providers_manager.ProvidersManager.asset_to_openlineage_converters
  • airflow.lineage.hook.DatasetLineageInfo.datasetairflow.lineage.hook.AssetLineageInfo.asset

Any class in Airflow that inherits these class should not have these methods

  • airflow.secrets.base_secrets.BaseSecretsBackend.get_conn_uriairflow.secrets.base_secrets.BaseSecretsBackend.get_conn_value
  • airflow.secrets.base_secrets.BaseSecretsBackend.get_connectionsairflow.secrets.base_secrets.BaseSecretsBackend.get_connection
  • airflow.hooks.base.BaseHook.get_connections → use get_connection
  • airflow.datasets.BaseDataset.iter_datasetsairflow.sdk.definitions.asset.BaseAsset.iter_assets
  • airflow.datasets.BaseDataset.iter_dataset_aliasesairflow.sdk.definitions.asset.BaseAsset.iter_asset_aliases

Test Plan

A test fixture is included in the PR.

Any class in Airflow that inherits these class should not have these methods

* `airflow.secrets.base_secrets.BaseSecretsBackend.get_conn_uri` → `airflow.secrets.base_secrets.BaseSecretsBackend.get_conn_value`
* `airflow.secrets.base_secrets.BaseSecretsBackend.get_connections` → `airflow.secrets.base_secrets.BaseSecretsBackend.get_connection`
* `airflow.hooks.base.BaseHook.get_connections` → use `get_connection`
* `airflow.datasets.BaseDataset.iter_datasets` → `airflow.sdk.definitions.asset.BaseAsset.iter_assets`
* `airflow.datasets.BaseDataset.iter_dataset_aliases` → `airflow.sdk.definitions.asset.BaseAsset.iter_asset_aliases`
@Lee-W Lee-W changed the title [airflow]: extend removed method class attributes and more methods(AIR302) [airflow]: extend removed method class attributes and more methods (AIR302) Dec 20, 2024
Comment on lines +255 to +259
_ if SECRET_BACKEND_REGEX.is_match(&qualname.segments().join(".")) => match attr.as_str() {
"get_conn_uri" => Some(Replacement::Name("get_conn_value")),
"get_connections" => Some(Replacement::Name("get_connection")),
&_ => None,
},
Copy link
Member

Choose a reason for hiding this comment

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

It should be possible to simplify the regex a bit (to ensure it runs less frequently?)

Suggested change
_ if SECRET_BACKEND_REGEX.is_match(&qualname.segments().join(".")) => match attr.as_str() {
"get_conn_uri" => Some(Replacement::Name("get_conn_value")),
"get_connections" => Some(Replacement::Name("get_connection")),
&_ => None,
},
["airflow", rest @ ..] if SECRET_BACKEND_REGEX.is_match(rest.join(".")) => match attr.as_str() {
"get_conn_uri" => Some(Replacement::Name("get_conn_value")),
"get_connections" => Some(Replacement::Name("get_connection")),
&_ => None,
},

This requires removing the airflow segment from the regex. The advantage is that we can skip over the match if the first segment isn't airflow

Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants