uranusjr commented on code in PR #25410:
URL: https://github.com/apache/airflow/pull/25410#discussion_r941966038


##########
airflow/models/dag.py:
##########
@@ -460,18 +467,46 @@ def __init__(
             self.default_args['end_date'] = 
timezone.convert_to_utc(self.default_args['end_date'])
 
         # sort out DAG's scheduling behavior
-        scheduling_args = [schedule_interval, timetable, schedule_on]
+        scheduling_args = [schedule_interval, timetable, schedule]
         if not at_most_one(*scheduling_args):
-            raise ValueError(
-                "At most one allowed for args 'schedule_interval', 
'timetable', and 'schedule_on'."
+            raise ValueError("At most one allowed for args 
'schedule_interval', 'timetable', and 'schedule'.")
+        if schedule_interval is not NOTSET:
+            warnings.warn(
+                "Param `schedule_interval` is deprecated and will be removed 
in a future release. "
+                "Please use `schedule` instead. ",
+                DeprecationWarning,
+                stacklevel=2,
+            )
+        if timetable is not None:
+            warnings.warn(
+                "Param `timetable` is deprecated and will be removed in a 
future release. "
+                "Please use `schedule` instead. ",
+                DeprecationWarning,
+                stacklevel=2,
             )
-
         self.timetable: Timetable
         self.schedule_interval: ScheduleInterval
-        self.schedule_on: Optional[List["Dataset"]] = list(schedule_on) if 
schedule_on else None
-        if schedule_on:
-            if not isinstance(schedule_on, Sequence):
-                raise ValueError("Param `schedule_on` must be 
Sequence[Dataset]")
+        self.dataset_triggers: Optional[List[Dataset]] = None
+
+        if schedule is not NOTSET:
+            if isinstance(schedule, List):
+                # if List, only support List[Dataset]
+                if any(isinstance(x, Dataset) for x in schedule):
+                    if not all(isinstance(x, Dataset) for x in schedule):
+                        raise ValueError(
+                            "If scheduling DAG with List[Dataset], all 
elements must be Dataset."
+                        )
+                    self.dataset_triggers = list(schedule)
+                else:
+                    raise ValueError(
+                        "Use of List object with `schedule` param is only 
supported for List[Dataset]."
+                    )
+            elif isinstance(schedule, Timetable):
+                timetable = schedule
+            else:  # assumed to be ScheduleIntervalArg
+                schedule_interval = schedule

Review Comment:
   Just simpler? The original implementation has some unnecessary nesting.



-- 
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]

Reply via email to