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

   ### Description
   
   The new Trigger Form UI released in 2.6 is handy but doesn't support `array` 
params of data types other than string. For more flexibility, this PR proposes 
to generate a JSON field similar to the `object` param if the users specify the 
attribute `items` in `schema`.
   
   ### How to reproduce the issue
   
   Use an `array` param and require the items to be integers.
   
   ```
   with DAG(
       dag_id=Path(__file__).stem,
       description=__doc__[0 : __doc__.find(".")],
       doc_md=__doc__,
       schedule=None,
       start_date=datetime.datetime(2022, 3, 4),
       catchup=False,
       tags=["example_ui"],
       params={
           "array_of_numbers": Param(
               [1, 2, 3],
               "Only integers are accepted in this array",
               type="array",
               title="Array of numbers",
               items={"type": "number"},
           ),
       },
   ) as dag:
   
       @task(task_id="show_params")
       def show_params(**kwargs) -> None:
           ti: TaskInstance = kwargs["ti"]
           dag_run: DagRun = ti.dag_run
           if not dag_run.conf:
               print("Uups, no parameters supplied as DagRun.conf, was the 
trigger w/o form?")
               raise AirflowSkipException("No DagRun.conf parameters supplied.")
           print(f"This DAG was triggered with the following 
parameters:\n{json.dumps(dag_run.conf, indent=4)}")
   
       show_params()
   ``` 
   
   The Generated Conf JSON shows an array of strings
   
   <img width="1132" alt="image" 
src="https://github.com/apache/airflow/assets/9677913/36191337-3676-4f61-aed5-24b278bffe95";>
   
   And we cannot trigger the DAG:
   
   <img width="1162" alt="image" 
src="https://github.com/apache/airflow/assets/9677913/d8369464-8d77-4ce6-9c5b-9492e19a14c8";>
   
   
   ### Workaround
   
   We can manually update the Generated Configuration JSON box, but it is not 
user friendly (especially if we expect an array of objects!), and will become 
counter intuitive as users get used to the benefits of the new trigger form.
   
   
   What do you think @jens-scheffler-bosch ?
   
   
   
   


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