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

feat(AIR302): extend the following rules #15015

Merged
merged 6 commits into from
Dec 17, 2024

Conversation

Lee-W
Copy link
Contributor

@Lee-W Lee-W commented Dec 16, 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.

  • airflow.api_connexion.security.requires_access_datasetairflow.api_connexion.security.requires_access_asset
  • airflow.auth.managers.base_auth_manager.is_authorized_datasetairflow.auth.managers.base_auth_manager.is_authorized_asset
  • airflow.auth.managers.models.resource_details.DatasetDetailsairflow.auth.managers.models.resource_details.AssetDetails
  • airflow.lineage.hook.DatasetLineageInfoairflow.lineage.hook.AssetLineageInfo
  • airflow.security.permissions.RESOURCE_DATASETairflow.security.permissions.RESOURCE_ASSET
  • airflow.www.auth.has_access_datasetairflow.www.auth.has_access_dataset.has_access_asset
  • remove airflow.datasets.DatasetAliasEvent
  • airflow.datasets.Datasetairflow.sdk.definitions.asset.Asset
  • airflow.Datasetairflow.sdk.definitions.asset.Asset
  • airflow.datasets.DatasetAliasairflow.sdk.definitions.asset.AssetAlias
  • airflow.datasets.DatasetAllairflow.sdk.definitions.asset.AssetAll
  • airflow.datasets.DatasetAnyairflow.sdk.definitions.asset.AssetAny
  • airflow.datasets.metadataairflow.sdk.definitions.asset.metadata
  • airflow.datasets.expand_alias_to_datasetsairflow.sdk.definitions.asset.expand_alias_to_assets
  • airflow.datasets.manager.dataset_managerairflow.assets.manager
  • airflow.datasets.manager.resolve_dataset_managerairflow.assets.resolve_asset_manager
  • airflow.datasets.manager.DatasetManagerairflow.assets.AssetManager
  • airflow.listeners.spec.dataset.on_dataset_createdairflow.listeners.spec.asset.on_asset_created
  • airflow.listeners.spec.dataset.on_dataset_changedairflow.listeners.spec.asset.on_asset_changed
  • airflow.timetables.simple.DatasetTriggeredTimetableairflow.timetables.simple.AssetTriggeredTimetable
  • airflow.timetables.datasets.DatasetOrTimeScheduleairflow.timetables.assets.AssetOrTimeSchedule
  • airflow.providers.amazon.auth_manager.avp.entities.AvpEntities.DATASETairflow.providers.amazon.auth_manager.avp.entities.AvpEntities.ASSET
  • airflow.providers.amazon.aws.datasets.s3.create_datasetairflow.providers.amazon.aws.assets.s3.create_asset
  • airflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineageairflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineage
  • airflow.providers.amazon.aws.datasets.s3.sanitize_uriairflow.providers.amazon.aws.assets.s3.sanitize_uri
  • airflow.providers.common.io.datasets.file.convert_dataset_to_openlineageairflow.providers.common.io.assets.file.convert_asset_to_openlineage
  • airflow.providers.common.io.datasets.file.sanitize_uriairflow.providers.common.io.assets.file.sanitize_uri
  • airflow.providers.common.io.datasets.file.create_datasetairflow.providers.common.io.assets.file.create_asset
  • airflow.providers.google.datasets.bigquery.sanitize_uriairflow.providers.google.assets.bigquery.sanitize_uri
  • airflow.providers.google.datasets.gcs.create_datasetairflow.providers.google.assets.gcs.create_asset
  • airflow.providers.google.datasets.gcs.sanitize_uriairflow.providers.google.assets.gcs.sanitize_uri
  • airflow.providers.google.datasets.gcs.convert_dataset_to_openlineageairflow.providers.google.assets.gcs.convert_asset_to_openlineage
  • airflow.providers.fab.auth_manager.fab_auth_manager.is_authorized_datasetairflow.providers.fab.auth_manager.fab_auth_manager.is_authorized_asset
  • airflow.providers.openlineage.utils.utils.DatasetInfoairflow.providers.openlineage.utils.utils.AssetInfo
  • airflow.providers.openlineage.utils.utils.translate_airflow_datasetairflow.providers.openlineage.utils.utils.translate_airflow_asset
  • airflow.providers.postgres.datasets.postgres.sanitize_uriairflow.providers.postgres.assets.postgres.sanitize_uri
  • airflow.providers.mysql.datasets.mysql.sanitize_uriairflow.providers.mysql.assets.mysql.sanitize_uri
  • airflow.providers.trino.datasets.trino.sanitize_uriairflow.providers.trino.assets.trino.sanitize_uri

