milton0825 commented on a change in pull request #5598:
[AIRFLOW-733][AIRFLOW-883] Apply default_args when setting `op.dag = dag` or
`dag >> op`
URL: https://github.com/apache/airflow/pull/5598#discussion_r304020523
##########
File path: airflow/models/dag.py
##########
@@ -1093,6 +1093,21 @@ def add_task(self, task):
:param task: the task you want to add
:type task: task
"""
+ if task.task_id in self.task_dict:
+ # TODO: raise an error in Airflow 2.0
+ warnings.warn(
+ 'The requested task could not be added to the DAG because a '
+ 'task with task_id {} is already in the DAG. Starting in '
+ 'Airflow 2.0, trying to overwrite a task will raise an '
+ 'exception.'.format(task.task_id),
+ category=PendingDeprecationWarning)
+ else:
+ self.task_dict[task.task_id] = task
+ task.dag = self
+
+ if hasattr(task.__init__, "reapply_defaults"):
+ task.__init__.reapply_defaults(self)
Review comment:
Interesting. Didn't know that the wrapper can be accessed in this way.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services