Search code examples
attributesairflowmarkdown

How to remove unused "attributes" in Airflow docs?


Inside a BashOperator, I added a markdown snippet of documentation for the "Task Instance Details" of my Airflow nodes. Now I can see my markdown, defined by the attribute "doc_md", but also

Attribute: bash_command
Attribute: doc
Attribute: doc_json
Attribute: doc_rst
Attribute: doc_yaml

I don't want to show any other attributes more than "doc_md", is it possible?

enter image description here


Solution

  • You can hide some attribute from the table which is just below by adding them to HIDE_ATTRS_FROM_UI, but currently you cannot hide the attributes you have mentioned in your question.

    Airflow defines them in this method then it checks if the operators contains the attribute, and if yes, it adds it to the UI, and the attributes you want to hide are defined in the BaseOperator which is the parent of all the other operators.

    A solution is creating a new operator by copy the code of BaseOperator without the fields you want to hide (here), then duplicating the code for the operators you are using and extending the new operator instead of BaseOperator, but I'm not sure if it's worth it.

    Feel free to create an issue or open a pull request on Airflow to add a new option to hide these attributes.