<h2 dir="auto">Python version: 3.6.12<br>
Airflow version: 2.0.1<br>
Node: sandbox-hdp.hortonworks.com</h2>
<p dir="auto">Traceback (most recent call last):<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app<br>
response = self.full_dispatch_request()<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request<br>
rv = self.handle_user_exception(e)<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception<br>
reraise(exc_type, exc_value, tb)<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/flask/<em>compat.py", line 39, in reraise<br>
raise value<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request<br>
rv = self.dispatch_request()<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request<br>
return self.view_functions<a href="**req.view_args">rule.endpoint</a><br>
File "/root/airflow/venv/lib64/python3.6/site-packages/airflow/www/auth.py", line 34, in decorated<br>
return func(*args, **kwargs)<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/airflow/www/views.py", line 532, in index<br>
user_permissions = current_app.appbuilder.sm.get_current_user_permissions()<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/airflow/www/security.py", line 229, in get_current_user_permissions<br>
{(perm_view.permission.name, perm_view.view_menu.name) for perm_view in role.permissions}<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/airflow/www/security.py", line 229, in <br>
{(perm_view.permission.name, perm_view.view_menu.name) for perm_view in role.permissions}<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 453, in <strong>get</strong><br>
return self.impl.get(state, dict</em>)<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/sqlalchemy/orm/attributes.py", line 897, in get<br>
value = self.callable_(state, passive)<br>
File "/root/airflow/venv/lib64/python3.6/site-packages/sqlalchemy/orm/strategies.py", line 831, in _load_for_state<br>
% (orm_util.state_str(state), self.key)<br>
<strong>sqlalchemy.orm.exc.DetachedInstanceError: Parent instance &lt;PermissionView at 0x7fef4bf3e4e0&gt; is not bound to a Session; lazy load operation of attribute 'view_menu' cannot proceed (Background on this error at: <a href="http://sqlalche.me/e/14/bhk3" rel="nofollow">http://sqlalche.me/e/14/bhk3</a>)</strong></p>
<h3 dir="auto">Apache Airflow version</h3>
<p dir="auto">2.4.0</p>
<h3 dir="auto">What happened</h3>
<p dir="auto">From v2.4.0，I run dynamic task mapping example, got many warnings.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from airflow import DAG
from airflow.decorators import task
import pendulum as pl

with DAG(
    dag_id='test-dynamic-tasks', 
    description='测试动态task的注册告警',
    schedule=None,
    start_date=pl.today().add(days=-1),
) as dag:

    @task
    def sum_it(values):
        print(sum(values))

    @task
    def add_one(i):
        return i + 1

    added_values = add_one.expand(i = [1,2])
    sum_it(added_values)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">airflow</span> <span class="pl-k">import</span> <span class="pl-v">DAG</span>
<span class="pl-k">from</span> <span class="pl-s1">airflow</span>.<span class="pl-s1">decorators</span> <span class="pl-k">import</span> <span class="pl-s1">task</span>
<span class="pl-k">import</span> <span class="pl-s1">pendulum</span> <span class="pl-k">as</span> <span class="pl-s1">pl</span>

<span class="pl-k">with</span> <span class="pl-v">DAG</span>(
    <span class="pl-s1">dag_id</span><span class="pl-c1">=</span><span class="pl-s">'test-dynamic-tasks'</span>, 
    <span class="pl-s1">description</span><span class="pl-c1">=</span><span class="pl-s">'测试动态task的注册告警'</span>,
    <span class="pl-s1">schedule</span><span class="pl-c1">=</span><span class="pl-c1">None</span>,
    <span class="pl-s1">start_date</span><span class="pl-c1">=</span><span class="pl-s1">pl</span>.<span class="pl-en">today</span>().<span class="pl-en">add</span>(<span class="pl-s1">days</span><span class="pl-c1">=</span><span class="pl-c1">-</span><span class="pl-c1">1</span>),
) <span class="pl-k">as</span> <span class="pl-s1">dag</span>:

    <span class="pl-en">@<span class="pl-s1">task</span></span>
    <span class="pl-k">def</span> <span class="pl-en">sum_it</span>(<span class="pl-s1">values</span>):
        <span class="pl-en">print</span>(<span class="pl-en">sum</span>(<span class="pl-s1">values</span>))

    <span class="pl-en">@<span class="pl-s1">task</span></span>
    <span class="pl-k">def</span> <span class="pl-en">add_one</span>(<span class="pl-s1">i</span>):
        <span class="pl-k">return</span> <span class="pl-s1">i</span> <span class="pl-c1">+</span> <span class="pl-c1">1</span>

    <span class="pl-s1">added_values</span> <span class="pl-c1">=</span> <span class="pl-s1">add_one</span>.<span class="pl-en">expand</span>(<span class="pl-s1">i</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>])
    <span class="pl-en">sum_it</span>(<span class="pl-s1">added_values</span>)</pre></div>
<p dir="auto">Warnings like this.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks"><pre class="notranslate"><code class="notranslate">[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Mapped(_PythonDecoratedOperator): add_one&gt;, sum_it already registered for DAG: test-dynamic-tasks
[2022-09-30, 09:11:29 CST] {taskmixin.py:205} WARNING - Dependency &lt;Task(_PythonDecoratedOperator): sum_it&gt;, add_one already registered for DAG: test-dynamic-tasks
</code></pre></div>
<h3 dir="auto">What you think should happen instead</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">How to reproduce</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating System</h3>
<p dir="auto">CentOS Linux release 7.9.2009 (Core)</p>
<h3 dir="auto">Versions of Apache Airflow Providers</h3>
<p dir="auto">airflow-code-editor                      7.0.0<br>
apache-airflow                           2.4.0<br>
apache-airflow-providers-celery          3.0.0<br>
apache-airflow-providers-common-sql      1.1.0<br>
apache-airflow-providers-ftp             3.1.0<br>
apache-airflow-providers-http            4.0.0<br>
apache-airflow-providers-imap            3.0.0<br>
apache-airflow-providers-microsoft-psrp  2.0.0<br>
apache-airflow-providers-microsoft-winrm 3.0.0<br>
apache-airflow-providers-mysql           3.2.0<br>
apache-airflow-providers-redis           3.0.0<br>
apache-airflow-providers-samba           4.0.0<br>
apache-airflow-providers-sftp            4.0.0<br>
apache-airflow-providers-sqlite          3.2.0<br>
apache-airflow-providers-ssh             3.1.0</p>
<h3 dir="auto">Deployment</h3>
<p dir="auto">Other</p>
<h3 dir="auto">Deployment details</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Anything else</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Are you willing to submit PR?</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Yes I am willing to submit a PR!</li>
</ul>
<h3 dir="auto">Code of Conduct</h3>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> I agree to follow this project's <a href="https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md">Code of Conduct</a></li>
</ul>