otter-grader icon indicating copy to clipboard operation
otter-grader copied to clipboard

Make xeCJK opt-in behavior

Open chrispyles opened this issue 2 years ago • 4 comments

Make the use of the xeCJK template for Otter Export opt-in only. Currently, if PDF generation fails, Otter Export automatically tries again with xeCJK enabled, and then only shows the error message generated by the xeCJK template. Instead, this retry should not happen automatically, and instead the xecjk argument should be used to determine whether to use the xeCJK template or not. This would need to be added as an argument to functions that call Otter Export (e.g. otter.Notebook.export). This also means that no_xecjk/--no-xecjk can be removed.

chrispyles avatar Oct 09 '22 18:10 chrispyles

I think I am running into this problem now. During the export to PDF part of the otter assign process, I am getting this error when the process tries to generate template pdfs -- the solution pdfs work fine.

Here is the stack trace:

=====

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 69, in convert_notebook pdf_output = nbconvert.export(pdf_exporter, nb) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 86, in export output, resources = exporter_instance.from_notebook_node(nb, resources) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/nbconvert/exporters/pdf.py", line 200, in from_notebook_node raise LatexFailed("\n".join(self._captured_output)) nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output: This is BibTeX, Version 0.99d (TeX Live 2022/Homebrew) The top-level auxiliary file: notebook.aux I found no \citation commands---while reading file notebook.aux I found no \bibdata command---while reading file notebook.aux I found no \bibstyle command---while reading file notebook.aux (There were 3 error messages)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/sean/Documents/cb/venv-assignments-new/bin/otter", line 8, in sys.exit(cli()) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1130, in call return self.main(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/cli.py", line 32, in wrapper return f(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/cli.py", line 65, in assign_cli return assign(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/assign/init.py", line 138, in main export_notebook( File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/init.py", line 42, in export_notebook Exporter.convert_notebook(nb_path, pdf_name, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 75, in convert_notebook cls.convert_notebook(nb_path, dest, xecjk=True, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 84, in convert_notebook raise ExportFailedException(message) otter.export.exporters.base_exporter.ExportFailedException: There was an error generating your LaTeX; showing full error message: This is BibTeX, Version 0.99d (TeX Live 2022/Homebrew) The top-level auxiliary file: notebook.aux I found no \citation commands---while reading file notebook.aux I found no \bibdata command---while reading file notebook.aux I found no \bibstyle command---while reading file notebook.aux (There were 3 error messages)

If the error above is related to xeCJK or fandol in LaTeX and you don't require this functionality, try running again with no_xecjk set to True or the --no-xecjk flag.

=======

Am I doing something wrong to get this error at all?

I tried updating the system's TeXLive.

sean-morris avatar Oct 23 '22 22:10 sean-morris

Errors like

I found no \citation commands---while reading file notebook.aux
I found no \bibdata command---while reading file notebook.aux
I found no \bibstyle command---while reading file notebook.aux
(There were 3 error messages)

are usually caused by empty LaTeX being sent to nbconvert for export. Are there any manually-graded questions (i.e. is there any content between <!-- BEGIN QUESTION --> and <!-- END QUESTION --> comments) in your notebook?

chrispyles avatar Oct 23 '22 22:10 chrispyles

Ok, I think I have it narrowed down @chrispyles.

In otter-grader 3.3.0 we actually see the error but it does not stop the process: Screen Shot 2022-10-24 at 4 58 33 PM

In otter-grader 4.1.0, the process is killed. I pasted the stacktrace below.

On a whim, I decided to add a manually graded problem to the notebook -- there were none in the lab -- and now there is no error. It looks like the if your template_pdf attribute is set to true on a notebook with no manually-graded questions the LaTex processor freaks out. In otter-grader 3.3.0 this was not show stopping but in otter-grader 4.1.0 it is. I am not quite sure why that is the case.

otter-grader 4.1.0: otter assign output(with manually graded question): INFO otter.assign.main] Generating views [INFO otter.assign.main] Generating autograder zipfile [INFO otter.assign.main] Generating solutions PDF [INFO otter.assign.main] Generating template PDF [INFO otter.assign.main] Running tests against the solutions notebook [INFO otter.check.notebook.Notebook.grading_mode] Entering Notebook grading mode [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_2_1_2 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_2_3_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_2_3_2 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_3_1_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_4_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_4_1_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_2_1_2 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_2_3_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_2_3_2 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_3_1_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_4_1 [INFO otter.check.notebook.Notebook.check] Running check for question: q1_2_4_1_1 [INFO otter.check.notebook.Notebook.grading_mode] Exiting Notebook grading mode [INFO otter.assign.main] All autograder tests passed.

otter-grader 4.1.0: otter assign output(with no manually graded questions): [INFO otter.assign.main] Generating views [INFO otter.assign.main] Generating autograder zipfile [INFO otter.assign.main] Generating solutions PDF [INFO otter.assign.main] Generating template PDF Traceback (most recent call last): File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 69, in convert_notebook pdf_output = nbconvert.export(pdf_exporter, nb) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 86, in export output, resources = exporter_instance.from_notebook_node(nb, resources) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/nbconvert/exporters/pdf.py", line 200, in from_notebook_node raise LatexFailed("\n".join(self._captured_output)) nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output: This is BibTeX, Version 0.99d (TeX Live 2022/Homebrew) The top-level auxiliary file: notebook.aux I found no \citation commands---while reading file notebook.aux I found no \bibdata command---while reading file notebook.aux I found no \bibstyle command---while reading file notebook.aux (There were 3 error messages)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 69, in convert_notebook pdf_output = nbconvert.export(pdf_exporter, nb) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 86, in export output, resources = exporter_instance.from_notebook_node(nb, resources) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/nbconvert/exporters/pdf.py", line 200, in from_notebook_node raise LatexFailed("\n".join(self._captured_output)) nbconvert.exporters.pdf.LatexFailed: PDF creating failed, captured latex output: This is BibTeX, Version 0.99d (TeX Live 2022/Homebrew) The top-level auxiliary file: notebook.aux I found no \citation commands---while reading file notebook.aux I found no \bibdata command---while reading file notebook.aux I found no \bibstyle command---while reading file notebook.aux (There were 3 error messages)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/sean/Documents/cb/venv-assignments-new/bin/otter", line 8, in sys.exit(cli()) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1130, in call return self.main(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1657, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, **ctx.params) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/click/core.py", line 760, in invoke return __callback(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/cli.py", line 32, in wrapper return f(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/cli.py", line 65, in assign_cli return assign(*args, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/assign/init.py", line 138, in main export_notebook( File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/init.py", line 42, in export_notebook Exporter.convert_notebook(nb_path, pdf_name, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 75, in convert_notebook cls.convert_notebook(nb_path, dest, xecjk=True, **kwargs) File "/Users/sean/Documents/cb/venv-assignments-new/lib/python3.9/site-packages/otter/export/exporters/via_latex.py", line 84, in convert_notebook raise ExportFailedException(message) otter.export.exporters.base_exporter.ExportFailedException: There was an error generating your LaTeX; showing full error message: This is BibTeX, Version 0.99d (TeX Live 2022/Homebrew) The top-level auxiliary file: notebook.aux I found no \citation commands---while reading file notebook.aux I found no \bibdata command---while reading file notebook.aux I found no \bibstyle command---while reading file notebook.aux (There were 3 error messages)

If the error above is related to xeCJK or fandol in LaTeX and you don't require this functionality, try running again with no_xecjk set to True or the --no-xecjk flag.

sean-morris avatar Oct 25 '22 00:10 sean-morris

On a whim, I decided to add a manually graded problem to the notebook -- there were none in the lab -- and now there is no error.

Yes, from my last note, this is expected. If there are no manually graded questions, when Otter filters the notebook, there won't be anything left in the notebook, and LaTeX (or whatever flavor of it nbconvert uses) errors when there's nothing to render.

In otter-grader 3.3.0 this was not show stopping but in otter-grader 4.1.0 it is.

Yes, this was an intentional change to be able to surface these errors to students on Gradescope when there are errors generating a PDF of their submission.

chrispyles avatar Oct 26 '22 00:10 chrispyles

Great thanks -- ok. Didn't catch this was done on purpose. I am good.

sean-morris avatar Oct 26 '22 20:10 sean-morris