airflow/models/dag.py
def add_task(self, task):
        """
        Add a task to the DAG

        :param task: the task you want to add
        :type task: task
        """
        if not self.start_date and not task.start_date:
            raise AirflowException("Task is missing the start_date parameter")
        # if the task has no start date, assign it the same as the DAG
        elif not task.start_date:
            task.start_date = self.start_date
        # otherwise, the task will start on the later of its own start date and
        # the DAG's start date
        elif self.start_date:
            task.start_date = max(task.start_date, self.start_date)

        # if the task has no end date, assign it the same as the dag
        if not task.end_date:
            task.end_date = self.end_date
        # otherwise, the task will end on the earlier of its own end date and
        # the DAG's end date
        elif task.end_date and self.end_date:
            task.end_date = min(task.end_date, self.end_date)

        if (
            task.task_id in self.task_dict and self.task_dict[task.task_id] is not task
        ) or task.task_id in self._task_group.used_group_ids:
            raise DuplicateTaskIdFound(f"Task id '{task.task_id}' has already been added to the DAG")
        else:
            self.task_dict[task.task_id] = task
            task.dag = self
            # Add task_id to used_group_ids to prevent group_id and task_id collisions.
            self._task_group.used_group_ids.add(task.task_id)

        self.task_count = len(self.task_dict)

        Add a task to the DAG

        :param task: the task you want to add
        :type task: task
        
Add a task to the DAG
Add a task to the DAG
def add_task(self, task):
        if not self.start_date and not task.start_date:
            raise AirflowException("Task is missing the start_date parameter")
        elif not task.start_date:
            task.start_date = self.start_date
        elif self.start_date:
            task.start_date = max(task.start_date, self.start_date)
        if not task.end_date:
            task.end_date = self.end_date
        elif task.end_date and self.end_date:
            task.end_date = min(task.end_date, self.end_date)
        if (
            task.task_id in self.task_dict and self.task_dict[task.task_id] is not task
        ) or task.task_id in self._task_group.used_group_ids:
            raise DuplicateTaskIdFound(f"Task id '{task.task_id}' has already been added to the DAG")
        else:
            self.task_dict[task.task_id] = task
            task.dag = self
            self._task_group.used_group_ids.add(task.task_id)
        self.task_count = len(self.task_dict)
def add_task ( self , task ) : if not self . start_date and not task . start_date : raise AirflowException ( "Task is missing the start_date parameter" ) elif not task . start_date : task . start_date = self . start_date elif self . start_date : task . start_date = max ( task . start_date , self . start_date ) if not task . end_date : task . end_date = self . end_date elif task . end_date and self . end_date : task . end_date = min ( task . end_date , self . end_date ) if ( task . task_id in self . task_dict and self . task_dict [ task . task_id ] is not task ) or task . task_id in self . _task_group . used_group_ids : raise DuplicateTaskIdFound ( f"Task id '{task.task_id}' has already been added to the DAG" ) else : self . task_dict [ task . task_id ] = task task . dag = self self . _task_group . used_group_ids . add ( task . task_id ) self . task_count = len ( self . task_dict )
Add a task to the DAG
Add a task to the DAG
"""
        Add a task to the DAG

        :param task: the task you want to add
        :type task: task
        """ # if the task has no start date, assign it the same as the DAG # otherwise, the task will start on the later of its own start date and # the DAG's start date # if the task has no end date, assign it the same as the dag # otherwise, the task will end on the earlier of its own end date and # the DAG's end date # Add task_id to used_group_ids to prevent group_id and task_id collisions.
self
task
the task you want to add
the task you want to add