fredthomsen opened a new pull request, #42578:
URL: https://github.com/apache/airflow/pull/42578
The DAG dependency view shows dependencies for DAGs that are available at
DAG parsing/serialization time. Dynamically mapped tasks that trigger (via
`TriggerDagRunOperator`) or wait for (via `ExternalTaskSensor`) external DAGs
are now listed as DAG dependencies provided that those dependencies are set via
`partial`, and not dynamically expanded.
Tested with the following:
```
@dag()
def triggering_dag():
"""
DAG that is doing the triggering.
"""
t = TriggerDagRunOperator.partial(
trigger_dag_id="triggered_dag",
task_id="triggering_task",
reset_dag_run=True,
).expand(trigger_run_id=["trigger_run_id1__{{ ts }}",
"trigger_run_id2__{{ ts }}"])
t
@dag()
def unmapped_triggering_dag():
"""
DAG that is doing the triggering.
"""
t = TriggerDagRunOperator(
trigger_dag_id="triggered_dag",
task_id="triggering_task",
reset_dag_run=True,
trigger_run_id="unmapped_trigger_run_id1__{{ ts }}",
)
t
@dag()
def triggered_dag():
"""
DAG that is getting triggered.
"""
@task()
def empty_task() -> int:
return 0
empty_task()
triggering_dag()
triggered_dag()
unmapped_triggering_dag()
@dag(
schedule="*/5 * * * *",
start_date=pendulum.datetime(2024, 1, 1),
catchup=False,
)
def mapped_sensor_dag():
"""
DAG that is doing the waiting/sensing.
"""
t = ExternalTaskSensor.partial(
task_id="wait",
external_dag_id="waited_on_dag",
deferrable=True,
check_existence=True,
).expand(external_task_id=["empty_task", "another_empty_task"])
t
@dag(
schedule="*/5 * * * *",
start_date=pendulum.datetime(2024, 1, 1),
catchup=False,
)
def unmapped_sensor_dag():
"""
DAG that is doing the waiting/sensing.
"""
t = ExternalTaskSensor(
task_id="wait",
external_dag_id="waited_on_dag",
external_task_id="empty_task",
deferrable=True,
check_existence=True,
)
t
@dag(
schedule="*/5 * * * *",
start_date=pendulum.datetime(2024, 1, 1),
catchup=False,
)
def waited_on_dag():
"""
DAG that is getting waited on.
"""
@task()
def empty_task() -> int:
return 0
@task()
def another_empty_task() -> int:
return 1
@task()
def yet_another_empty_task() -> int:
return 2
empty_task()
another_empty_task()
yet_another_empty_task()
waited_on_dag()
unmapped_sensor_dag()
mapped_sensor_dag()
```
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information.
In case of fundamental code changes, an Airflow Improvement Proposal
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party
License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a
newsfragment file, named `{pr_number}.significant.rst` or
`{issue_number}.significant.rst`, in
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]