You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/22 07:51:02 UTC

[GitHub] [airflow] mehmax edited a comment on pull request #17082: #16976 Add json.dumps() for templated fields objects: 'dict' and 'list'

mehmax edited a comment on pull request #17082:
URL: https://github.com/apache/airflow/pull/17082#issuecomment-884718338


   Hi, may I bring something up which I noticed while testing this:
   When I use templated files in a _PythonVirtualenvDecoratedOperator and my file contains linebreaks, json.dumps will not add add them in the UI.
   This is not very beautiful:
   Example
   ![image](https://user-images.githubusercontent.com/84371809/126605156-92c5f6fb-6182-463d-8b8b-bac60ee10702.png)
   
   Can we make it so that each key in a dictionary is rendered seperately? Like this (just an Idea):
   ![image](https://user-images.githubusercontent.com/84371809/126604916-1604a803-71c4-42bd-9104-1995181f62e0.png)
   
   Coding I used (no optimized!):
   
   ```
               if renderer in renderers:
                   if isinstance(content, dict):
                       logging.info(content)
                       for key, value in content.items():
                           html_dict[key] = renderers[renderer](value)
                   if isinstance(content, list):
                       content = json.dumps(content, sort_keys=True, indent=4)
                       html_dict[template_field] = renderers[renderer](content)
   ```
   
   
   
   
   


-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org