Skip to content

Replace external_trigger check with DagRunType #45932

@kaxil

Description

@kaxil

Now that we have explicit Dag Run types, we should not need DagRun.external_trigger too.

Example, the following code can be changed

def choose_branch(self, context: Context) -> str | Iterable[str]:
# If the DAG Run is externally triggered, then return without
# skipping downstream tasks
dag_run: DagRun = context["dag_run"] # type: ignore[assignment]
if dag_run.external_trigger:
self.log.info("Externally triggered DAG_Run: allowing execution to proceed.")
return list(context["task"].get_direct_relative_ids(upstream=False))

to

    def choose_branch(self, context: Context) -> str | Iterable[str]:
        # If the DAG Run is manually triggered, then return without
        # skipping downstream tasks
        dag_run: DagRun = context["dag_run"]  # type: ignore[assignment]
        if dag_run.run_type == DagRunType.MANUAL:
            self.log.info("Externally triggered DAG_Run: allowing execution to proceed.")
            return list(context["task"].get_direct_relative_ids(upstream=False))

We should replace all usages of DagRun.external_trigger and remove it from DB too.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions