Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a dummy operator at the start of parallel pipelines #2197

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions dlt/helpers/airflow_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from airflow.configuration import conf
from airflow.models import TaskInstance
from airflow.utils.task_group import TaskGroup
from airflow.operators.dummy import DummyOperator
from airflow.operators.empty import EmptyOperator
from airflow.operators.python import PythonOperator, get_current_context
except ModuleNotFoundError:
raise MissingDependencyException("Airflow", ["apache-airflow>=2.5"])
Expand Down Expand Up @@ -448,10 +448,10 @@ def make_task(pipeline: Pipeline, data: Any, name: str = None) -> PythonOperator
tasks = []
sources = data.decompose("scc")
t_name = self._task_name(pipeline, data)
start = make_task(pipeline, sources[0])
start = EmptyOperator(task_id=f"{t_name}_start")

# parallel tasks
for source in sources[1:]:
for source in sources:
for resource in source.resources.values():
if resource.incremental:
logger.warn(
Expand All @@ -466,7 +466,7 @@ def make_task(pipeline: Pipeline, data: Any, name: str = None) -> PythonOperator

tasks.append(make_task(pipeline, source))

end = DummyOperator(task_id=f"{t_name}_end")
end = EmptyOperator(task_id=f"{t_name}_end")

if tasks:
start >> tasks >> end
Expand All @@ -485,22 +485,18 @@ def make_task(pipeline: Pipeline, data: Any, name: str = None) -> PythonOperator
tasks = []
naming = SnakeCaseNamingConvention()
sources = data.decompose("scc")
start = make_task(
pipeline,
sources[0],
naming.normalize_identifier(self._task_name(pipeline, sources[0])),
)
start = EmptyOperator(task_id=f"{t_name}_start")

# parallel tasks
for source in sources[1:]:
for source in sources:
# name pipeline the same as task
new_pipeline_name = naming.normalize_identifier(
self._task_name(pipeline, source)
)
tasks.append(make_task(pipeline, source, new_pipeline_name))

t_name = self._task_name(pipeline, data)
end = DummyOperator(task_id=f"{t_name}_end")
end = EmptyOperator(task_id=f"{t_name}_end")

if tasks:
start >> tasks >> end
Expand Down