jedcunningham commented on code in PR #22867:
URL: https://github.com/apache/airflow/pull/22867#discussion_r846523919


##########
docs/apache-airflow/concepts/dynamic-task-mapping.rst:
##########
@@ -0,0 +1,256 @@
+ .. 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.
+
+====================
+Dynamic Task Mapping
+====================
+
+Dynamic Task Mapping allows a way for a workflow to create a number of tasks 
at runtime based upon current data, rather than the DAG author having to know 
in advance how many tasks would be needed.
+
+This is similar to defining your tasks in a for loop, but instead of having 
the DAG file fetch the data and do that itself, the scheduler can do this based 
on the output of a previous task. Right before a mapped task is executed the 
scheduler will create *n* copies of the task, one for each input.
+
+It is also possible to have a task operate on the collected output of a mapped 
task, commonly known as map and reduce.
+
+Simple mapping
+==============
+
+In its simplest form you can map over a list defined directly in your DAG file 
using the ``expand()`` function instead of calling your task directly.
+
+.. code-block:: python
+
+    from airflow import DAG

Review Comment:
   ```suggestion
       from datetime import datetime
   
       from airflow import DAG
   ```



##########
docs/apache-airflow/concepts/dynamic-task-mapping.rst:
##########
@@ -0,0 +1,256 @@
+ .. 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.
+
+====================
+Dynamic Task Mapping
+====================
+
+Dynamic Task Mapping allows a way for a workflow to create a number of tasks 
at runtime based upon current data, rather than the DAG author having to know 
in advance how many tasks would be needed.
+
+This is similar to defining your tasks in a for loop, but instead of having 
the DAG file fetch the data and do that itself, the scheduler can do this based 
on the output of a previous task. Right before a mapped task is executed the 
scheduler will create *n* copies of the task, one for each input.
+
+It is also possible to have a task operate on the collected output of a mapped 
task, commonly known as map and reduce.
+
+Simple mapping
+==============
+
+In its simplest form you can map over a list defined directly in your DAG file 
using the ``expand()`` function instead of calling your task directly.
+
+.. code-block:: python
+
+    from airflow import DAG
+    from airflow.decorators import task
+
+
+    with DAG(dag_id="simple_mapping", start_date=datetime(2022, 3, 4)):
+
+        @task
+        def add_one(x: int):
+            return x + 1
+
+        @task
+        def sum_it(values):
+            total = sum(values)
+            print(f"Total was {total}")
+
+        added_values = add_one.expand(x=[1, 2, 3])
+        sum_it(added_values)
+
+This will show ``Total was 9`` in the task logs when executed.
+
+.. note:: A reduce task is not required.
+
+    Although we show a "reduce" task here (``sum_it``) you don't have to have 
one, the mapped tasks will still be executed even if they have no downstream 
tasks.
+
+Repeated Mapping
+================
+
+The result of one mapped task can also be used as input to the next mapped task
+
+.. code-block:: python
+
+    from airflow import DAG
+    from airflow.decorators import task
+
+
+    with DAG(dag_id="repeated_mapping", start_date=datetime(2022, 3, 4)):

Review Comment:
   ```suggestion
       with DAG(dag_id="repeated_mapping", start_date=datetime(2022, 3, 4)) as 
dag:
   ```



##########
docs/apache-airflow/concepts/dynamic-task-mapping.rst:
##########
@@ -0,0 +1,256 @@
+ .. 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.
+
+====================
+Dynamic Task Mapping
+====================
+
+Dynamic Task Mapping allows a way for a workflow to create a number of tasks 
at runtime based upon current data, rather than the DAG author having to know 
in advance how many tasks would be needed.
+
+This is similar to defining your tasks in a for loop, but instead of having 
the DAG file fetch the data and do that itself, the scheduler can do this based 
on the output of a previous task. Right before a mapped task is executed the 
scheduler will create *n* copies of the task, one for each input.
+
+It is also possible to have a task operate on the collected output of a mapped 
task, commonly known as map and reduce.
+
+Simple mapping
+==============
+
+In its simplest form you can map over a list defined directly in your DAG file 
using the ``expand()`` function instead of calling your task directly.
+
+.. code-block:: python
+
+    from airflow import DAG
+    from airflow.decorators import task
+
+
+    with DAG(dag_id="simple_mapping", start_date=datetime(2022, 3, 4)):

Review Comment:
   ```suggestion
       with DAG(dag_id="simple_mapping", start_date=datetime(2022, 3, 4)) as 
dag:
   ```



-- 
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]

Reply via email to