Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formgrader error when trying to manually grade a specific submission: "Sorry, the formgrader encountered an error. Please contact the administrator of the formgrader for further assistance. " #1373

Closed
LaurentHayez opened this issue Sep 29, 2020 · 11 comments · Fixed by #1567
Labels
Milestone

Comments

@LaurentHayez
Copy link

Operating system

Ubuntu 20.04.1 LTS

nbgrader --version

0.6.1

jupyterhub --version (if used with JupyterHub)

1.0.0

(I'm getting a weird error when typing this:

future: <Task finished coro=<JupyterHub.launch_instance_async() done, defined at /opt/tljh/user/lib/python3.7/site-packages/jupyterhub/app.py:2477> exception=SystemExit(0)>
Traceback (most recent call last):
  File "/opt/tljh/user/lib/python3.7/site-packages/jupyterhub/app.py", line 2492, in launch_instance
    loop.start()
  File "/opt/tljh/user/lib/python3.7/site-packages/tornado/platform/asyncio.py", line 132, in start
    self.asyncio_loop.run_forever()
  File "/opt/tljh/user/lib/python3.7/asyncio/base_events.py", line 539, in run_forever
    self._run_once()
  File "/opt/tljh/user/lib/python3.7/asyncio/base_events.py", line 1775, in _run_once
    handle._run()
  File "/opt/tljh/user/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/opt/tljh/user/lib/python3.7/site-packages/jupyterhub/app.py", line 2479, in launch_instance_async
    await self.initialize(argv)
  File "/opt/tljh/user/lib/python3.7/site-packages/jupyterhub/app.py", line 2085, in initialize
    super().initialize(*args, **kwargs)
  File "/opt/tljh/user/lib/python3.7/site-packages/traitlets/config/application.py", line 86, in inner
    return method(app, *args, **kwargs)
  File "/opt/tljh/user/lib/python3.7/site-packages/traitlets/config/application.py", line 326, in initialize
    self.parse_command_line(argv)
  File "/opt/tljh/user/lib/python3.7/site-packages/traitlets/config/application.py", line 86, in inner
    return method(app, *args, **kwargs)
  File "/opt/tljh/user/lib/python3.7/site-packages/traitlets/config/application.py", line 693, in parse_command_line
    self.exit(0)
  File "/opt/tljh/user/lib/python3.7/site-packages/traitlets/config/application.py", line 827, in exit
    sys.exit(exit_status)
SystemExit: 0

jupyter notebook --version

6.0.3

Expected behavior

Be able to manually grade the submissions when clicking on the submission id in the formgrader/gradebook tab.

Actual behavior

Page is displaying the error "Sorry, the formgrader encountered an error. Please contact the administrator of the formgrader for further assistance."

Steps to reproduce the behavior

It's the first time since I installed it this year that I tried to manually grade assignments and it diplays this error. I autograded the assignments from the command line, then clicked on the Formgrader tab, then Manual Grading tab, then on the Assignment ID, Notebook ID, and when I try to access any specific submission, I get the previous error.

Here is a part of my journalctl log that contains the error:

Sep 29 06:07:05 yahoocluster-7 bash[67034]:     HTTPServerRequest(protocol='https', host='clusterinfo.unineuchatel.ch:10002', method='GET', uri='/user/hayezl/formgrader/submissions/788073b4>
Sep 29 06:07:05 yahoocluster-7 bash[67034]:     Traceback (most recent call last):
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/tornado/web.py", line 1590, in _execute
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         result = method(*self.path_args, **self.path_kwargs)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/tornado/web.py", line 3006, in wrapper
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return method(self, *args, **kwargs)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbgrader/server_extensions/formgrader/base.py", line 108, in wrapper
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return f(self, *args, **kwargs)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbgrader/server_extensions/formgrader/base.py", line 117, in wrapper
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return f(self, *args, **kwargs)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbgrader/server_extensions/formgrader/handlers.py", line 125, in get
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         html, _ = self.exporter.from_filename(filename, resources=resources)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 182, in from_filename
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return self.from_file(f, resources=resources, **kw)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbconvert/exporters/exporter.py", line 200, in from_file
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbconvert/exporters/html.py", line 122, in from_notebook_node
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return super().from_notebook_node(nb, resources, **kw)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 382, in from_notebook_node
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         output = self.template.render(nb=nb_copy, resources=resources)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 143, in template
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         self._template_cached = self._load_template()
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/nbconvert/exporters/templateexporter.py", line 353, in _load_template
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return self.environment.get_template(template_file)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/jinja2/environment.py", line 883, in get_template
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         return self._load_template(name, self.make_globals(globals))
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/jinja2/environment.py", line 857, in _load_template
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         template = self.loader.load(self, name, globals)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       File "/opt/tljh/user/lib/python3.7/site-packages/jinja2/loaders.py", line 429, in load
Sep 29 06:07:05 yahoocluster-7 bash[67034]:         raise TemplateNotFound(name)
Sep 29 06:07:05 yahoocluster-7 bash[67034]:     jinja2.exceptions.TemplateNotFound: formgrade
Sep 29 06:07:05 yahoocluster-7 bash[67034]: [E 2020-09-29 06:07:05.479 SingleUserNotebookApp log:166] {
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Host": "clusterinfo.unineuchatel.ch:10002",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Accept-Encoding": "gzip, deflate, br",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Accept-Language": "fr-CH,en-US;q=0.7,en;q=0.3",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Cookie": "jupyterhub-user-hayezl=[secret]; _xsrf=[secret]; jupyterhub-session-id=[secret]",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Referer": "https://clusterinfo.unineuchatel.ch:10002/user/hayezl/formgrader/gradebook/Serie1/Fourier2021_serie1",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "Upgrade-Insecure-Requests": "1",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "X-Forwarded-For": "51.154.36.71, 192.168.128.1",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "X-Forwarded-Host": "clusterinfo.unineuchatel.ch:10002",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "X-Forwarded-Port": "10002",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "X-Forwarded-Proto": "https",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "X-Forwarded-Server": "yahoocluster-7",
Sep 29 06:07:05 yahoocluster-7 bash[67034]:       "X-Real-Ip": "192.168.128.1"
Sep 29 06:07:05 yahoocluster-7 bash[67034]:     }
Sep 29 06:07:05 yahoocluster-7 bash[67034]: [E 2020-09-29 06:07:05.479 SingleUserNotebookApp log:174] 500 GET /user/hayezl/formgrader/submissions/788073b4944d43b09f2b9e449127dd3d/ (hayezl@1>

Thanks for any help regarding this issue.

@jjsapido
Copy link

Having the same weird issue in a docker container installation
jinja2.exceptions.TemplateNotFound: formgrade
any hint?

@jjsapido
Copy link

jjsapido commented Sep 30, 2020

Found another similar error when trying to generate feedback

[WARNING] Config option `template_path` not recognized by `HTMLExporter`.  Did you mean one of: `template_file, template_name, template_paths`?
[INFO] Copying /home/admin/pythonExam/autograded/user/ps1/jupyter.png -> /home/admin/pythonExam/feedback/user/ps1/jupyter.png
[INFO] Copying /home/admin/pythonExam/autograded/user/ps1/timestamp.txt -> /home/admin/pythonExam/feedback/user/ps1/timestamp.txt
[INFO] Converting notebook /home/admin/pythonExam/autograded/user/ps1/problem1.ipynb
[ERROR] There was an error processing assignment: /home/admin/pythonExam/autograded/user/ps1
[ERROR] Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/nbgrader/converters/base.py", line 336, in convert_notebooks
        self.convert_single_notebook(notebook_filename)
      File "/usr/local/lib/python3.8/dist-packages/nbgrader/converters/base.py", line 292, in convert_single_notebook
        output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/exporter.py", line 181, in from_filename
        return self.from_file(f, resources=resources, **kw)
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/exporter.py", line 199, in from_file
        return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/html.py", line 119, in from_notebook_node
        return super().from_notebook_node(nb, resources, **kw)
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/templateexporter.py", line 387, in from_notebook_node
        output = self.template.render(nb=nb_copy, resources=resources)
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/templateexporter.py", line 148, in template
        self._template_cached = self._load_template()
      File "/usr/local/lib/python3.8/dist-packages/nbconvert/exporters/templateexporter.py", line 358, in _load_template
        return self.environment.get_template(template_file)
      File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 883, in get_template
        return self._load_template(name, self.make_globals(globals))
      File "/usr/local/lib/python3.8/dist-packages/jinja2/environment.py", line 857, in _load_template
        template = self.loader.load(self, name, globals)
      File "/usr/local/lib/python3.8/dist-packages/jinja2/loaders.py", line 429, in load
        raise TemplateNotFound(name)
    jinja2.exceptions.TemplateNotFound: feedback.tpl
    
[WARNING] Removing failed assignment: /home/admin/pythonExam/feedback/user/ps1
[ERROR] There was an error processing assignment 'ps1' for student 'user'
[ERROR] Please see the the above traceback for details on the specific errors on the above failures.

@gzagatti
Copy link

gzagatti commented Oct 2, 2020

I had the same problem on the latest version of nbgrader, version 0.6.1, which I manage to fix.

The problem seems to be caused by the way nbgrader is handling Jinja templates.

  1. HTMLExporter does not have the template_path configuration, it should be template_paths notice the plural at the end. This affects nbgrader/server_extensions/formgrader.py and nbgrader/converters/generate_feedback.py

  2. nbgrader/server_extensions/formgrader/formgrader.py is not correctly appending to HTMLExporter.template_paths. This should be an append not assignment.

  3. The server extensions templates are not using the latest nbconverter Jinja 2 file extension. They should all be moved from tpl to .html.j2 The references inside of the files to .tpl files should also be fixed accordingly.

Once I fixed those templating issues, I was able to render the webpage.

@ZiminXia
Copy link

ZiminXia commented Oct 2, 2020

Hi, I had the same problem with nbconvert 6.0.6 (perhaps version 6.0.x all have this problem).
Seems jupyter notebook uses the nbconvert to convert .ipynb file into .HTML file. It has "template_paths" configuration. As mentioned above nbgrader uses "template_path" (without plural).

For me, downgrading nbconvert to 5.6.1 solves this problem. Hope this is helpful for you.

@perllaghu
Copy link
Contributor

nbconvert 6.0.0 was known to break for the Feedback system, so this seems similar.

The master branch has pinned nbconvert to 5.6.1

If you were to create a branch that fixed nbgrader for nbconvert 6, that would be awesome.

Else downgrade nbconvert, or install from master

@LaurentHayez
Copy link
Author

Thank you for your replies.

I tried to tingle with @gzagatti 's suggestion of modifying the variable names as well as the extension files, but I did not manage to make it work that way.

Solution that works

As suggested by @perllaghu and @ZXia221 , downgrading nbconvert to version 5.6.1 solves the issue (so far, I can open a specific submission, I did not try to generate and release feeback to the stutents yet).

On jupyterhub, one can simply open a terminal and type

sudo -E pip uninstall nbconvert
sudo -E pip install --upgrade nbconvert==5.6.1

rkdarst added a commit to AaltoSciComp/nbgrader that referenced this issue Jan 8, 2021
- From jupyter#1373, thanks @gzagatti
- I can't quickly find the latest version of jinja2 that requires this
rkdarst added a commit to AaltoSciComp/nbgrader that referenced this issue Jan 8, 2021
- Solution from jupyter#1373, thanks to @gzagatti
- I don't know how or why this works
rkdarst added a commit to AaltoSciComp/nbgrader that referenced this issue Jan 11, 2021
- From jupyter#1373, thanks @gzagatti
- I can't quickly find the latest version of jinja2 that requires this
rkdarst added a commit to AaltoSciComp/nbgrader that referenced this issue Jan 11, 2021
- Solution from jupyter#1373, thanks to @gzagatti
- I don't know how or why this works
rkdarst added a commit to AaltoSciComp/nbgrader that referenced this issue Jan 11, 2021
- From jupyter#1373, thanks @gzagatti
- I can't quickly find the latest version of jinja2 that requires this
rkdarst added a commit to AaltoSciComp/nbgrader that referenced this issue Jan 11, 2021
- Solution from jupyter#1373, thanks to @gzagatti
- I don't know how or why this works
jhamrick pushed a commit to jhamrick/nbgrader that referenced this issue Mar 18, 2021
- From jupyter#1373, thanks @gzagatti
- I can't quickly find the latest version of jinja2 that requires this
jhamrick pushed a commit to jhamrick/nbgrader that referenced this issue Mar 18, 2021
- Solution from jupyter#1373, thanks to @gzagatti
- I don't know how or why this works
jhamrick pushed a commit to jhamrick/nbgrader that referenced this issue Mar 18, 2021
- From jupyter#1373, thanks @gzagatti
- I can't quickly find the latest version of jinja2 that requires this
jhamrick pushed a commit to jhamrick/nbgrader that referenced this issue Mar 18, 2021
- Solution from jupyter#1373, thanks to @gzagatti
- I don't know how or why this works
@jhamrick jhamrick added this to the No action milestone Mar 18, 2021
@jhamrick jhamrick modified the milestones: No action, 0.7.0 Mar 18, 2021
jhamrick pushed a commit to jhamrick/nbgrader that referenced this issue Mar 19, 2021
- From jupyter#1373, thanks @gzagatti
- I can't quickly find the latest version of jinja2 that requires this
jhamrick pushed a commit to jhamrick/nbgrader that referenced this issue Mar 19, 2021
- Solution from jupyter#1373, thanks to @gzagatti
- I don't know how or why this works
This was referenced Mar 25, 2021
@orboan
Copy link

orboan commented Jun 10, 2021

I had the same problem on the latest version of nbgrader, version 0.6.1, which I manage to fix.

The problem seems to be caused by the way nbgrader is handling Jinja templates.

  1. HTMLExporter does not have the template_path configuration, it should be template_paths notice the plural at the end. This affects nbgrader/server_extensions/formgrader.py and nbgrader/converters/generate_feedback.py
  2. nbgrader/server_extensions/formgrader/formgrader.py is not correctly appending to HTMLExporter.template_paths. This should be an append not assignment.
  3. The server extensions templates are not using the latest nbconverter Jinja 2 file extension. They should all be moved from tpl to .html.j2 The references inside of the files to .tpl files should also be fixed accordingly.

Once I fixed those templating issues, I was able to render the webpage.

Hello, can you please be more specific, as I followed your mentioned steps and the main formgrader webpage does not render now.

I applied the next script and restarted the server, and now formgrader does not render:

#!/bin/bash
ext1=.tpl
ext2=.html.j2

TEMPLATES_DIR=/opt/conda/lib/python3.8/site-packages/nbgrader/server_extensions/formgrader/templates
for i in $TEMPLATES_DIR/*; do sudo su -c "mv $i ${i/$ext1/$ext2}"; done
for i in $TEMPLATES_DIR/*; do sudo su -c "sed -i 's/$ext1/$ext2/g' $i"; done

FORMGRADER_FILE=/opt/conda/lib/python3.8/site-packages/nbgrader/server_extensions/formgrader/formgrader.py
sudo su -c "sed -i 's/HTMLExporter\.template_path\ =\ \[handlers\.template_path\]/HTMLExporter\.template_paths\.append(handlers\.template_path)/g'  $FORMGRADER_FILE"

FEEDBACK_FILE=/opt/conda/lib/python3.8/site-packages/nbgrader/converters/generate_feedback.py
sudo su -c "sed -i 's/HTMLExporter.template_path/HTMLExporter.template_paths/g' $FEEDBACK_FILE"

What am I missing?

nbconvert version is 6.0.7

Thank you.

@orboan
Copy link

orboan commented Jun 16, 2021

Hello again,
so "BertR added a commit to BertR/nbgrader" is it working? I couldn't find the changing of the template extensions in references inside the template files. Is that done or only it is changed the file names?

I also have another question:

On what nbgrader version is based this BertR/nbgrader? I ask because I am using ngshare, and for that to work it is needed nbgrader 0.7.0.

Thanks a lot to everyone for all your contributions and help !

@astraw
Copy link

astraw commented Jul 6, 2021

I seem to have solved this problem for myself (with nbgrader 0.6.1) by reverting to nbconvert 5.6.

Nearly simultaneously, I also reverted to sqlalchemy=1.3 (from 1.4.x) and jinja2=2.11 (from 3.x) which may have also played a role. The sqlalchemy reversion seemed necessary to solve another issue I was having. I'm not sure if the jinja2 reversion was really needed for anything, but I did it before reverting nbconvert.

I note that there is ongoing work to upgrade to nbconvert 6 #1421 but I am using nbgrader 0.6.1 and didn't want to change it.

@debbieyuster
Copy link

Same as a few others, I too was able to resolve the formgrader error message by downgrading nbconvert from v.6.1.0 to v.5.6.0.
I am using nbgrader v0.6.1.

dpshelio added a commit to UCL-RITS/doctoral-programming-intro that referenced this issue Sep 28, 2021
pinning nbconvert with a particular version that has the templates
jupyter/nbgrader#1373

requires also pin jupyter-client to an earlier version
jupyter/jupyter_client#637
@whositwhatnow
Copy link

I am running nbconvert 5.6.1 and still encountering this error. wondering if i should reinstall or downgrade to 5.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
10 participants