title: Airflow passing 'ti' into a python method
body: <p>Good evening,</p>
  <p>In Airflow I have a task_group (tg1) that loops through a list and dynamically calls a python method which then generates a series of tasks. The issue that I am having is that I need to have access to Xcoms inside of the python method and I keep seeing error:</p>
  <p>KeyError: &quot;task_instance&quot;.  or &quot;KeyError: &quot;ti&quot;.   I have called it both ways to be sure.</p>
  <p>Task Group Code:</p>
  <pre><code>    ...
      for partitions in partition_list:
          t1 = PythonOperator(
              task_id='Refresh_Wrapper_{0}'.format(iteration),
              python_callable=refresh_task(task_id, partitions, dag, iteration),
              provide_context=True,
              dag=dag
          )
      ...
  </code></pre>
  <p>Python Method Code:</p>
  <pre><code>     def refresh_task(task_group, data, dag, iteration, **context):
           foo = &quot;baz{0}&quot;.format(str(iteration))
           bar = &quot;Bar &quot; + context['task_instance'].xcom_pull(task_ids=task_group.foo, key='return_value')
           .....
  </code></pre>