vemikhaylov opened a new pull request, #29608:
URL: https://github.com/apache/airflow/pull/29608

   ### Context
   
   During discussion under #28287 it was decided that it may've been useful to 
be able to pass XCom Args to a task, when it's being tested with the `tasks 
test` CLI command and notify a user if a task is dependent on some XCom Arg, 
but it hasn't been passed.
   
   ### Solution
   
   Introducing the `--xcom-args` argument for the `tasks test` command, which a 
JSON with XCom args can be passed to. The JSON has the following structure: 
`{"task_id": {"xcom_key": "value"}}`, which allows user to work both with the 
cases of the implicit XCom used by the Task Flow API (i.e., `xcom_key == 
"return_value"`) and of the XCom args with the custom keys (e.g., manually 
pushed and / or used in the templated kwargs).
   
   Hence, a full CLI call may look like: 
   
   `airflow tasks test example_passing_xcom_args_via_test_command python_echo 
--xcom-args {"get_python_echo_message": {"return_value": "test xcom arg"}}`
   
   or  
   
   `airflow tasks test run_bash_with_manually_pushed_command run_bash 
--xcom-args {"manually_push_bash_command": {"command": "echo \'test bash\'"}}`
   
   If a user misses any XCom args in their call, they'll be able to see a 
message like:
   
   ```
   airflow.exceptions.AirflowException: The task 'python_echo' is dependent on 
XCom args (task_id, key) passed from the upstream tasks: 
[('get_python_echo_message', 'return_value')]. Please, pass them via the 
--xcom-args argument (see --help for more details). The following (task_id, 
key) pairs are currently missed: [('get_python_echo_message', 'return_value')].
   ```
   
   closes: #28287


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to