nailo2c commented on issue #56953:
URL: https://github.com/apache/airflow/issues/56953#issuecomment-3500712646
Hi, I think you need to use `context` if you want to use `--task-params`
e.g.
```python
from airflow.decorators import dag, task
@dag
def problem_dag():
@task
def get_numbers(**context):
return [1,2]
@task
def multiply_by_two(number, **context):
if context["params"].get("number") is not None:
number = context["params"]["number"]
return number * 2
numbers = get_numbers()
multiplied_numbers = multiply_by_two.expand(number=numbers)
problem_dag()
```
result 1
```console
root@9afb732f3cd7:/opt/airflow# airflow tasks test problem_dag
multiply_by_two --map-index 0 -t '{"number":2}'
2025-11-07T04:51:08.515952Z [info ] Done. Returned value was: 4
[airflow.task.operators.airflow.providers.standard.decorators.python._PythonDecoratedOperator]
loc=python.py:218
```
result 2
```console
root@9afb732f3cd7:/opt/airflow# airflow tasks test problem_dag
multiply_by_two --map-index 0 -t '{"number":1}'
2025-11-07T04:52:28.369291Z [info ] Done. Returned value was: 2
[airflow.task.operators.airflow.providers.standard.decorators.python._PythonDecoratedOperator]
loc=python.py:218
```
--
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]