Chao-Han Tsai created AIRFLOW-2517:
--------------------------------------

             Summary: backfill support passing key values through CLI
                 Key: AIRFLOW-2517
                 URL: https://issues.apache.org/jira/browse/AIRFLOW-2517
             Project: Apache Airflow
          Issue Type: Improvement
            Reporter: Chao-Han Tsai
            Assignee: Chao-Han Tsai


In backfill, we can provide key-value pairs through CLI and those pairs can be 
accessed through macros. This is just like the way `trigger_dag -c` works [1].

Let's walk through an example.

In the airflow CLI we specify a key-value pair.
{code}
 airflow backfill hello_world -s 2018-02-01 -e 2018-02-08 -c ' {"text": "some 
text"}
{code}
 ```

In the DAG file, I have a `BashOperator` that contains a template command and I 
want 
 \{{ dag_run.conf.text }} resolves to the text I passed in CLI. 
{code:python}
 templated_command = """
 echo "ds = {{ ds }}"
 echo "prev_ds = {{ macros.datetime.strftime(prev_execution_date, "%Y-%m-%d") 
}}"
 echo "next_ds = {{ macros.datetime.strftime(next_execution_date, "%Y-%m-%d") 
}}"
 echo "text_through_conf = {{ dag_run.conf.text }}"
 """

bash_operator = BashOperator(
 task_id='bash_task',
 bash_command=templated_command,
 dag=dag
 )
{code}

[1] [https://airflow.apache.org/cli.html#trigger_dag]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to