jscheffl commented on PR #41513:
URL: https://github.com/apache/airflow/pull/41513#issuecomment-2297230720

   > Here's an example of the use of the `@dag` decorator with kwargs: 
https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dags.html#the-dag-decorator
   > 
   > That page says
   > 
   > > As well as being a new way of making DAGs cleanly, the decorator also 
sets up any parameters you have in your function as DAG parameters, letting you 
[set those parameters when triggering the 
DAG](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/dag-run.html#dagrun-parameters).
 You can then access the parameters from Python code, or from {{ context.params 
}} inside a [Jinja 
template](https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/operators.html#concepts-jinja-templating).
   > 
   > So, it looks like the _intention_ is for these kwargs to be treated in the 
same way as the `params` argument to the `DAG` constructor, which _does_ accept 
`Param`s for richer trigger form definitions, as described here 
https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/params.html#use-params-to-provide-a-trigger-ui-form
   > 
   > It would seem strange that `@dag` is _deliberately_ less powerful than 
`DAG` in this regard.
   
   Yes. But what the docs say: use a Jinja2 template as templated params.So to 
be preceise I would interpret it as:
   ```
   @dag(
       schedule="* * * * * ",
       start_date=datetime.datetime.fromisoformat("2024-01-01"),
       params={
           "example_array_param": Param(["foo", "bar"], description="An example 
of an array parameter"),
       },
   )
   def test_dag(
       example_array_param="{{ params.example_array_param }}",
   ):
       (...)
   ```
   ...but I agree that yours look much cleaner and Pythonic. (As well I have 
not checked the opposite if the Jinja templating works in this case)
   
   As said it is not solely about fixing this alone but also to add proper 
tests and documentation. You don't want to have your feature breaking down 
because nobody knows about it and it is lost in a refactoring. And if it is 
cool would be great more people know about it.


-- 
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