In additional to the newly added rules above, the message for airflow.contrib.* and airflow.subdag.* has been extended, airflow.sensors.external_task.ExternalTaskSensorLink error has been fixed and the test fixture has been reorganized

Test Plan

A test fixture is included in the PR.

* remove `airflow.datasets.DatasetAliasEvent`
* `airflow.datasets.Dataset` → `airflow.sdk.definitions.asset.Asset`
* `airflow.Dataset` → `airflow.sdk.definitions.asset.Asset`
* `airflow.datasets.DatasetAlias` → `airflow.sdk.definitions.asset.AssetAlias`
* `airflow.datasets.DatasetAll` → `airflow.sdk.definitions.asset.AssetAll`
* `airflow.datasets.DatasetAny` → `airflow.sdk.definitions.asset.AssetAny`
* `airflow.datasets.expand_alias_to_datasets` → `airflow.sdk.definitions.asset.expand_alias_to_assets`
* `airflow.datasets.manager` → `airflow.assets.manager`
* `airflow.datasets.manager.dataset_manager` → `airflow.assets.manager`
* `airflow.datasets.manager.resolve_dataset_manager` → `airflow.assets.resolve_asset_manager`
* `airflow.datasets.manager.DatasetManager` → `airflow.assets.AssetManager`
* `airflow.listeners.spec.dataset.on_dataset_created` → `airflow.listeners.spec.asset.on_asset_created`
* `airflow.listeners.spec.dataset.on_dataset_changed` → `airflow.listeners.spec.asset.on_asset_changed`
* `airflow.timetables.datasets.DatasetOrTimeSchedule` → `airflow.timetables.assets.AssetOrTimeSchedule`
* `airflow.lineage.hook.DatasetLineageInfo` → `airflow.lineage.hook.AssetLineageInfo`
* `airflow.datasets.metadata` → `airflow.sdk.definitions.asset.metadata`
* `airflow.auth.managers.models.resource_details.DatasetDetails` → `airflow.auth.managers.models.resource_details.AssetDetails`
* `airflow.timetables.simple.DatasetTriggeredTimetable` → `airflow.timetables.simple.AssetTriggeredTimetable`
* `airflow.providers.openlineage.utils.utils.DatasetInfo` → `airflow.providers.openlineage.utils.utils.AssetInfo`
* `airflow.providers.amazon.aws.datasets.s3.create_dataset`  → `airflow.providers.amazon.aws.assets.s3.create_asset`
* `airflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineage`  → `airflow.providers.amazon.aws.assets.s3.convert_asset_to_openlineage`
* `airflow.providers.common.io.datasets.file.create_dataset` → `airflow.providers.common.io.assets.file.create_asset`
* `airflow.providers.common.io.datasets.file.convert_dataset_to_openlineage` → `airflow.providers.common.io.assets.file.convert_asset_to_openlineage`
* `airflow.api_connexion.security.requires_access_dataset` → `airflow.api_connexion.security.requires_access_asset`
* `airflow.auth.managers.base_auth_manager.is_authorized_dataset` → `airflow.auth.managers.base_auth_manager.is_authorized_asset`
* `airflow.www.auth.has_access_dataset` → `airflow.www.auth.has_access_dataset.has_access_asset`
* `airflow.providers.fab.auth_manager.fab_auth_manager.is_authorized_dataset` → `airflow.providers.fab.auth_manager.fab_auth_manager.is_authorized_asset`
* `airflow.providers.openlineage.utils.utils.translate_airflow_dataset` → `airflow.providers.openlineage.utils.utils.translate_airflow_asset`
* `airflow.providers.amazon.auth_manager.avp.entities.AvpEntities.DATASET` → `airflow.providers.amazon.auth_manager.avp.entities.AvpEntities.ASSET`
* `airflow.security.permissions.RESOURCE_DATASET` → `airflow.security.permissions.RESOURCE_ASSET`
Copy link
Contributor

github-actions bot commented Dec 16, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

