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/02/11 14:33:28 UTC

[GitHub] [airflow] dimonchik-suvorov opened a new issue #14192: Rendered templates not properly formatted

dimonchik-suvorov opened a new issue #14192:
URL: https://github.com/apache/airflow/issues/14192


   The case is when Airflow preparing a `Rendered Template` view it uses Jinja and Jinja uses a simple `pprint` which returns an ugly result surrounded by redundant single/double quotes in case it can't found and import `pretty` module.
   
   <details>
   <summary>Example of how it could be displayed</summary>
   <p>
   
   ```
   ('USE test_db;\n'
   '\n'
   'INSERT OVERWRITE TABLE \n'
   ' test_table\n'
   "PARTITION (part_column = 'some_part_value')\n"
   '\n'
   'SELECT  \n'
   ' field1           AS f_1,\n'
   ' count(*)         AS cnt\n'
   'FROM\n'
   ' source_table\n'
   'WHERE\n'
   " part_column = 'some_part_value';")
   ```
   </p>
   </details>  
   
   The line of Airflow code where it uses Jinja formatting - [views.py#L916](https://github.com/apache/airflow/blob/master/airflow/www/views.py#L916)
   


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

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



[GitHub] [airflow] ryanahamilton closed issue #14192: Rendered templates not properly formatted

Posted by GitBox <gi...@apache.org>.
ryanahamilton closed issue #14192:
URL: https://github.com/apache/airflow/issues/14192


   


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

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



[GitHub] [airflow] ryanahamilton commented on issue #14192: Rendered templates not properly formatted

Posted by GitBox <gi...@apache.org>.
ryanahamilton commented on issue #14192:
URL: https://github.com/apache/airflow/issues/14192#issuecomment-805226245


   Closing this based on [@kaxil's response](https://github.com/apache/airflow/pull/14193#issuecomment-777615243) and the PR closure on #14193
   > The library `pretty-py3` is not actively maintained and I am not sure if we should use it that globally.
   > 
   > Jinja uses built-in library not an external library -
   https://github.com/pallets/jinja/blob/f009a004a2e70a3608d49aceb1814b90bb4370d6/src/jinja2/utils.py#L160
   > 
   > https://docs.python.org/3.8/library/pprint.html
   > 
   > That said -- I think the users who want it can use the library you mentioned or add their own custom filter.
   > 
   > You can just do `{{ yourvar| custom_pprint}}` where `custom_pprint` is your custom filter and Jinja will print it nicely I think: https://stackoverflow.com/a/25728848/5691525


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

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