PetroFit / petrofit

Python package for calculating Petrosian properties and fitting galaxy light profiles
https://petrofit.readthedocs.io
28 stars 7 forks source link

'jinja2.utils' has no attribute 'escape' #110

Closed robelgeda closed 2 years ago

robelgeda commented 2 years ago

There is a bug with nbconvert that is causing tests to fail.

Bug

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbsphinx.py", line 1032, in parse
    rststring, resources = exporter.from_notebook_node(nb, resources)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbsphinx.py", line 849, in from_notebook_node
    rststr, resources = super(Exporter, self).from_notebook_node(
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbconvert/exporters/templateexporter.py", line 392, in from_notebook_node
    output = self.template.render(nb=nb_copy, resources=resources)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/jinja2/environment.py", line 1291, in render
    self.environment.handle_exception()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/jinja2/environment.py", line 926, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 128, in top-level template code
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/rst/index.rst.j2", line 1, in top-level template code
    {%- extends 'display_priority.j2' -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/display_priority.j2", line 1, in top-level template code
    {%- extends 'base/null.j2' -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 26, in top-level template code
    {%- block body -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 29, in block 'body'
    {%- block body_loop -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 31, in block 'body_loop'
    {%- block any_cell scoped -%}
  File "<template>", line 17, in block 'any_cell'
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 34, in block 'any_cell'
    {%- block codecell scoped -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 44, in block 'codecell'
    {%- block output_group -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 48, in block 'output_group'
    {%- block outputs scoped -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 50, in block 'outputs'
    {%- block output scoped -%}
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/share/jupyter/nbconvert/templates/base/null.j2", line 54, in block 'output'
    {%- block stream scoped -%}
  File "<template>", line 152, in block 'stream'
  File "<template>", line 138, in block 'nboutput'
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/jinja2/runtime.py", line 777, in _invoke
    rv = self._func(*arguments)
  File "<template>", line 66, in template
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbconvert/filters/ansi.py", line 60, in ansi2html
    text = jinja2.utils.escape(text)
AttributeError: module 'jinja2.utils' has no attribute 'escape'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/cmd/build.py", line 284, in build_main
    app.build(args.force_all, filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/application.py", line 337, in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    self.build(to_build,
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 308, in build
    updated_docnames = set(self.read())
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 415, in read
    self._read_serial(docnames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 436, in _read_serial
    self.read_doc(docname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/builders/__init__.py", line 476, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/io.py", line 189, in read_doc
    pub.publish()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/docutils/core.py", line 217, in publish
    self.document = self.reader.read(self.source, self.parser,
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/sphinx/io.py", line 109, in read
    self.parse()
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/docutils/readers/__init__.py", line 78, in parse
    self.parser.parse(self.input, document)
  File "/home/docs/checkouts/readthedocs.org/user_builds/petrofit/conda/v0.4.0/lib/python3.10/site-packages/nbsphinx.py", line 1041, in parse
    raise NotebookError(type(e).__name__ + ' in ' +
nbsphinx.NotebookError: AttributeError in correction_grids.ipynb:
module 'jinja2.utils' has no attribute 'escape'

Notebook error:
AttributeError in correction_grids.ipynb:
module 'jinja2.utils' has no attribute 'escape'

Ticket Tracking Bug

https://github.com/jupyter/nbconvert/issues/1736

Solution

For now, I will add a patch that will restrict the new version of 'jinja2.utils' that is causing this issue. The hope is that nbconvert releases a patched up version and we can remove the patch. I will keep this ticket open as a reminder to remove the patch.

robelgeda commented 2 years ago

Re-openning and keeping open until nbconvert releases with a fix.

robelgeda commented 2 years ago

Working again!