ℹ️ ecosystem check detected linter changes. (+16 -0 violations, +0 -0 fixes in 1 projects; 54 projects unchanged)

apache/airflow (+16 -0 violations, +0 -0 fixes)

ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview --select ALL

+ providers/src/airflow/providers/common/compat/lineage/hook.py:39:32: AIR302 `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/compat/lineage/hook.py:39:5: AIR302 `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/compat/lineage/hook.py:63:17: AIR302 `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/compat/lineage/hook.py:67:17: AIR302 `airflow.lineage.hook.DatasetLineageInfo` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/compat/openlineage/utils/utils.py:40:59: AIR302 `airflow.providers.openlineage.utils.utils.translate_airflow_dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/io/assets/file.py:35:47: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/io/assets/file.py:37:12: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/common/io/assets/file.py:46:41: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/google/assets/gcs.py:40:74: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/google/assets/gcs.py:41:12: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/google/assets/gcs.py:50:41: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/openlineage/utils/utils.py:402:84: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/openlineage/utils/utils.py:403:86: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/openlineage/utils/utils.py:723:36: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/src/airflow/providers/openlineage/utils/utils.py:758:36: AIR302 `airflow.datasets.Dataset` is removed in Airflow 3.0
+ providers/tests/openlineage/plugins/test_utils.py:406:21: AIR302 `airflow.timetables.simple.DatasetTriggeredTimetable` is removed in Airflow 3.0

Changes by rule (1 rules affected)

code total + violation - violation + fix - fix
AIR302 16 16 0 0 0

* `airflow.providers.amazon.aws.datasets.s3.create_dataset` → `airflow.providers.amazon.aws.assets.s3.create_asset`
* `airflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineage` → `airflow.providers.amazon.aws.datasets.s3.convert_dataset_to_openlineage`
* `airflow.providers.amazon.aws.assets.s3.sanitize_uri` → `airflow.providers.amazon.aws.assets.s3.sanitize_uri`
* `airflow.providers.common.io.datasets.file.convert_dataset_to_openlineage` → `airflow.providers.common.io.assets.file.convert_asset_to_openlineage`
* `airflow.providers.common.io.datasets.file.create_dataset` → `airflow.providers.common.io.assets.file.create_asset`
* `airflow.providers.common.io.datasets.file.sanitize_uri` → `airflow.providers.common.io.assets.file.sanitize_uri`
* `airflow.providers.google.datasets.bigquery.sanitize_uri` → `airflow.providers.google.assets.bigquery.sanitize_uri`
* `airflow.providers.google.datasets.gcs.create_dataset` → `airflow.providers.google.assets.gcs.create_asset`
* `airflow.providers.google.datasets.gcs.sanitize_uri` → `airflow.providers.google.assets.gcs.sanitize_uri`
* `airflow.providers.google.datasets.gcs.convert_dataset_to_openlineage` → `airflow.providers.google.assets.gcs.convert_asset_to_openlineage`
* `airflow.providers.postgres.datasets.postgres.sanitize_uri` → `airflow.providers.postgres.assets.postgres.sanitize_uri`
* `airflow.providers.mysql.datasets.mysql.sanitize_uri` → `airflow.providers.mysql.assets.mysql.sanitize_uri`
* `airflow.providers.trino.datasets.trino.sanitize_uri` → `airflow.providers.trino.assets.trino.sanitize_uri`
@dhruvmanila dhruvmanila added rule Implementing or modifying a lint rule preview Related to preview mode features labels Dec 16, 2024
@Lee-W Lee-W marked this pull request as ready for review December 17, 2024 04:20
@MichaReiser MichaReiser merged commit 867a8f9 into astral-sh:main Dec 17, 2024
21 checks passed
dcreager added a commit that referenced this pull request Dec 17, 2024
* main:
  [red-knot] Explicitly test diagnostics are emitted for unresolvable submodule imports (#15035)
  Fix stale File status in tests (#15030)
  [red-knot] Basic support for other legacy `typing` aliases (#14998)
  feat(AIR302): extend the following rules (#15015)
  [`perflint`] Simplify finding the loop target in `PERF401` (#15025)
  [red-knot] Avoid undeclared path when raising conflicting declarations (#14958)
@Lee-W Lee-W deleted the extend-AIR302 branch December 18, 2024 00:07
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.

3 participants