question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rendered Templates - py renderer doesn't work for list or dict

See original GitHub issue

Apache Airflow version: 2.1.1

What happened:

The rendered templates screen doesn’t show the operator arguments for TaskFlow API operators. image

What you expected to happen:

Should show the arguments after any templates have been rendered.

How to reproduce it:

Will happen for any @task decorated operator.

Anything else we need to know:

This issue appears on a number of operators. Possible solution is to modify the “get_python_source” in utils/code_utils.py to handle list and dict. This would cause any operator that using py as the renderer to handle lists and dicts. Possibly something like:

    if isinstance(x, list):
        return [str(v) for v in x]

    if isinstance(x, dict):
        return {k: str(v) for k, v in x.items()}

The converting values to strings seems necessary in order to avoid errors when this is passed to the pygments lexer. image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
brain-bustercommented, Jul 18, 2021

@brain-buster - would you like to make a PR to fix the issue maybe ?

Yes, of course. I will make PR tomorrow ASAP since this bug is completely affects my project.

0reactions
potiukcommented, Jul 18, 2021

@brain-buster - would you like to make a PR to fix the issue maybe ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Django render doesn't seem to pass dictionary to template
It looks like your template expects results2 to be a list of dicts, while you're passing a single dict.
Read more >
Django shortcut functions
Combines a given template with a given context dictionary and returns an HttpResponse object with that rendered text. Django does not provide a...
Read more >
Primer on Jinja Templating - Real Python
Render the template: Fill the placeholders with content. You can provide a dictionary or keyword arguments as context. In this case, you've ...
Read more >
Renderers - Django REST framework
The TemplateHTMLRenderer will create a RequestContext , using the response.data as the context dict, and determine a template name to use to render...
Read more >
Rendering a String, List & Dictionary in Flask
When rendering a string, list, or dictionary in HTML from within a Flask app, you need to pass the variables from Python to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found