airflow
airflow copied to clipboard
Support multiline input for Params of type string in trigger UI form
This patch adds the possibility to have a multiline input (textarea) for Params of type "string" in the trigger UI form. The choice between rendering a text input (single line) or a textarea (multiline) is based on the presence of a new line character in any of the examples of the Param. For instance, the following code generates a multiline input:
Param(
description="a parameter that is rendered better with a textarea",
type=["string", "null"],
examples=["first line of text before\na new line"],
)
I know Params of type "array" are rendered as textareas but forcing our end-users to format their multiline text into an array of strings would not be very friendly :). So it seems more practical to leave the Param as a "string" type and work on the rendering options instead.
The patch is merely a PoC to showcase what the feature would look like and by no means a definitive solution. I think that relying on the examples attribute is more a hack than a solution, but adding a new explicit attribute to the Param object is beyond my understanding of Airflow. So feel free to rewrite it completely if you think the feature is worth it.
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst) Here are some useful points:
- Pay attention to the quality of your code (ruff, mypy and type annotations). Our pre-commits will help you with that.
- In case of a new feature add useful documentation (in docstrings or in
docs/directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it. - Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
- Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
- Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
- Be sure to read the Airflow Coding style.
- Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits. Apache Airflow is a community-driven project and together we are making it better 🚀. In case of doubts contact the developers at: Mailing List: [email protected] Slack: https://s.apache.org/airflow-slack
Thanks for the feedback ! I'll try to check whether the format attribute of the JSON schema for string type can be used in this case.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.
Some static checks fail. Though I like the implementation a lot more than before... actually as project team we have decided (1) that Airflow 2.10 will only get new features in exceptional cases and (2) the UI will be completely re-written - So an upcoming Airflow 3 will have a 100% new codebase for UI... this change probably will never to live in any future release.
@bbovenzi WDYT how should we treat this PR? Make it to main to have a reminder to migrate it/the feature to the new UI? I think it is useful but code needs to be re-written anyway in 100% React.
Some static checks fail. Though I like the implementation a lot more than before... actually as project team we have decided (1) that Airflow 2.10 will only get new features in exceptional cases and (2) the UI will be completely re-written - So an upcoming Airflow 3 will have a 100% new codebase for UI... this change probably will never to live in any future release.
@bbovenzi WDYT how should we treat this PR? Make it to main to have a reminder to migrate it/the feature to the new UI? I think it is useful but code needs to be re-written anyway in 100% React.
I think this is a small enough of a surface area where adding it now doesn't significantly change how we rebuild this view. But having it in the code reminds us to make this feature work in 2.10.
Some static checks fail. Though I like the implementation a lot more than before... actually as project team we have decided (1) that Airflow 2.10 will only get new features in exceptional cases and (2) the UI will be completely re-written - So an upcoming Airflow 3 will have a 100% new codebase for UI... this change probably will never to live in any future release. @bbovenzi WDYT how should we treat this PR? Make it to main to have a reminder to migrate it/the feature to the new UI? I think it is useful but code needs to be re-written anyway in 100% React.
I think this is a small enough of a surface area where adding it now doesn't significantly change how we rebuild this view. But having it in the code reminds us to make this feature work in 2.10.
@sc-anssi So then I would say... if you fix the static checks then we could merge it and back-port to a 2.10.2 release...
@sc-anssi So then I would say... if you fix the static checks then we could merge it and back-port to a 2.10.2 release...
Spelling is fixed, please let me know if anything else needs to be done :+1:
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.