This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new bf41344f94 Fix main after accidental breakage when merging notifier
changes (#33157)
bf41344f94 is described below
commit bf41344f945378a1573ef7fdb09d4930a14063c2
Author: Jarek Potiuk <[email protected]>
AuthorDate: Sun Aug 6 20:26:06 2023 +0200
Fix main after accidental breakage when merging notifier changes (#33157)
The #33116 has been merged but it did not have "full tests needed"
and it crossed with ruff upgrade. Also provider verification has
been brokent (but not run in the PR) by having wrong Name
(Notification vs. Notifier) and by not excluding notification
check for Airflow version 2.
---
airflow/providers_manager.py | 2 +-
scripts/in_container/verify_providers.py | 31 +++++++++++++++++++++++++------
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/airflow/providers_manager.py b/airflow/providers_manager.py
index 0aa8ff170e..e25e82c265 100644
--- a/airflow/providers_manager.py
+++ b/airflow/providers_manager.py
@@ -536,7 +536,7 @@ class ProvidersManager(LoggingMixin, metaclass=Singleton):
"""Lazy initialization of providers executors information."""
self.initialize_providers_list()
self._discover_executors()
-
+
@provider_info_cache("notifications")
def initialize_providers_notifications(self):
"""Lazy initialization of providers notifications information."""
diff --git a/scripts/in_container/verify_providers.py
b/scripts/in_container/verify_providers.py
index c332423f12..ea824e3e1c 100755
--- a/scripts/in_container/verify_providers.py
+++ b/scripts/in_container/verify_providers.py
@@ -104,7 +104,7 @@ SECRETS_PATTERN = r".*Backend$"
TRANSFERS_PATTERN = r".*To[A-Z0-9].*Operator$"
WRONG_TRANSFERS_PATTERN = r".*Transfer$|.*TransferOperator$"
TRIGGER_PATTERN = r".*Trigger$"
-NOTIFICATION_PATTERN = r".*Notification$"
+NOTIFICATION_PATTERN = r".*Notifier|.*send_.*_notification$"
ALL_PATTERNS = {
OPERATORS_PATTERN,
@@ -124,7 +124,7 @@ EXPECTED_SUFFIXES: dict[EntityType, str] = {
EntityType.Secrets: "Backend",
EntityType.Transfers: "Operator",
EntityType.Trigger: "Trigger",
- EntityType.Notification: "Notification",
+ EntityType.Notification: "Notifier",
}
@@ -468,7 +468,14 @@ def get_package_class_summary(
from airflow.secrets import BaseSecretsBackend
from airflow.sensors.base import BaseSensorOperator
from airflow.triggers.base import BaseTrigger
- from airflow.notifications.basenotifier import BaseNotifier
+
+ # Remove this conditional check after providers are 2.6+ compatible
+ try:
+ from airflow.notifications.basenotifier import BaseNotifier
+
+ has_notifier = True
+ except ImportError:
+ has_notifier = False
all_verified_entities: dict[EntityType, VerifiedEntities] = {
EntityType.Operators: find_all_entities(
@@ -529,15 +536,21 @@ def get_package_class_summary(
expected_class_name_pattern=TRIGGER_PATTERN,
unexpected_class_name_patterns=ALL_PATTERNS - {TRIGGER_PATTERN},
),
- EntityType.Notification: find_all_entities(
+ }
+ if has_notifier:
+ all_verified_entities[EntityType.Notification] = find_all_entities(
imported_classes=imported_classes,
base_package=full_package_name,
sub_package_pattern_match=r".*\.notifications\..*",
ancestor_match=BaseNotifier,
expected_class_name_pattern=NOTIFICATION_PATTERN,
unexpected_class_name_patterns=ALL_PATTERNS -
{NOTIFICATION_PATTERN},
- ),
- }
+ )
+ else:
+ all_verified_entities[EntityType.Notification] = VerifiedEntities(
+ all_entities=set(), wrong_entities=[]
+ )
+
for entity in EntityType:
print_wrong_naming(entity,
all_verified_entities[entity].wrong_entities)
@@ -583,6 +596,12 @@ def check_if_classes_are_properly_named(
for class_full_name in entity_summary[entity_type].entities:
_, class_name = class_full_name.rsplit(".", maxsplit=1)
error_encountered = False
+ if (
+ class_name.startswith("send_")
+ and class_name.endswith("_notification")
+ and entity_type == EntityType.Notification
+ ):
+ continue
if not is_camel_case_with_acronyms(class_name):
console.print(
f"[red]The class {class_full_name} is wrongly named. The "