henry3260 commented on code in PR #58852:
URL: https://github.com/apache/airflow/pull/58852#discussion_r2653065892
##########
airflow-core/src/airflow/timetables/base.py:
##########
@@ -238,6 +238,34 @@ def summary(self) -> str:
"""
return type(self).__name__
+ @property
+ def type_name(self) -> str:
+ """
+ This is primarily intended for filtering dags based on timetable type.
+
+ For built-in timetables (defined in airflow.timetables or
+ airflow.sdk.definitions.timetables), this returns the class name only.
+ For custom timetables (user-defined via plugins), this returns the full
+ import path to avoid confusion between multiple implementations with
the
+ same class name.
+
+ For example, built-in timetables return:
+ ``"NullTimetable"`` or ``"CronDataIntervalTimetable"``
+ while custom timetables return the full path:
+ ``"my_company.timetables.CustomTimetable"``
+ """
+ module = self.__class__.__module__
+ class_name = self.__class__.__name__
+
+ # Built-in timetables from Core or SDK use class name only
+ if module.startswith("airflow.timetables.") or module.startswith(
+ "airflow.sdk.definitions.timetables."
+ ):
+ return class_name
Review Comment:
> Maybe this can just do `module.startswith("airflow.")`?
It is not recommended to change this to `module.startswith('airflow.')`, as
it would treat all `airflow.*` modules (including `airflow.providers.*` and
third-party/custom modules) as 'built-in'. This would make it impossible to
distinguish between Timetable classes with the same name.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]