title: Airflow: Dynamically generate tasks with TaskFlow API
body: <p>Previously I used the following snippet to dynamically generate tasks:</p>
  <pre><code>dummy_start_task = PythonOperator(
      task_id=&quot;dummy_start&quot;,
      default_args=default_args,
      python_callable=dummy_start,
      dag=dag
  )
  
  make_images_tasks = list()
  for n in range(WORKERS):
      globals()[f&quot;make_images_{n}_task&quot;] = PythonOperator(
          task_id=f'make_images_{n}',
          default_args=default_args,
          python_callable=make_images,
          op_kwargs={&quot;n&quot;: n},
          dag=dag
      )
      make_images_tasks.append(globals()[f&quot;make_images_{n}_task&quot;])
  
  dummy_collector_task = PythonOperator(
      task_id=&quot;dummy_collector&quot;,
      default_args=default_args,
      python_callable=dummy_collector,
      dag=dag
  )
  
  dummy_start_task &gt;&gt; make_images_tasks &gt;&gt; dummy_collector_task
  
  # in collector_task I would use:
  # items = task_instance.xcom_pull(task_ids=[f&quot;make_images_{n}&quot; for n in range(int(WORKERS))])
  # to get the XCOMs from the these dynamically generated tasks
  </code></pre>
  <p>How can I achieve that using the TaskFlow API? (Spawn multiple tasks and then get their XComs in the following collector-task)</p>