[ 
https://issues.apache.org/jira/browse/AIRFLOW-2517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16489929#comment-16489929
 ] 

Jacques Gaudin edited comment on AIRFLOW-2517 at 5/25/18 7:39 AM:
------------------------------------------------------------------

The same could be done for `test`. Please see this SO question:

[https://stackoverflow.com/questions/50132215/set-dag-run-conf-parameters-in-call-to-airflow-test/50360218#50360218]

 

 


was (Author: jacques gaudin):
The same could be done for `test`. Please see this SO question:

https://issues.apache.org/jira/browse/AIRFLOW-2517

 

> 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
>            Priority: Major
>
> 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:java}
>  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:java}
>  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