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

Bug with "Raw NBConvert" cell #921

Open
kf71 opened this issue Jan 15, 2018 · 1 comment · May be fixed by #1922
Open

Bug with "Raw NBConvert" cell #921

kf71 opened this issue Jan 15, 2018 · 1 comment · May be fixed by #1922
Labels
Milestone

Comments

@kf71
Copy link

kf71 commented Jan 15, 2018

Operating system

Ubuntu 16.04.3 LTS

nbgrader --version

0.5.1

jupyterhub --version (if used with JupyterHub)

0.8.1

jupyter notebook --version

5.2.2

When trying to generate an assignment with a notebook containing a "Raw NBConvert" cell, I get the following error:

===================

[INFO] Updating/creating assignment 'test_python_raw': {}
[INFO] Converting notebook /home/xxxx/source/./test_python_raw/test_python.ipynb
[ERROR] There was an error processing assignment: /home/xxxx/source/./test_python_raw
[ERROR] Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/nbgrader/api.py", line 1674, in find_source_cell
.filter(SourceCell.name == name, Notebook.name == notebook, Assignment.name == assignment)
File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/query.py", line 2843, in one
raise orm_exc.NoResultFound("No row was found for one()")
sqlalchemy.orm.exc.NoResultFound: No row was found for one()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/api.py", line 1703, in update_or_create_source_cell
    source_cell = self.find_source_cell(name, notebook, assignment)
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/api.py", line 1677, in find_source_cell
    raise MissingEntry("No such source cell: {}/{}/{}".format(assignment, notebook, name))
nbgrader.api.MissingEntry: No such source cell: test_python_raw/test_python/cell-4357cb391b6565e5

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlite3.IntegrityError: CHECK constraint failed: source_cell_type

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/api.py", line 1646, in add_source_cell
    self.db.commit()
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/scoping.py", line 153, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/session.py", line 937, in commit
    self.transaction.commit()
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/session.py", line 461, in commit
    self._prepare_impl()
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/session.py", line 441, in _prepare_impl
    self.session.flush()
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/session.py", line 2237, in flush
    self._flush(objects)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/session.py", line 2363, in _flush
    transaction.rollback(_capture_exception=True)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/util/compat.py", line 187, in reraise
    raise value
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/session.py", line 2327, in _flush
    flush_context.execute()
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/unitofwork.py", line 391, in execute
    rec.execute(self)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/unitofwork.py", line 556, in execute
    uow
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/persistence.py", line 181, in save_obj
    mapper, table, insert)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/orm/persistence.py", line 866, in _emit_insert_statements
    execute(statement, params)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 948, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/sql/elements.py", line 269, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1060, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1200, in _execute_context
    context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1413, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/util/compat.py", line 203, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/util/compat.py", line 186, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/base.py", line 1193, in _execute_context
    context)
  File "/usr/local/lib/python3.5/dist-packages/sqlalchemy/engine/default.py", line 507, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) CHECK constraint failed: source_cell_type [SQL: 'INSERT INTO source_cell (id, name, cell_type, locked, source, checksum, notebook_id) VALUES (?, ?, ?, ?, ?, ?, ?)'] [parameters: ('b13cc42dd4bf43b6af7f50914c891d26', 'cell-4357cb391b6565e5', 'raw', 1, 'def f(x):\n    solution=2\n    return solution', 'd44cbd43b668532e37118b4ad667ff41', '3e3ae111b5dc47089f713f9d390ff4fc')] (Background on this error at: http://sqlalche.me/e/gkpj)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/converters/base.py", line 293, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/converters/base.py", line 249, in convert_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/exporters/exporter.py", line 174, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/exporters/exporter.py", line 192, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/exporters/notebook.py", line 31, in from_notebook_node
    nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/exporters/exporter.py", line 134, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/exporters/exporter.py", line 311, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/usr/local/lib/python3.5/dist-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/preprocessors/savecells.py", line 87, in preprocess
    self._create_notebook(nb)
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/preprocessors/savecells.py", line 61, in _create_notebook
    source_cell = self.gradebook.update_or_create_source_cell(name, self.notebook_id, self.assignment_id, **info)
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/api.py", line 1705, in update_or_create_source_cell
    source_cell = self.add_source_cell(name, notebook, assignment, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/nbgrader/api.py", line 1649, in add_source_cell
    raise InvalidEntry(*e.args)
nbgrader.api.InvalidEntry: (sqlite3.IntegrityError) CHECK constraint failed: source_cell_type

[ERROR] There was an error processing assignment 'test_python_raw' for student '.'
[ERROR] Please see the the above traceback for details on the specific errors on the above failures.

=================================

It is not a serious problem. I convert the cell to "Markdown" with pre /pre tag and everything is OK.

@lgpage lgpage added the bug label Feb 16, 2018
@lgpage lgpage added this to the 0.6.0 milestone Feb 16, 2018
@jhamrick
Copy link
Member

I can confirm this, and the issue is that in the SQLalchemy API I've only allowed cells to be code or markdown. I'm not quite sure why I did this, but it should definitely be amended to include raw cells as well.

@jhamrick jhamrick modified the milestones: 0.6.0, 0.7.0 May 30, 2019
@jhamrick jhamrick modified the milestones: 0.7.0, 0.8.0 Mar 18, 2021
@jhamrick jhamrick modified the milestones: 0.8.0, 0.8.1 Jun 23, 2022
@KrKOo KrKOo linked a pull request Sep 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants