Repository: incubator-airflow Updated Branches: refs/heads/master bf8c8b247 -> b75367bb5
[AIRFLOW-1975] Make TriggerDagRunOperator callback optional Closes #2921 from bcb/make-trigger-dag-run- callback-optional Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/b75367bb Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/b75367bb Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/b75367bb Branch: refs/heads/master Commit: b75367bb572e8bbfc1bfd539fbb34a76a5ed484d Parents: bf8c8b2 Author: Beau Barker <[email protected]> Authored: Wed Jan 10 19:59:22 2018 +0100 Committer: Bolke de Bruin <[email protected]> Committed: Wed Jan 10 19:59:22 2018 +0100 ---------------------------------------------------------------------- airflow/operators/dagrun_operator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/b75367bb/airflow/operators/dagrun_operator.py ---------------------------------------------------------------------- diff --git a/airflow/operators/dagrun_operator.py b/airflow/operators/dagrun_operator.py index 2b5a814..2c363c8 100644 --- a/airflow/operators/dagrun_operator.py +++ b/airflow/operators/dagrun_operator.py @@ -28,7 +28,7 @@ class DagRunOrder(object): class TriggerDagRunOperator(BaseOperator): """ - Triggers a DAG run for a specified ``dag_id`` if a criteria is met + Triggers a DAG run for a specified ``dag_id`` :param trigger_dag_id: the dag_id to trigger :type trigger_dag_id: str @@ -51,7 +51,7 @@ class TriggerDagRunOperator(BaseOperator): def __init__( self, trigger_dag_id, - python_callable, + python_callable=None, *args, **kwargs): super(TriggerDagRunOperator, self).__init__(*args, **kwargs) self.python_callable = python_callable @@ -59,7 +59,8 @@ class TriggerDagRunOperator(BaseOperator): def execute(self, context): dro = DagRunOrder(run_id='trig__' + timezone.utcnow().isoformat()) - dro = self.python_callable(context, dro) + if self.python_callable is not None: + dro = self.python_callable(context, dro) if dro: with create_session() as session: dbag = DagBag(settings.DAGS_FOLDER)
