execution_date in airflow: need to access as a variable
<p>I am really a newbie in this forum. But I have been playing with airflow, for sometime, for our company.  Sorry if this question sounds really dumb.</p>

<p>I am writing a pipeline using bunch of BashOperators. 
Basically, for each Task, I want to simply call a REST api using 'curl' </p>

<p>This is what my pipeline looks like(very simplified version):</p>

<pre><code>from airflow import DAG
from airflow.operators import BashOperator, PythonOperator
from dateutil import tz
import datetime

datetime_obj = datetime.datetime

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
    'start_date': datetime.datetime.combine(datetime_obj.today() - datetime.timedelta(1), datetime_obj.min.time()),
    'email': ['xxxx@xxx.xxx'],
    'email_on_failure': True,
    'email_on_retry': False,
    'retries': 2,
    'retry_delay': datetime.timedelta(minutes=5),
}


current_datetime = datetime_obj.now(tz=tz.tzlocal())

dag = DAG(
    'test_run', default_args=default_args, schedule_interval=datetime.timedelta(minutes=60))

curl_cmd='curl -XPOST "'+hostname+':8000/run?st='+current_datetime +'"'


t1 = BashOperator(
    task_id='rest-api-1',
    bash_command=curl_cmd,
    dag=dag)
</code></pre>

<p>If you notice I am doing <code>current_datetime= datetime_obj.now(tz=tz.tzlocal())</code>
Instead what I want here is <strong><em>'execution_date'</em></strong> </p>

<p>How do I use <strong>'execution_date'</strong> directly and assign it to a variable in my python file? </p>

<p>I have having this general issue of accessing args. 
Any help will be genuinely appreciated.</p>

<p>Thanks</p>